-
Notifications
You must be signed in to change notification settings - Fork 0
/
lexer.mll
22 lines (22 loc) · 826 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
(* File lexer.mll *)
{
open Parser (* The type token is defined in parser.mli *)
exception Eof
}
rule token = parse
[' ' '\t' '\n'] { token lexbuf } (* skip blanks *)
| ['0'-'9']+ as lxm { INT(lxm) }
| ['0'-'9']+ '.' ['0'-'9']* as lxm { FLOAT(lxm) }
| '+' { PLUS }
| '-' { MINUS }
| '*' { MUL }
| '/' { DIV }
| '%' { MOD }
| "+." { FPLUS }
| "-." { FMINUS }
| "*." { FMUL }
| '(' { LPAR }
| ')' { RPAR }
| "int" '(' ['0'-'9']+ '.' ['0'-'9']+ ')' as lxm { INTOFFLOAT(lxm) }
| "float" '(' ['0'-'9']+ ')' as lxm { FLOATOFINT(lxm) }
| eof { EOF }