]> git.kianting.info Git - uann/blob - ocaml_yacc/lexer.mll
a134e2ee9633ffa107ea23b590ec766f7180bbf3
[uann] / ocaml_yacc / lexer.mll
1 (* File lexer.mll *)
2 {
3 open Parser(* The type token is defined in parser.mli *)
4 exception Eof
5 }
6 rule token = parse
7 [' ' '\t'] { token lexbuf } (* skip blanks *)
8 | ['\n' ]{ EOL }
9 | ['i']['n'] { IN }
10 | ('_'|['a'-'z']|['A'-'Z']) as lxm { ID((String.make 1 lxm)) }
11 | ('_'|['a'-'z']|['A'-'Z'])(['0'-'9']|'_'|['a'-'z']|['A'-'Z'])+ as lxm { ID(lxm) }
12 | ['0'-'9']+ as lxm { INT(lxm) }
13 | '+' { PLUS }
14 | '-' { MINUS }
15 | '*' { TIMES }
16 | '/' { DIV }
17 | '(' { LPAREN }
18 | ')' { RPAREN }
19 | ['-']['>'] { IMPLY }
20 | ['=']['>'] { FUNC }
21 | '=' { ASSIGN }
22 | eof { raise Eof }