Home My Page Projects Code Snippets Project Openings SML/NJ
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files

SCM Repository

[smlnj] Annotation of /sml/trunk/src/ml-yacc/examples/fol/fol.lex
ViewVC logotype

Annotation of /sml/trunk/src/ml-yacc/examples/fol/fol.lex

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2 - (view) (download)

1 : monnier 2 structure Tokens = Tokens
2 :     structure Interface = Interface
3 :     open Interface
4 :    
5 :     type pos = Interface.pos
6 :     type svalue = Tokens.svalue
7 :     type ('a,'b) token = ('a,'b) Tokens.token
8 :     type lexresult= (svalue,pos) token
9 :    
10 :     val eof = fn () => Tokens.EOF(!line,!line)
11 :     fun makeInt (s : string) = s
12 :    
13 :     %%
14 :     %header (functor FolLexFun(structure Tokens: Fol_TOKENS
15 :     structure Interface: INTERFACE) : LEXER);
16 :     lcstart=[a-z!&$+/<=>?@~|#*`]|\-;
17 :     ucstart=[A-Z_];
18 :     idchars={lcstart}|{ucstart}|[0-9];
19 :     lcid={lcstart}{idchars}*;
20 :     ucid={ucstart}{idchars}*;
21 :     ws=[\t\ ]*;
22 :     num=[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());

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0