-
Notifications
You must be signed in to change notification settings - Fork 0
/
SrcLexer.x
42 lines (34 loc) · 1 KB
/
SrcLexer.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
{
module SrcLexer (srclexer) where
import SrcToken
}
%wrapper "basic"
$digit = 0-9
$alpha = [a-zA-Z]
tokens :-
$white+ ;
\\ { \_ -> SrcTokenLambda }
implicit { \_ -> SrcTokenImplicit }
interface { \_ -> SrcTokenInterface }
let { \_ -> SrcTokenLet }
in { \_ -> SrcTokenIn }
forall { \_ -> SrcTokenForall }
Int { \_ -> SrcTokenTInt }
[A-Z] [$alpha $digit \_ \']* { \s -> SrcTokenIfaceName s }
[a-z] [$alpha $digit \_ \']* { \s -> SrcTokenVar s }
$digit+ { \s -> SrcTokenInt (read s) }
\( { \_ -> SrcTokenOP }
\) { \_ -> SrcTokenCP }
\{ { \_ -> SrcTokenOB }
\} { \_ -> SrcTokenCB }
\: { \_ -> SrcTokenColon }
\; { \_ -> SrcTokenSemiColon }
\-\> { \_ -> SrcTokenArrow }
\=\> { \_ -> SrcTokenBigArrow }
\. { \_ -> SrcTokenDot }
\, { \_ -> SrcTokenComma }
\= { \_ -> SrcTokenEQ }
\? { \_ -> SrcTokenQuestion }
{
srclexer s = alexScanTokens s
}