Mercurial > urweb
comparison src/lacweb.lex @ 229:016d71e878c1
Relational operators; string literals for SQL
author | Adam Chlipala <adamc@hcoop.net> |
---|---|
date | Thu, 21 Aug 2008 15:27:04 -0400 |
parents | 524e10c91478 |
children | 87d41ac28b30 |
comparison
equal
deleted
inserted
replaced
228:19e5791923d0 | 229:016d71e878c1 |
---|---|
57 (); | 57 (); |
58 Tokens.EOF (pos, pos) | 58 Tokens.EOF (pos, pos) |
59 end | 59 end |
60 end | 60 end |
61 | 61 |
62 val strEnder = ref #"\"" | |
62 val str = ref ([] : char list) | 63 val str = ref ([] : char list) |
63 val strStart = ref 0 | 64 val strStart = ref 0 |
64 | 65 |
65 local | 66 local |
66 val initSig = ref false | 67 val initSig = ref false |
139 <COMMENT> "(*" => (enterComment (pos yypos); | 140 <COMMENT> "(*" => (enterComment (pos yypos); |
140 continue ()); | 141 continue ()); |
141 <COMMENT> "*)" => (if exitComment () then YYBEGIN INITIAL else (); | 142 <COMMENT> "*)" => (if exitComment () then YYBEGIN INITIAL else (); |
142 continue ()); | 143 continue ()); |
143 | 144 |
144 <INITIAL> "\"" => (YYBEGIN STRING; strStart := pos yypos; str := []; continue()); | 145 <INITIAL> "\"" => (YYBEGIN STRING; strEnder := #"\""; strStart := pos yypos; str := []; continue()); |
146 <INITIAL> "'" => (YYBEGIN STRING; strEnder := #"'"; strStart := pos yypos; str := []; continue()); | |
145 <STRING> "\\\"" => (str := #"\"" :: !str; continue()); | 147 <STRING> "\\\"" => (str := #"\"" :: !str; continue()); |
146 <STRING> "\"" => (if !xmlString then | 148 <STRING> "\\'" => (str := #"'" :: !str; continue()); |
147 (xmlString := false; YYBEGIN XMLTAG) | |
148 else | |
149 YYBEGIN INITIAL; | |
150 Tokens.STRING (String.implode (List.rev (!str)), !strStart, pos yypos + 1)); | |
151 <STRING> "\n" => (newline yypos; | 149 <STRING> "\n" => (newline yypos; |
152 str := #"\n" :: !str; continue()); | 150 str := #"\n" :: !str; continue()); |
153 <STRING> . => (str := String.sub (yytext, 0) :: !str; continue()); | 151 <STRING> . => (let |
152 val ch = String.sub (yytext, 0) | |
153 in | |
154 if ch = !strEnder then | |
155 (if !xmlString then | |
156 (xmlString := false; YYBEGIN XMLTAG) | |
157 else | |
158 YYBEGIN INITIAL; | |
159 Tokens.STRING (String.implode (List.rev (!str)), !strStart, pos yypos + 1)) | |
160 else | |
161 (str := ch :: !str; | |
162 continue ()) | |
163 end); | |
154 | 164 |
155 <INITIAL> "<" {id} ">"=> (let | 165 <INITIAL> "<" {id} ">"=> (let |
156 val tag = String.substring (yytext, 1, size yytext - 2) | 166 val tag = String.substring (yytext, 1, size yytext - 2) |
157 in | 167 in |
158 YYBEGIN XML; | 168 YYBEGIN XML; |
297 <INITIAL> "WHERE" => (Tokens.CWHERE (pos yypos, pos yypos + size yytext)); | 307 <INITIAL> "WHERE" => (Tokens.CWHERE (pos yypos, pos yypos + size yytext)); |
298 <INITIAL> "GROUP" => (Tokens.GROUP (pos yypos, pos yypos + size yytext)); | 308 <INITIAL> "GROUP" => (Tokens.GROUP (pos yypos, pos yypos + size yytext)); |
299 <INITIAL> "BY" => (Tokens.BY (pos yypos, pos yypos + size yytext)); | 309 <INITIAL> "BY" => (Tokens.BY (pos yypos, pos yypos + size yytext)); |
300 <INITIAL> "HAVING" => (Tokens.HAVING (pos yypos, pos yypos + size yytext)); | 310 <INITIAL> "HAVING" => (Tokens.HAVING (pos yypos, pos yypos + size yytext)); |
301 | 311 |
312 <INITIAL> "UNION" => (Tokens.UNION (pos yypos, pos yypos + size yytext)); | |
313 <INITIAL> "INTERSECT" => (Tokens.INTERSECT (pos yypos, pos yypos + size yytext)); | |
314 <INITIAL> "EXCEPT" => (Tokens.EXCEPT (pos yypos, pos yypos + size yytext)); | |
315 | |
302 <INITIAL> "TRUE" => (Tokens.TRUE (pos yypos, pos yypos + size yytext)); | 316 <INITIAL> "TRUE" => (Tokens.TRUE (pos yypos, pos yypos + size yytext)); |
303 <INITIAL> "FALSE" => (Tokens.FALSE (pos yypos, pos yypos + size yytext)); | 317 <INITIAL> "FALSE" => (Tokens.FALSE (pos yypos, pos yypos + size yytext)); |
304 <INITIAL> "AND" => (Tokens.CAND (pos yypos, pos yypos + size yytext)); | 318 <INITIAL> "AND" => (Tokens.CAND (pos yypos, pos yypos + size yytext)); |
305 <INITIAL> "OR" => (Tokens.OR (pos yypos, pos yypos + size yytext)); | 319 <INITIAL> "OR" => (Tokens.OR (pos yypos, pos yypos + size yytext)); |
306 <INITIAL> "NOT" => (Tokens.NOT (pos yypos, pos yypos + size yytext)); | 320 <INITIAL> "NOT" => (Tokens.NOT (pos yypos, pos yypos + size yytext)); |