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 33, Thu Feb 11 00:37:51 2010 UTC revision 40, Wed Mar 3 14:51:38 2010 UTC
# 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    
 <INITIAL> "("           => (T.LP);  
 <INITIAL> ")"           => (T.RP);  
 <INITIAL> "["           => (T.LB);  
 <INITIAL> "]"           => (T.RB);  
 <INITIAL> "{"           => (T.LCB);  
 <INITIAL> "}"           => (T.RCB);  
92  <INITIAL> "||"          => (T.OP_orelse);  <INITIAL> "||"          => (T.OP_orelse);
93  <INITIAL> "&&"          => (T.OP_andalso);  <INITIAL> "&&"          => (T.OP_andalso);
94  <INITIAL> "<"           => (T.OP_lt);  <INITIAL> "<"           => (T.OP_lt);
# Line 103  Line 100 
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);
106    <INITIAL> ")"           => (T.RP);
107    <INITIAL> "["           => (T.LB);
108    <INITIAL> "]"           => (T.RB);
109    <INITIAL> "{"           => (T.LCB);
110    <INITIAL> "}"           => (T.RCB);
111  <INITIAL> ","           => (T.COMMA);  <INITIAL> ","           => (T.COMMA);
112  <INITIAL> ";"           => (T.SEMI);  <INITIAL> ";"           => (T.SEMI);
113  <INITIAL> "#"           => (T.HASH);  <INITIAL> "#"           => (T.HASH);
114  <INITIAL> "!"           => (T.BANG);  <INITIAL> "!"           => (T.BANG);
115    <INITIAL> "="           => (T.OP_eq);
116    <INITIAL> "|"           => (T.BAR);
117    <INITIAL> ".."          => (T.DOTDOT);
118    
119  <INITIAL> {id}          => (Keywords.idToken yytext);  <INITIAL> {id}          => (Keywords.idToken yytext);
120    
121  <INITIAL> {num}         => (T.POSINT(valOf (IntInf.fromString yytext)));  <INITIAL> {num}         => (T.INT(valOf (IntInf.fromString yytext)));
122  <INITIAL> "-"{num}      => (T.NEGINT(valOf (IntInf.fromString yytext)));  <INITIAL> {num}"."{num}([eE][+-]?{num})?
 <INITIAL> "-"?{num}"."{num}([eE][+-]?{num})?  
123                          => (mkFloat yysubstr);                          => (mkFloat yysubstr);
124  <INITIAL> {ws}          => (skip ());  <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.33  
changed lines
  Added in v.40

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