-
Notifications
You must be signed in to change notification settings - Fork 0
/
lexmain.cmlex
44 lines (40 loc) · 928 Bytes
/
lexmain.cmlex
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
name LexMainFun
alphabet 128
set alpha = (range 'a 'z 'A 'Z)
set digit = (range '0 '9)
set alphanumeric = (| alpha digit '_ '')
set white = (| 32 9 10 13) /* space, tab, lf, cr */
set printable = (range '! '~)
set not_dquote = (~ '")
regexp ident = (seq alpha (* alphanumeric))
regexp ws = (+ white)
function lexmain : t =
eos => eof
ident => ident
(+ digit) => number
ws => skip
(seq '' printable) => char
"/*" => lcomment
(seq '" (* not_dquote) '") => string
'& => ampersand
"=>" => arrow
'| => bar
': => colon
'. => dot
'= => equal
'( => lparen
'- => minus
'+ => plus
'? => question
') => rparen
'/ => slash
'* => star
"**" => starstar
">=" => geq
'~ => tilde
epsilon => error
function skipcomment : u =
"/*" => comment_open
"*/" => comment_close
any => comment_skip
epsilon => comment_error