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

SCM Repository

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

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

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

trunk/src/parser/diderot.lex revision 14, Tue Jan 12 23:03:22 2010 UTC trunk/src/compiler/parser/diderot.lex revision 250, Fri Aug 6 21:37:28 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.OP_convolve);
106    <INITIAL> "(*)"         => (T.OP_convolve);
107    <INITIAL> "∇"         => (T.KW_D);
108  <INITIAL> "("           => (T.LP);  <INITIAL> "("           => (T.LP);
109  <INITIAL> ")"           => (T.RP);  <INITIAL> ")"           => (T.RP);
110  <INITIAL> "["           => (T.LB);  <INITIAL> "["           => (T.LB);
111  <INITIAL> "]"           => (T.RB);  <INITIAL> "]"           => (T.RB);
112  <INITIAL> "{"           => (T.LCB);  <INITIAL> "{"           => (T.LCB);
113  <INITIAL> "}"           => (T.RCB);  <INITIAL> "}"           => (T.RCB);
114    <INITIAL> ","           => (T.COMMA);
115    <INITIAL> ";"           => (T.SEMI);
116    <INITIAL> "#"           => (T.HASH);
117    <INITIAL> "!"           => (T.BANG);
118    <INITIAL> "="           => (T.OP_eq);
119    <INITIAL> "|"           => (T.BAR);
120    <INITIAL> ".."          => (T.DOTDOT);
121    
122    <INITIAL> "∞"         => (T.FLOAT FloatLit.posInf);
123    
124    <INITIAL> {id}          => (Keywords.idToken yytext);
125    
126    <INITIAL> {num}         => (T.INT(valOf (IntInf.fromString yytext)));
127    <INITIAL> {num}"."{num}([eE][+-]?{num})?
128                            => (mkFloat yysubstr);
129    <INITIAL> {ws}          => (skip ());
130    
131    <INITIAL> "\""          => (YYBEGIN STRING; continue());
132    
133    <INITIAL> .             => (lexErr(yypos, ["bad character `", String.toString yytext]);
134                                continue());
135    
136    (***** Strings *****)
137    <STRING>{esc}           => (addStr(valOf(String.fromString yytext)); continue());
138    <STRING>{sgood}+        => (addStr yytext; continue());
139    <STRING> "\""           => (YYBEGIN INITIAL; mkString());
140    
141    <STRING> .              => (lexErr(yypos, [
142                                    "bad character `", String.toString yytext,
143                                    "' in string literal"
144                                  ]);
145                                continue());
146    
147  (***** Comments *****)  (***** Comments *****)
148  <INITIAL> "//"  <INITIAL> "//"          => (YYBEGIN COM1; skip());
149          => (YYBEGIN COM1; skip());  <COM1> {eol}            => (YYBEGIN INITIAL; skip());
150  <COM1> {eol}  <COM1> .                => (skip());
         => (YYBEGIN INITIAL; skip());  
151    
152  <INITIAL> "/*"  <INITIAL> "/*"
153          => (YYBEGIN COM2; skip());          => (YYBEGIN COM2; skip());

Legend:
Removed from v.14  
changed lines
  Added in v.250

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