-
Notifications
You must be signed in to change notification settings - Fork 0
/
miniooLEX.mll
46 lines (38 loc) · 1.16 KB
/
miniooLEX.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
34
35
36
37
38
39
40
41
42
43
44
(* File miniooMENHIR.mll *)
{
open MiniooMENHIR (* Type token defined in miniooMENHIR.mli *)
exception Eof
}
rule token = parse
[' ' '\t' '\n' '\r'] {token lexbuf } (* skip blanks and tabs *)
| "true" as bool { TRUE }
| "false" as bool { FALSE }
| "var" { VAR }
| "proc" { PROCEDURE }
| "null" { NULL }
| "if" { IF }
| "else" { ELSE }
| "while" { WHILE }
| "malloc" { MALLOC }
| "skip" { SKIP }
| "atom" { ATOM }
| "eof" { print_string "\n lexer reached end of file \n"; EOF }
| (['A'-'Z'])(['a'-'z'] | ['A'-'Z'] | ['0'-'9'])* as ident
{ IDENT ident }
| (['a'-'z'] )(['a'-'z'] | ['A'-'Z'] | ['0'-'9'])* as field
{ FIELD field }
(*field with start with lower case*)
| ['0'-'9']+ as num
{ NUM (int_of_string num) }
| "|||" { PARALLEL }
| "==" { EQUALS }
| '<' { LT }
| ':' { COLON }
| ';' { SEMICOLON }
| '=' { ASSIGN }
| '-' { MINUS }
| '(' { LPAREN }
| ')' { RPAREN }
| '.' { LOCATION }
| '{' { LCUR }
| '}' { RCUR }