-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlexer.mll
executable file
·33 lines (32 loc) · 882 Bytes
/
lexer.mll
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
{
open Parser
}
let space = [' ' '\t' '\r' '\n']
let integer = ['0'-'9']+
let ident = ['a'-'z' 'A'-'Z'] ['0'-'9']*
rule token = parse
| space+ { token lexbuf }
| '(' { LPAREN }
| ')' { RPAREN }
| '[' { LBRACKET }
| ']' { RBRACKET }
| '$' { SUM }
| integer as i { CONST(int_of_string i) }
| '+' { PLUS }
| '-' { MINUS }
| '*' { MUL }
| '/' { DIV }
| '^' { POW }
| "<=" { LESS_EQUAL }
| ">=" { GREATER_EQUAL }
| '<' { LESS }
| '>' { GREATER }
| '=' { EQUAL }
| '|' { BAR }
| ',' { COMMA }
| "&&" { AND }
| "||" { OR }
| '@' { AT }
| ident as s { IDENT(s) }
| eof { EOF }
| _ { failwith "Unknown token" }