Debian Codegraph @

lib/mllpt-lib/ml-lpt/ml-antlr/examples/dragon/dragon.l

raw
1 %defs (
2 open Tokens;
3 fun eof() = EOF
4 type lex_result = token
5 );
6
7 %let eol=("\n"|"\013\n"|"\013");
8 %let ws=("\009"|"\011"|"\012"|" "|{eol});
9 %let alpha=[a-zA-Z];
10 %let digit=[0-9];
11 %let int={digit}+;
12 %let idchars=({alpha}|{digit}|"_");
13 %let id={alpha}{idchars}*;
14
15 {ws}+ => (skip());
16 "{" [^}]* "}" => (skip());
17
18 "program" => (KW_program);
19 "(" => (LP);
20 ")" => (RP);
21 ";" => (SEMI);
22 "." => (DOT);
23 "," => (COMMA);
24 "var" => (KW_var);
25 ":" => (COLON);
26 "array" => (KW_array);
27 "[" => (LSB);
28 "]" => (RSB);
29 "of" => (KW_of);
30 "integer" => (KW_integer);
31 "real" => (KW_real);
32 "function" => (KW_function);
33 "procedure" => (KW_procedure);
34 "begin" => (KW_begin);
35 "end" => (KW_end);
36 ":=" => (ASSIGNOP);
37 "if" => (KW_if);
38 "then" => (KW_then);
39 "else" => (KW_else);
40 "while" => (KW_while);
41 "do" => (KW_do);
42 "=" | "<>" | "<" | "<=" | ">=" | ">"
43 => (RELOP yytext);
44 "+" | "-" | "or"
45 => (ADDOP yytext);
46 "*" | "/" | "div" | "mod" | "and"
47 => (MULOP yytext);
48 "not" => (KW_not);
49 "-" => (MINUS);
50
51 {id} => (ID yytext);
52 {int} => (INT (valOf (IntInf.fromString yytext)));
53
54 . => (print (concat ["Unexpected character: '", yytext,
55 "'\n"]); continue());