Currently i'm trying to write an interpretter in Ocaml and this is my lexer.mll:
{
open Parser
exception Eof
}
rule main = parse
[ ' ' '\t' ] { main lexbuf }
| [ '\n' ] { EOL }
| ['0'-'9']+ as lxm { LINE_NUMBER(int_of_string lxm) }
| [^\\]*\.(\w+)$ as lxm { FILE_NAME lxm }
| "get_line" { GET_LINE }
(*| [ ^-?\b([0-9]{1,3}|1[0-9]{3}|20[0-4][0-9]|205[0-5])\b ] { RANGE } (* -2055 < RANGE < 2055 *)*)
| eof { raise Eof }
I'm really confused why ocamllex give me an error at the line { FILE_NAME lxm }. If i put #load "str.cma"
at the beginning of my lexer, it print out error syntax error on that line.
Why? i'm pretty confused ...
EDIT
should be [ [^\\]*\.(\w+)$ ] as lxm { FILE_NAME lxm }
But problem is still not solved ...