adamc@1
|
1 (* Copyright (c) 2008, Adam Chlipala
|
adamc@1
|
2 * All rights reserved.
|
adamc@1
|
3 *
|
adamc@1
|
4 * Redistribution and use in source and binary forms, with or without
|
adamc@1
|
5 * modification, are permitted provided that the following conditions are met:
|
adamc@1
|
6 *
|
adamc@1
|
7 * - Redistributions of source code must retain the above copyright notice,
|
adamc@1
|
8 * this list of conditions and the following disclaimer.
|
adamc@1
|
9 * - Redistributions in binary form must reproduce the above copyright notice,
|
adamc@1
|
10 * this list of conditions and the following disclaimer in the documentation
|
adamc@1
|
11 * and/or other materials provided with the distribution.
|
adamc@1
|
12 * - The names of contributors may not be used to endorse or promote products
|
adamc@1
|
13 * derived from this software without specific prior written permission.
|
adamc@1
|
14 *
|
adamc@1
|
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
adamc@1
|
16 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
adamc@1
|
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
adamc@1
|
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
adamc@1
|
19 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
adamc@1
|
20 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
adamc@1
|
21 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
adamc@1
|
22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
adamc@1
|
23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
adamc@1
|
24 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
adamc@1
|
25 * POSSIBILITY OF SUCH DAMAGE.
|
adamc@1
|
26 *)
|
adamc@1
|
27
|
adamc@244
|
28 (* Lexing info for Ur/Web programs *)
|
adamc@1
|
29
|
adamc@1
|
30 type pos = int
|
adamc@1
|
31 type svalue = Tokens.svalue
|
adamc@1
|
32 type ('a,'b) token = ('a,'b) Tokens.token
|
adamc@1
|
33 type lexresult = (svalue,pos) Tokens.token
|
adamc@1
|
34
|
adamc@1
|
35 local
|
adamc@1
|
36 val commentLevel = ref 0
|
adamc@1
|
37 val commentPos = ref 0
|
adamc@1
|
38 in
|
adamc@1
|
39 fun enterComment pos =
|
adamc@1
|
40 (if !commentLevel = 0 then
|
adamc@1
|
41 commentPos := pos
|
adamc@1
|
42 else
|
adamc@1
|
43 ();
|
adamc@1
|
44 commentLevel := !commentLevel + 1)
|
adamc@1
|
45
|
adamc@1
|
46 fun exitComment () =
|
adamc@1
|
47 (ignore (commentLevel := !commentLevel - 1);
|
adamc@1
|
48 !commentLevel = 0)
|
adamc@1
|
49
|
adamc@1
|
50 fun eof () =
|
adamc@1
|
51 let
|
adamc@1
|
52 val pos = ErrorMsg.lastLineStart ()
|
adamc@1
|
53 in
|
adamc@1
|
54 if !commentLevel > 0 then
|
adamc@1
|
55 ErrorMsg.errorAt' (!commentPos, !commentPos) "Unterminated comment"
|
adamc@1
|
56 else
|
adamc@1
|
57 ();
|
adamc@1
|
58 Tokens.EOF (pos, pos)
|
adamc@1
|
59 end
|
adamc@1
|
60 end
|
adamc@1
|
61
|
adamc@229
|
62 val strEnder = ref #"\""
|
adamc@14
|
63 val str = ref ([] : char list)
|
adamc@14
|
64 val strStart = ref 0
|
adamc@14
|
65
|
adamc@54
|
66 local
|
adamc@54
|
67 val initSig = ref false
|
adamc@54
|
68 val offset = ref 0
|
adamc@54
|
69 in
|
adamc@54
|
70
|
adamc@54
|
71 fun initialSig () = initSig := true
|
adamc@54
|
72
|
adamc@54
|
73 fun pos yypos = yypos - !offset
|
adamc@54
|
74
|
adamc@54
|
75 fun newline yypos =
|
adamc@54
|
76 if !initSig then
|
adamc@54
|
77 (initSig := false;
|
adamc@54
|
78 offset := yypos + 1)
|
adamc@54
|
79 else
|
adamc@54
|
80 ErrorMsg.newline (pos yypos)
|
adamc@54
|
81
|
adamc@54
|
82 end
|
adamc@54
|
83
|
adamc@91
|
84 val xmlTag = ref ([] : string list)
|
adamc@91
|
85 val xmlString = ref true
|
adamc@91
|
86 val braceLevels = ref ([] : ((unit -> unit) * int) list)
|
adamc@91
|
87
|
adamc@91
|
88 fun pushLevel s = braceLevels := (s, 1) :: (!braceLevels)
|
adamc@91
|
89
|
adamc@91
|
90 fun enterBrace () =
|
adamc@91
|
91 case !braceLevels of
|
adamc@91
|
92 (s, i) :: rest => braceLevels := (s, i+1) :: rest
|
adamc@91
|
93 | _ => ()
|
adamc@91
|
94
|
adamc@91
|
95 fun exitBrace () =
|
adamc@91
|
96 case !braceLevels of
|
adamc@91
|
97 (s, i) :: rest =>
|
adamc@91
|
98 if i = 1 then
|
adamc@91
|
99 (braceLevels := rest;
|
adamc@91
|
100 s ())
|
adamc@91
|
101 else
|
adamc@91
|
102 braceLevels := (s, i-1) :: rest
|
adamc@91
|
103 | _ => ()
|
adamc@91
|
104
|
adamc@91
|
105 fun initialize () = (xmlTag := [];
|
adamc@91
|
106 xmlString := false)
|
adamc@91
|
107
|
adamc@54
|
108
|
adamc@1
|
109 %%
|
adamc@244
|
110 %header (functor UrwebLexFn(structure Tokens : Urweb_TOKENS));
|
adamc@1
|
111 %full
|
adamc@91
|
112 %s COMMENT STRING XML XMLTAG;
|
adamc@1
|
113
|
adamc@48
|
114 id = [a-z_][A-Za-z0-9_']*;
|
adamc@316
|
115 cid = [A-Z][A-Za-z0-9_]*;
|
adamc@1
|
116 ws = [\ \t\012];
|
adamc@14
|
117 intconst = [0-9]+;
|
adamc@14
|
118 realconst = [0-9]+\.[0-9]*;
|
adamc@91
|
119 notags = [^<{\n]+;
|
adamc@1
|
120
|
adamc@1
|
121 %%
|
adamc@1
|
122
|
adamc@54
|
123 <INITIAL> \n => (newline yypos;
|
adamc@1
|
124 continue ());
|
adamc@54
|
125 <COMMENT> \n => (newline yypos;
|
adamc@1
|
126 continue ());
|
adamc@91
|
127 <XMLTAG> \n => (newline yypos;
|
adamc@91
|
128 continue ());
|
adamc@91
|
129 <XML> \n => (newline yypos;
|
adamc@91
|
130 Tokens.NOTAGS (yytext, yypos, yypos + size yytext));
|
adamc@1
|
131
|
adamc@1
|
132 <INITIAL> {ws}+ => (lex ());
|
adamc@1
|
133
|
adamc@1
|
134 <INITIAL> "(*" => (YYBEGIN COMMENT;
|
adamc@54
|
135 enterComment (pos yypos);
|
adamc@1
|
136 continue ());
|
adamc@54
|
137 <INITIAL> "*)" => (ErrorMsg.errorAt' (pos yypos, pos yypos) "Unbalanced comments";
|
adamc@1
|
138 continue ());
|
adamc@1
|
139
|
adamc@54
|
140 <COMMENT> "(*" => (enterComment (pos yypos);
|
adamc@1
|
141 continue ());
|
adamc@1
|
142 <COMMENT> "*)" => (if exitComment () then YYBEGIN INITIAL else ();
|
adamc@1
|
143 continue ());
|
adamc@1
|
144
|
adamc@229
|
145 <INITIAL> "\"" => (YYBEGIN STRING; strEnder := #"\""; strStart := pos yypos; str := []; continue());
|
adamc@229
|
146 <INITIAL> "'" => (YYBEGIN STRING; strEnder := #"'"; strStart := pos yypos; str := []; continue());
|
adamc@14
|
147 <STRING> "\\\"" => (str := #"\"" :: !str; continue());
|
adamc@229
|
148 <STRING> "\\'" => (str := #"'" :: !str; continue());
|
adamc@54
|
149 <STRING> "\n" => (newline yypos;
|
adamc@14
|
150 str := #"\n" :: !str; continue());
|
adamc@229
|
151 <STRING> . => (let
|
adamc@229
|
152 val ch = String.sub (yytext, 0)
|
adamc@229
|
153 in
|
adamc@229
|
154 if ch = !strEnder then
|
adamc@229
|
155 (if !xmlString then
|
adamc@229
|
156 (xmlString := false; YYBEGIN XMLTAG)
|
adamc@229
|
157 else
|
adamc@229
|
158 YYBEGIN INITIAL;
|
adamc@229
|
159 Tokens.STRING (String.implode (List.rev (!str)), !strStart, pos yypos + 1))
|
adamc@229
|
160 else
|
adamc@229
|
161 (str := ch :: !str;
|
adamc@229
|
162 continue ())
|
adamc@229
|
163 end);
|
adamc@14
|
164
|
adamc@360
|
165 <INITIAL> "<" {id} "/>"=>(let
|
adamc@360
|
166 val tag = String.substring (yytext, 1, size yytext - 3)
|
adamc@360
|
167 in
|
adamc@360
|
168 Tokens.XML_BEGIN_END (tag, yypos, yypos + size yytext)
|
adamc@360
|
169 end);
|
adamc@91
|
170 <INITIAL> "<" {id} ">"=> (let
|
adamc@91
|
171 val tag = String.substring (yytext, 1, size yytext - 2)
|
adamc@91
|
172 in
|
adamc@91
|
173 YYBEGIN XML;
|
adamc@91
|
174 xmlTag := tag :: (!xmlTag);
|
adamc@91
|
175 Tokens.XML_BEGIN (tag, yypos, yypos + size yytext)
|
adamc@91
|
176 end);
|
adamc@91
|
177 <XML> "</" {id} ">" => (let
|
adamc@91
|
178 val id = String.substring (yytext, 2, size yytext - 3)
|
adamc@91
|
179 in
|
adamc@91
|
180 case !xmlTag of
|
adamc@91
|
181 id' :: rest =>
|
adamc@91
|
182 if id = id' then
|
adamc@91
|
183 (YYBEGIN INITIAL;
|
adamc@91
|
184 xmlTag := rest;
|
adamc@91
|
185 Tokens.XML_END (yypos, yypos + size yytext))
|
adamc@91
|
186 else
|
adamc@91
|
187 Tokens.END_TAG (id, yypos, yypos + size yytext)
|
adamc@91
|
188 | _ =>
|
adamc@91
|
189 Tokens.END_TAG (id, yypos, yypos + size yytext)
|
adamc@91
|
190 end);
|
adamc@91
|
191
|
adamc@91
|
192 <XML> "<" {id} => (YYBEGIN XMLTAG;
|
adamc@91
|
193 Tokens.BEGIN_TAG (String.extract (yytext, 1, NONE),
|
adamc@91
|
194 yypos, yypos + size yytext));
|
adamc@91
|
195
|
adamc@91
|
196 <XMLTAG> "/" => (Tokens.DIVIDE (yypos, yypos + size yytext));
|
adamc@91
|
197 <XMLTAG> ">" => (YYBEGIN XML;
|
adamc@91
|
198 Tokens.GT (yypos, yypos + size yytext));
|
adamc@91
|
199
|
adamc@91
|
200 <XMLTAG> {ws}+ => (lex ());
|
adamc@91
|
201
|
adamc@91
|
202 <XMLTAG> {id} => (Tokens.SYMBOL (yytext, yypos, yypos + size yytext));
|
adamc@91
|
203 <XMLTAG> "=" => (Tokens.EQ (yypos, yypos + size yytext));
|
adamc@91
|
204
|
adamc@91
|
205 <XMLTAG> {intconst} => (case Int64.fromString yytext of
|
adamc@91
|
206 SOME x => Tokens.INT (x, yypos, yypos + size yytext)
|
adamc@91
|
207 | NONE => (ErrorMsg.errorAt' (yypos, yypos)
|
adamc@91
|
208 ("Expected int, received: " ^ yytext);
|
adamc@91
|
209 continue ()));
|
adamc@91
|
210 <XMLTAG> {realconst} => (case Real.fromString yytext of
|
adamc@91
|
211 SOME x => Tokens.FLOAT (x, yypos, yypos + size yytext)
|
adamc@91
|
212 | NONE => (ErrorMsg.errorAt' (yypos, yypos)
|
adamc@91
|
213 ("Expected float, received: " ^ yytext);
|
adamc@91
|
214 continue ()));
|
adamc@91
|
215 <XMLTAG> "\"" => (YYBEGIN STRING;
|
adamc@91
|
216 xmlString := true;
|
adamc@104
|
217 strStart := yypos; str := []; continue ());
|
adamc@91
|
218
|
adamc@91
|
219 <XMLTAG> "{" => (YYBEGIN INITIAL;
|
adamc@91
|
220 pushLevel (fn () => YYBEGIN XMLTAG);
|
adamc@91
|
221 Tokens.LBRACE (yypos, yypos + 1));
|
adamc@91
|
222 <XMLTAG> "(" => (YYBEGIN INITIAL;
|
adamc@91
|
223 pushLevel (fn () => YYBEGIN XMLTAG);
|
adamc@91
|
224 Tokens.LPAREN (yypos, yypos + 1));
|
adamc@91
|
225
|
adamc@91
|
226 <XMLTAG> . => (ErrorMsg.errorAt' (yypos, yypos)
|
adamc@91
|
227 ("illegal XML tag character: \"" ^ yytext ^ "\"");
|
adamc@91
|
228 continue ());
|
adamc@91
|
229
|
adamc@91
|
230 <XML> "{" => (YYBEGIN INITIAL;
|
adamc@91
|
231 pushLevel (fn () => YYBEGIN XML);
|
adamc@91
|
232 Tokens.LBRACE (yypos, yypos + 1));
|
adamc@91
|
233
|
adamc@91
|
234 <XML> {notags} => (Tokens.NOTAGS (yytext, yypos, yypos + size yytext));
|
adamc@91
|
235
|
adamc@91
|
236 <XML> . => (ErrorMsg.errorAt' (yypos, yypos)
|
adamc@91
|
237 ("illegal XML character: \"" ^ yytext ^ "\"");
|
adamc@91
|
238 continue ());
|
adamc@91
|
239
|
adamc@82
|
240 <INITIAL> "()" => (Tokens.UNIT (pos yypos, pos yypos + size yytext));
|
adamc@54
|
241 <INITIAL> "(" => (Tokens.LPAREN (pos yypos, pos yypos + size yytext));
|
adamc@54
|
242 <INITIAL> ")" => (Tokens.RPAREN (pos yypos, pos yypos + size yytext));
|
adamc@54
|
243 <INITIAL> "[" => (Tokens.LBRACK (pos yypos, pos yypos + size yytext));
|
adamc@54
|
244 <INITIAL> "]" => (Tokens.RBRACK (pos yypos, pos yypos + size yytext));
|
adamc@110
|
245 <INITIAL> "{" => (enterBrace ();
|
adamc@110
|
246 Tokens.LBRACE (pos yypos, pos yypos + size yytext));
|
adamc@110
|
247 <INITIAL> "}" => (exitBrace ();
|
adamc@110
|
248 Tokens.RBRACE (pos yypos, pos yypos + size yytext));
|
adamc@1
|
249
|
adamc@54
|
250 <INITIAL> "->" => (Tokens.ARROW (pos yypos, pos yypos + size yytext));
|
adamc@54
|
251 <INITIAL> "=>" => (Tokens.DARROW (pos yypos, pos yypos + size yytext));
|
adamc@54
|
252 <INITIAL> "++" => (Tokens.PLUSPLUS (pos yypos, pos yypos + size yytext));
|
adamc@149
|
253 <INITIAL> "--" => (Tokens.MINUSMINUS (pos yypos, pos yypos + size yytext));
|
adamc@1
|
254
|
adamc@54
|
255 <INITIAL> "=" => (Tokens.EQ (pos yypos, pos yypos + size yytext));
|
adamc@219
|
256 <INITIAL> "<>" => (Tokens.NE (pos yypos, pos yypos + size yytext));
|
adamc@219
|
257 <INITIAL> "<" => (Tokens.LT (pos yypos, pos yypos + size yytext));
|
adamc@219
|
258 <INITIAL> ">" => (Tokens.GT (pos yypos, pos yypos + size yytext));
|
adamc@219
|
259 <INITIAL> "<=" => (Tokens.LE (pos yypos, pos yypos + size yytext));
|
adamc@219
|
260 <INITIAL> ">=" => (Tokens.GE (pos yypos, pos yypos + size yytext));
|
adamc@54
|
261 <INITIAL> "," => (Tokens.COMMA (pos yypos, pos yypos + size yytext));
|
adamc@54
|
262 <INITIAL> ":::" => (Tokens.TCOLON (pos yypos, pos yypos + size yytext));
|
adamc@54
|
263 <INITIAL> "::" => (Tokens.DCOLON (pos yypos, pos yypos + size yytext));
|
adamc@54
|
264 <INITIAL> ":" => (Tokens.COLON (pos yypos, pos yypos + size yytext));
|
adamc@174
|
265 <INITIAL> "..." => (Tokens.DOTDOTDOT (pos yypos, pos yypos + size yytext));
|
adamc@54
|
266 <INITIAL> "." => (Tokens.DOT (pos yypos, pos yypos + size yytext));
|
adamc@54
|
267 <INITIAL> "$" => (Tokens.DOLLAR (pos yypos, pos yypos + size yytext));
|
adamc@54
|
268 <INITIAL> "#" => (Tokens.HASH (pos yypos, pos yypos + size yytext));
|
adamc@54
|
269 <INITIAL> "__" => (Tokens.UNDERUNDER (pos yypos, pos yypos + size yytext));
|
adamc@54
|
270 <INITIAL> "_" => (Tokens.UNDER (pos yypos, pos yypos + size yytext));
|
adamc@84
|
271 <INITIAL> "~" => (Tokens.TWIDDLE (pos yypos, pos yypos + size yytext));
|
adamc@156
|
272 <INITIAL> "|" => (Tokens.BAR (pos yypos, pos yypos + size yytext));
|
adamc@195
|
273 <INITIAL> "*" => (Tokens.STAR (pos yypos, pos yypos + size yytext));
|
adamc@243
|
274 <INITIAL> "<-" => (Tokens.LARROW (pos yypos, pos yypos + size yytext));
|
adamc@243
|
275 <INITIAL> ";" => (Tokens.SEMI (pos yypos, pos yypos + size yytext));
|
adamc@1
|
276
|
adamc@389
|
277 <INITIAL> "+" => (Tokens.PLUS (pos yypos, pos yypos + size yytext));
|
adamc@389
|
278 <INITIAL> "-" => (Tokens.MINUS (pos yypos, pos yypos + size yytext));
|
adamc@389
|
279 <INITIAL> "/" => (Tokens.DIVIDE (yypos, yypos + size yytext));
|
adamc@389
|
280 <INITIAL> "%" => (Tokens.MOD (pos yypos, pos yypos + size yytext));
|
adamc@389
|
281
|
adamc@54
|
282 <INITIAL> "con" => (Tokens.CON (pos yypos, pos yypos + size yytext));
|
adamc@54
|
283 <INITIAL> "type" => (Tokens.LTYPE (pos yypos, pos yypos + size yytext));
|
adamc@156
|
284 <INITIAL> "datatype" => (Tokens.DATATYPE (pos yypos, pos yypos + size yytext));
|
adamc@156
|
285 <INITIAL> "of" => (Tokens.OF (pos yypos, pos yypos + size yytext));
|
adamc@54
|
286 <INITIAL> "val" => (Tokens.VAL (pos yypos, pos yypos + size yytext));
|
adamc@123
|
287 <INITIAL> "rec" => (Tokens.REC (pos yypos, pos yypos + size yytext));
|
adamc@123
|
288 <INITIAL> "and" => (Tokens.AND (pos yypos, pos yypos + size yytext));
|
adamc@242
|
289 <INITIAL> "fun" => (Tokens.FUN (pos yypos, pos yypos + size yytext));
|
adamc@54
|
290 <INITIAL> "fn" => (Tokens.FN (pos yypos, pos yypos + size yytext));
|
adamc@67
|
291 <INITIAL> "fold" => (Tokens.FOLD (pos yypos, pos yypos + size yytext));
|
adamc@170
|
292 <INITIAL> "case" => (Tokens.CASE (pos yypos, pos yypos + size yytext));
|
adamc@190
|
293 <INITIAL> "if" => (Tokens.IF (pos yypos, pos yypos + size yytext));
|
adamc@190
|
294 <INITIAL> "then" => (Tokens.THEN (pos yypos, pos yypos + size yytext));
|
adamc@190
|
295 <INITIAL> "else" => (Tokens.ELSE (pos yypos, pos yypos + size yytext));
|
adamc@1
|
296
|
adamc@54
|
297 <INITIAL> "structure" => (Tokens.STRUCTURE (pos yypos, pos yypos + size yytext));
|
adamc@54
|
298 <INITIAL> "signature" => (Tokens.SIGNATURE (pos yypos, pos yypos + size yytext));
|
adamc@54
|
299 <INITIAL> "struct" => (Tokens.STRUCT (pos yypos, pos yypos + size yytext));
|
adamc@54
|
300 <INITIAL> "sig" => (if yypos = 2 then initialSig () else (); Tokens.SIG (pos yypos, pos yypos + size yytext));
|
adamc@54
|
301 <INITIAL> "end" => (Tokens.END (pos yypos, pos yypos + size yytext));
|
adamc@54
|
302 <INITIAL> "functor" => (Tokens.FUNCTOR (pos yypos, pos yypos + size yytext));
|
adamc@54
|
303 <INITIAL> "where" => (Tokens.WHERE (pos yypos, pos yypos + size yytext));
|
adamc@54
|
304 <INITIAL> "extern" => (Tokens.EXTERN (pos yypos, pos yypos + size yytext));
|
adamc@58
|
305 <INITIAL> "include" => (Tokens.INCLUDE (pos yypos, pos yypos + size yytext));
|
adamc@58
|
306 <INITIAL> "open" => (Tokens.OPEN (pos yypos, pos yypos + size yytext));
|
adamc@88
|
307 <INITIAL> "constraint"=> (Tokens.CONSTRAINT (pos yypos, pos yypos + size yytext));
|
adamc@88
|
308 <INITIAL> "constraints"=> (Tokens.CONSTRAINTS (pos yypos, pos yypos + size yytext));
|
adamc@109
|
309 <INITIAL> "export" => (Tokens.EXPORT (pos yypos, pos yypos + size yytext));
|
adamc@203
|
310 <INITIAL> "table" => (Tokens.TABLE (pos yypos, pos yypos + size yytext));
|
adamc@338
|
311 <INITIAL> "sequence" => (Tokens.SEQUENCE (pos yypos, pos yypos + size yytext));
|
adamc@211
|
312 <INITIAL> "class" => (Tokens.CLASS (pos yypos, pos yypos + size yytext));
|
adamc@339
|
313 <INITIAL> "with" => (Tokens.WITH (pos yypos, pos yypos + size yytext));
|
adamc@30
|
314
|
adamc@54
|
315 <INITIAL> "Type" => (Tokens.TYPE (pos yypos, pos yypos + size yytext));
|
adamc@54
|
316 <INITIAL> "Name" => (Tokens.NAME (pos yypos, pos yypos + size yytext));
|
adamc@82
|
317 <INITIAL> "Unit" => (Tokens.KUNIT (pos yypos, pos yypos + size yytext));
|
adamc@1
|
318
|
adamc@204
|
319 <INITIAL> "SELECT" => (Tokens.SELECT (pos yypos, pos yypos + size yytext));
|
adamc@204
|
320 <INITIAL> "FROM" => (Tokens.FROM (pos yypos, pos yypos + size yytext));
|
adamc@204
|
321 <INITIAL> "AS" => (Tokens.AS (pos yypos, pos yypos + size yytext));
|
adamc@209
|
322 <INITIAL> "WHERE" => (Tokens.CWHERE (pos yypos, pos yypos + size yytext));
|
adamc@339
|
323 <INITIAL> "SQL" => (Tokens.SQL (pos yypos, pos yypos + size yytext));
|
adamc@226
|
324 <INITIAL> "GROUP" => (Tokens.GROUP (pos yypos, pos yypos + size yytext));
|
adamc@230
|
325 <INITIAL> "ORDER" => (Tokens.ORDER (pos yypos, pos yypos + size yytext));
|
adamc@226
|
326 <INITIAL> "BY" => (Tokens.BY (pos yypos, pos yypos + size yytext));
|
adamc@227
|
327 <INITIAL> "HAVING" => (Tokens.HAVING (pos yypos, pos yypos + size yytext));
|
adamc@231
|
328 <INITIAL> "LIMIT" => (Tokens.LIMIT (pos yypos, pos yypos + size yytext));
|
adamc@231
|
329 <INITIAL> "OFFSET" => (Tokens.OFFSET (pos yypos, pos yypos + size yytext));
|
adamc@232
|
330 <INITIAL> "ALL" => (Tokens.ALL (pos yypos, pos yypos + size yytext));
|
adamc@209
|
331
|
adamc@229
|
332 <INITIAL> "UNION" => (Tokens.UNION (pos yypos, pos yypos + size yytext));
|
adamc@229
|
333 <INITIAL> "INTERSECT" => (Tokens.INTERSECT (pos yypos, pos yypos + size yytext));
|
adamc@229
|
334 <INITIAL> "EXCEPT" => (Tokens.EXCEPT (pos yypos, pos yypos + size yytext));
|
adamc@229
|
335
|
adamc@209
|
336 <INITIAL> "TRUE" => (Tokens.TRUE (pos yypos, pos yypos + size yytext));
|
adamc@209
|
337 <INITIAL> "FALSE" => (Tokens.FALSE (pos yypos, pos yypos + size yytext));
|
adamc@220
|
338 <INITIAL> "AND" => (Tokens.CAND (pos yypos, pos yypos + size yytext));
|
adamc@220
|
339 <INITIAL> "OR" => (Tokens.OR (pos yypos, pos yypos + size yytext));
|
adamc@220
|
340 <INITIAL> "NOT" => (Tokens.NOT (pos yypos, pos yypos + size yytext));
|
adamc@204
|
341
|
adamc@235
|
342 <INITIAL> "COUNT" => (Tokens.COUNT (pos yypos, pos yypos + size yytext));
|
adamc@236
|
343 <INITIAL> "AVG" => (Tokens.AVG (pos yypos, pos yypos + size yytext));
|
adamc@236
|
344 <INITIAL> "SUM" => (Tokens.SUM (pos yypos, pos yypos + size yytext));
|
adamc@236
|
345 <INITIAL> "MIN" => (Tokens.MIN (pos yypos, pos yypos + size yytext));
|
adamc@236
|
346 <INITIAL> "MAX" => (Tokens.MAX (pos yypos, pos yypos + size yytext));
|
adamc@235
|
347
|
adamc@268
|
348 <INITIAL> "ASC" => (Tokens.ASC (pos yypos, pos yypos + size yytext));
|
adamc@268
|
349 <INITIAL> "DESC" => (Tokens.DESC (pos yypos, pos yypos + size yytext));
|
adamc@268
|
350
|
adamc@302
|
351 <INITIAL> "INSERT" => (Tokens.INSERT (pos yypos, pos yypos + size yytext));
|
adamc@302
|
352 <INITIAL> "INTO" => (Tokens.INTO (pos yypos, pos yypos + size yytext));
|
adamc@302
|
353 <INITIAL> "VALUES" => (Tokens.VALUES (pos yypos, pos yypos + size yytext));
|
adamc@302
|
354 <INITIAL> "UPDATE" => (Tokens.UPDATE (pos yypos, pos yypos + size yytext));
|
adamc@302
|
355 <INITIAL> "SET" => (Tokens.SET (pos yypos, pos yypos + size yytext));
|
adamc@302
|
356 <INITIAL> "DELETE" => (Tokens.DELETE (pos yypos, pos yypos + size yytext));
|
adamc@302
|
357
|
adamc@54
|
358 <INITIAL> {id} => (Tokens.SYMBOL (yytext, pos yypos, pos yypos + size yytext));
|
adamc@54
|
359 <INITIAL> {cid} => (Tokens.CSYMBOL (yytext, pos yypos, pos yypos + size yytext));
|
adamc@1
|
360
|
adamc@14
|
361 <INITIAL> {intconst} => (case Int64.fromString yytext of
|
adamc@120
|
362 SOME x => Tokens.INT (x, pos yypos, pos yypos + size yytext)
|
adamc@120
|
363 | NONE => (ErrorMsg.errorAt' (pos yypos, pos yypos)
|
adamc@120
|
364 ("Expected int, received: " ^ yytext);
|
adamc@120
|
365 continue ()));
|
adamc@14
|
366 <INITIAL> {realconst} => (case Real64.fromString yytext of
|
adamc@54
|
367 SOME x => Tokens.FLOAT (x, pos yypos, pos yypos + size yytext)
|
adamc@54
|
368 | NONE => (ErrorMsg.errorAt' (pos yypos, pos yypos)
|
adamc@14
|
369 ("Expected float, received: " ^ yytext);
|
adamc@14
|
370 continue ()));
|
adamc@14
|
371
|
adamc@1
|
372 <COMMENT> . => (continue());
|
adamc@1
|
373
|
adamc@54
|
374 <INITIAL> . => (ErrorMsg.errorAt' (pos yypos, pos yypos)
|
adamc@1
|
375 ("illegal character: \"" ^ yytext ^ "\"");
|
adamc@1
|
376 continue ());
|