Home My Page Projects Code Snippets Project Openings diderot
Summary Activity Tracker Tasks SCM

SCM Repository

[diderot] Diff of /trunk/src/parser/diderot.lex
ViewVC logotype

Diff of /trunk/src/parser/diderot.lex

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 23, Mon Feb 1 03:29:06 2010 UTC revision 40, Wed Mar 3 14:51:38 2010 UTC
# Line 10  Line 10 
10    
11  %defs(  %defs(
12    
13      structure T = ManticoreTokens      structure T = DiderotTokens
14    
15    (* some type lex_result is necessitated by ml-ulex *)    (* some type lex_result is necessitated by ml-ulex *)
16      type lex_result = T.token      type lex_result = T.token
# Line 83  Line 83 
83  %let idchar = {letter}|{dig}|"_"|"'";  %let idchar = {letter}|{dig}|"_"|"'";
84  %let id = {letter}{idchar}*;  %let id = {letter}{idchar}*;
85  %let ws = " "|[\t\n\v\f\r];  %let ws = " "|[\t\n\v\f\r];
86    %let esc = "\\"[abfnrtv\\\"]|"\\"{dig}{dig}{dig};
87    %let sgood = [\032-\126]&[^\"\\]; (* sgood means "characters good inside strings" *)
88    %let eol = "\n";
89    
90  (***** Keywords and operators *****)  (***** Keywords and operators *****)
91    
92    <INITIAL> "||"          => (T.OP_orelse);
93    <INITIAL> "&&"          => (T.OP_andalso);
94    <INITIAL> "<"           => (T.OP_lt);
95    <INITIAL> "<="          => (T.OP_lte);
96    <INITIAL> "=="          => (T.OP_eqeq);
97    <INITIAL> "!="          => (T.OP_neq);
98    <INITIAL> ">="          => (T.OP_gte);
99    <INITIAL> ">"           => (T.OP_gt);
100  <INITIAL> "+"           => (T.OP_plus);  <INITIAL> "+"           => (T.OP_plus);
101  <INITIAL> "-"           => (T.OP_minus);  <INITIAL> "-"           => (T.OP_minus);
102  <INITIAL> "*"           => (T.OP_star);  <INITIAL> "*"           => (T.OP_star);
103    <INITIAL> "/"           => (T.OP_slash);
104  <INITIAL> "@"           => (T.OP_at);  <INITIAL> "@"           => (T.OP_at);
105  <INITIAL> "("           => (T.LP);  <INITIAL> "("           => (T.LP);
106  <INITIAL> ")"           => (T.RP);  <INITIAL> ")"           => (T.RP);
# Line 96  Line 108 
108  <INITIAL> "]"           => (T.RB);  <INITIAL> "]"           => (T.RB);
109  <INITIAL> "{"           => (T.LCB);  <INITIAL> "{"           => (T.LCB);
110  <INITIAL> "}"           => (T.RCB);  <INITIAL> "}"           => (T.RCB);
 <INITIAL> "<"           => (T.LT);  
 <INITIAL> "<="          => (T.LTEQ);  
 <INITIAL> "=="          => (T.EQEQ);  
 <INITIAL> "!="          => (T.NEQ);  
 <INITIAL> ">="          => (T.GTEQ);  
 <INITIAL> ">"           => (T.GT);  
111  <INITIAL> ","           => (T.COMMA);  <INITIAL> ","           => (T.COMMA);
112  <INITIAL> ";"           => (T.SEMI);  <INITIAL> ";"           => (T.SEMI);
 <INITIAL> ":"           => (T.COLON);  
113  <INITIAL> "#"           => (T.HASH);  <INITIAL> "#"           => (T.HASH);
114    <INITIAL> "!"           => (T.BANG);
115    <INITIAL> "="           => (T.OP_eq);
116    <INITIAL> "|"           => (T.BAR);
117    <INITIAL> ".."          => (T.DOTDOT);
118    
119    <INITIAL> {id}          => (Keywords.idToken yytext);
120    
121    <INITIAL> {num}         => (T.INT(valOf (IntInf.fromString yytext)));
122    <INITIAL> {num}"."{num}([eE][+-]?{num})?
123                            => (mkFloat yysubstr);
124    <INITIAL> {ws}          => (skip ());
125    
126    <INITIAL> .             => (lexErr(yypos, ["bad character `", String.toString yytext]);
127                                continue());
128    
129    (***** Strings *****)
130    
131    <INITIAL> "\""          => (YYBEGIN STRING; continue());
132    <STRING>{esc}           => (addStr(valOf(String.fromString yytext)); continue());
133    <STRING>{sgood}+        => (addStr yytext; continue());
134    <STRING> "\""           => (YYBEGIN INITIAL; mkString());
135    
136    <STRING> .              => (lexErr(yypos, [
137                                    "bad character `", String.toString yytext,
138                                    "' in string literal"
139                                  ]);
140                                continue());
141    
142  (***** Comments *****)  (***** Comments *****)
143  <INITIAL> "//"  <INITIAL> "//"          => (YYBEGIN COM1; skip());
144          => (YYBEGIN COM1; skip());  <COM1> {eol}            => (YYBEGIN INITIAL; skip());
145  <COM1> {eol}  <COM1> .                => (skip());
         => (YYBEGIN INITIAL; skip());  
146    
147  <INITIAL> "/*"  <INITIAL> "/*"
148          => (YYBEGIN COM2; skip());          => (YYBEGIN COM2; skip());

Legend:
Removed from v.23  
changed lines
  Added in v.40

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