-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLexer.x
44 lines (38 loc) · 1.43 KB
/
Lexer.x
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
{
module Lexer where
import Model
}
%wrapper "basic"
-- Some of the following tokens are copied from the official docs, from Alex.
$digit = 0-9 -- digits
$alpha = [a-zA-Z] -- alphabetic characters
tokens :-
$white+ ;
"--".* ;
"->" { const TArrow}
\; { const TSemicolon}
\, { const TComma}
\. { const TDot}
\_ { const TUnderscore }
go { const TGo}
take { const TTake}
mark { const TMark}
nothing { const TNothing}
turn { const TTurn}
case { const TCase}
of { const TOf}
end { const TEnd}
left { const TLeft}
right { const TRight}
front { const TFront}
Empty { const TEmpty}
Lambda { const TLambda}
Debris { const TDebris}
Asteroid { const TAsteroid}
Boundary { const TBoundary}
[$alpha $digit \+ \-]+ { \s -> TIdent s }
{
main = do
s <- getContents
print (alexScanTokens s)
}