This repository has been archived by the owner on Sep 18, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlexer.mll
55 lines (51 loc) · 2.11 KB
/
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
(* File lexer.mll, by Alex Everett & Jack Trute *)
{
open Parser
}
let blank = [' ' '\n' '\t']
let digits = ['0'-'9']+ as lxm
let lang =
'{'(' '*(['a'-'z']+|':')' '*','' '*)*(['a'-'z']+|':')?' '*'}' as lxm
let word =
('"'['a'-'z''A'-'Z''0'-'9']*'"')|':' as lxm
let ident =
['a'-'z''A'-'Z''0'-'9']+ as lxm
let comment = '(''*'_*'*'')'
rule lexermain = parse
| blank { lexermain lexbuf }
| digits { INT(int_of_string lxm) }
| lang { LANGUAGE(lxm) }
| word { STRING(lxm) }
| comment { COMMENT }
| '(' { LPAREN }
| ')' { RPAREN }
| '<' { LESS }
| '>' { GREATER }
| '=' { EQUAL }
| '+' { PLUS }
| '-' { MINUS }
| "==" { EQUALS }
| "begin" { BEGIN }
| "fi" { FINISH }
| "cond" { COND }
| "then" { THEN }
| "else" { ELSE }
| "len" { LENGTH }
| "cons" { CONS }
| "concat" { CONCAT }
| "funct" { FUNCT }
| "->" { FARROW }
| "in" { IN }
| "var" { VAR }
| "union" { UNION }
| ":" { EMPTYWORD("") }
| "head" { HEAD }
| "tail" { TAIL }
| "sort" { SORT }
| "uniq" { UNIQ }
| "cap" { CAP }
| "append" { APPEND }
| ident { IDENT(lxm) }
| "$"['1'-'9']+ as lxm { LANGUAGE(read_line lxm) }
| "$last_line" { INT(get_last_line 10) }
| eof { EOF }