Import Upstream version 20180207
[hcoop/debian/mlton.git] / mlyacc / examples / fol / fol.lex
CommitLineData
7f918cf1
CE
1structure Tokens = Tokens
2structure Interface = Interface
3open Interface
4
5type pos = Interface.pos
6type svalue = Tokens.svalue
7type ('a,'b) token = ('a,'b) Tokens.token
8type lexresult= (svalue,pos) token
9
10val eof = fn () => Tokens.EOF(!line,!line)
11fun makeInt (s : string) = s
12
13%%
14%header (functor FolLexFun(structure Tokens: Fol_TOKENS
15 structure Interface: INTERFACE) : LEXER);
16lcstart=[a-z!&$+/<=>?@~|#*`]|\-;
17ucstart=[A-Z_];
18idchars={lcstart}|{ucstart}|[0-9];
19lcid={lcstart}{idchars}*;
20ucid={ucstart}{idchars}*;
21ws=[\t\ ]*;
22num=[0-9]+;
23%%
24<INITIAL>{ws} => (lex());
25<INITIAL>\n => (next_line(); lex());
26<INITIAL>":-" => (Tokens.BACKARROW(!line,!line));
27<INITIAL>"," => (Tokens.COMMA(!line,!line));
28<INITIAL>";" => (Tokens.SEMICOLON(!line,!line));
29<INITIAL>"." => (Tokens.DOT(!line,!line));
30<INITIAL>"(" => (Tokens.LPAREN(!line,!line));
31<INITIAL>")" => (Tokens.RPAREN(!line,!line));
32<INITIAL>"->" => (Tokens.ARROW(!line,!line));
33<INITIAL>"=>" => (Tokens.DOUBLEARROW(!line,!line));
34<INITIAL>"|" => (Tokens.BAR(!line,!line));
35<INITIAL>"true" => (Tokens.TRUE(!line,!line));
36<INITIAL>"forall" => (Tokens.FORALL(!line,!line));
37<INITIAL>"exists" => (Tokens.EXISTS(!line,!line));
38<INITIAL>{lcid} => (Tokens.LCID (yytext,!line,!line));
39<INITIAL>{ucid} => (Tokens.UCID (yytext,!line,!line));
40<INITIAL>{num} => (Tokens.INT (makeInt yytext,!line,!line));
41<INITIAL>. => (error ("ignoring illegal character" ^ yytext,
42 !line,!line); lex());