FSLex Unknown Error

278 views Asked by At

I got some problem with my FSLex which I can't solve... All I know is that fslex.exe exited with code 1...

The F# code at the top was tested in F# Interactive, so the problem isn't there (I can't see how).

Lexer: http://pastebin.com/qnDnUh59

And Parser.fsi: http://pastebin.com/sGyLqZbN

Thanks, Ramon.

1

There are 1 answers

1
Juliet On BEST ANSWER

Non-zero error means the lexer failed, usually it'll describe the failure too. When I compile, I get exited with code 1 along with this:

Unexpected character '\'

let id = [\w'.']+ 
----------^

Lexer doesn't like char literals outside of quotes, and it doesn't understand the meaning of \w either. According to FsLex source code, FsLex only understands the following escape sequences:

let escape c =
 match c with
 | '\\' -> '\\'
 | '\'' -> '\''
 | 'n' -> '\n'
 | 't' -> '\t'
 | 'b' -> '\b'
 | 'r' -> '\r'
 | c -> c

This fixed version of your lexer compiles fine for me: http://pastebin.com/QGNk3VKD