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@623
|
250 <INITIAL> "-->" => (Tokens.KARROW (pos yypos, pos yypos + size yytext));
|
adamc@54
|
251 <INITIAL> "->" => (Tokens.ARROW (pos yypos, pos yypos + size yytext));
|
adamc@623
|
252 <INITIAL> "==>" => (Tokens.DKARROW (pos yypos, pos yypos + size yytext));
|
adamc@54
|
253 <INITIAL> "=>" => (Tokens.DARROW (pos yypos, pos yypos + size yytext));
|
adamc@54
|
254 <INITIAL> "++" => (Tokens.PLUSPLUS (pos yypos, pos yypos + size yytext));
|
adamc@149
|
255 <INITIAL> "--" => (Tokens.MINUSMINUS (pos yypos, pos yypos + size yytext));
|
adamc@493
|
256 <INITIAL> "---" => (Tokens.MINUSMINUSMINUS (pos yypos, pos yypos + size yytext));
|
adamc@674
|
257 <INITIAL> "^" => (Tokens.CARET (pos yypos, pos yypos + size yytext));
|
adamc@1
|
258
|
adamc@54
|
259 <INITIAL> "=" => (Tokens.EQ (pos yypos, pos yypos + size yytext));
|
adamc@219
|
260 <INITIAL> "<>" => (Tokens.NE (pos yypos, pos yypos + size yytext));
|
adamc@219
|
261 <INITIAL> "<" => (Tokens.LT (pos yypos, pos yypos + size yytext));
|
adamc@219
|
262 <INITIAL> ">" => (Tokens.GT (pos yypos, pos yypos + size yytext));
|
adamc@219
|
263 <INITIAL> "<=" => (Tokens.LE (pos yypos, pos yypos + size yytext));
|
adamc@219
|
264 <INITIAL> ">=" => (Tokens.GE (pos yypos, pos yypos + size yytext));
|
adamc@54
|
265 <INITIAL> "," => (Tokens.COMMA (pos yypos, pos yypos + size yytext));
|
adamc@54
|
266 <INITIAL> ":::" => (Tokens.TCOLON (pos yypos, pos yypos + size yytext));
|
adamc@54
|
267 <INITIAL> "::" => (Tokens.DCOLON (pos yypos, pos yypos + size yytext));
|
adamc@54
|
268 <INITIAL> ":" => (Tokens.COLON (pos yypos, pos yypos + size yytext));
|
adamc@174
|
269 <INITIAL> "..." => (Tokens.DOTDOTDOT (pos yypos, pos yypos + size yytext));
|
adamc@54
|
270 <INITIAL> "." => (Tokens.DOT (pos yypos, pos yypos + size yytext));
|
adamc@54
|
271 <INITIAL> "$" => (Tokens.DOLLAR (pos yypos, pos yypos + size yytext));
|
adamc@54
|
272 <INITIAL> "#" => (Tokens.HASH (pos yypos, pos yypos + size yytext));
|
adamc@54
|
273 <INITIAL> "__" => (Tokens.UNDERUNDER (pos yypos, pos yypos + size yytext));
|
adamc@54
|
274 <INITIAL> "_" => (Tokens.UNDER (pos yypos, pos yypos + size yytext));
|
adamc@84
|
275 <INITIAL> "~" => (Tokens.TWIDDLE (pos yypos, pos yypos + size yytext));
|
adamc@156
|
276 <INITIAL> "|" => (Tokens.BAR (pos yypos, pos yypos + size yytext));
|
adamc@195
|
277 <INITIAL> "*" => (Tokens.STAR (pos yypos, pos yypos + size yytext));
|
adamc@243
|
278 <INITIAL> "<-" => (Tokens.LARROW (pos yypos, pos yypos + size yytext));
|
adamc@243
|
279 <INITIAL> ";" => (Tokens.SEMI (pos yypos, pos yypos + size yytext));
|
adamc@629
|
280 <INITIAL> "!" => (Tokens.BANG (pos yypos, pos yypos + size yytext));
|
adamc@1
|
281
|
adamc@389
|
282 <INITIAL> "+" => (Tokens.PLUS (pos yypos, pos yypos + size yytext));
|
adamc@389
|
283 <INITIAL> "-" => (Tokens.MINUS (pos yypos, pos yypos + size yytext));
|
adamc@389
|
284 <INITIAL> "/" => (Tokens.DIVIDE (yypos, yypos + size yytext));
|
adamc@389
|
285 <INITIAL> "%" => (Tokens.MOD (pos yypos, pos yypos + size yytext));
|
adamc@403
|
286 <INITIAL> "@" => (Tokens.AT (pos yypos, pos yypos + size yytext));
|
adamc@389
|
287
|
adamc@54
|
288 <INITIAL> "con" => (Tokens.CON (pos yypos, pos yypos + size yytext));
|
adamc@54
|
289 <INITIAL> "type" => (Tokens.LTYPE (pos yypos, pos yypos + size yytext));
|
adamc@156
|
290 <INITIAL> "datatype" => (Tokens.DATATYPE (pos yypos, pos yypos + size yytext));
|
adamc@156
|
291 <INITIAL> "of" => (Tokens.OF (pos yypos, pos yypos + size yytext));
|
adamc@54
|
292 <INITIAL> "val" => (Tokens.VAL (pos yypos, pos yypos + size yytext));
|
adamc@123
|
293 <INITIAL> "rec" => (Tokens.REC (pos yypos, pos yypos + size yytext));
|
adamc@123
|
294 <INITIAL> "and" => (Tokens.AND (pos yypos, pos yypos + size yytext));
|
adamc@242
|
295 <INITIAL> "fun" => (Tokens.FUN (pos yypos, pos yypos + size yytext));
|
adamc@54
|
296 <INITIAL> "fn" => (Tokens.FN (pos yypos, pos yypos + size yytext));
|
adamc@621
|
297 <INITIAL> "map" => (Tokens.MAP (pos yypos, pos yypos + size yytext));
|
adamc@170
|
298 <INITIAL> "case" => (Tokens.CASE (pos yypos, pos yypos + size yytext));
|
adamc@190
|
299 <INITIAL> "if" => (Tokens.IF (pos yypos, pos yypos + size yytext));
|
adamc@190
|
300 <INITIAL> "then" => (Tokens.THEN (pos yypos, pos yypos + size yytext));
|
adamc@190
|
301 <INITIAL> "else" => (Tokens.ELSE (pos yypos, pos yypos + size yytext));
|
adamc@1
|
302
|
adamc@54
|
303 <INITIAL> "structure" => (Tokens.STRUCTURE (pos yypos, pos yypos + size yytext));
|
adamc@54
|
304 <INITIAL> "signature" => (Tokens.SIGNATURE (pos yypos, pos yypos + size yytext));
|
adamc@54
|
305 <INITIAL> "struct" => (Tokens.STRUCT (pos yypos, pos yypos + size yytext));
|
adamc@54
|
306 <INITIAL> "sig" => (if yypos = 2 then initialSig () else (); Tokens.SIG (pos yypos, pos yypos + size yytext));
|
adamc@446
|
307 <INITIAL> "let" => (Tokens.LET (pos yypos, pos yypos + size yytext));
|
adamc@446
|
308 <INITIAL> "in" => (Tokens.IN (pos yypos, pos yypos + size yytext));
|
adamc@54
|
309 <INITIAL> "end" => (Tokens.END (pos yypos, pos yypos + size yytext));
|
adamc@54
|
310 <INITIAL> "functor" => (Tokens.FUNCTOR (pos yypos, pos yypos + size yytext));
|
adamc@54
|
311 <INITIAL> "where" => (Tokens.WHERE (pos yypos, pos yypos + size yytext));
|
adamc@54
|
312 <INITIAL> "extern" => (Tokens.EXTERN (pos yypos, pos yypos + size yytext));
|
adamc@58
|
313 <INITIAL> "include" => (Tokens.INCLUDE (pos yypos, pos yypos + size yytext));
|
adamc@58
|
314 <INITIAL> "open" => (Tokens.OPEN (pos yypos, pos yypos + size yytext));
|
adamc@88
|
315 <INITIAL> "constraint"=> (Tokens.CONSTRAINT (pos yypos, pos yypos + size yytext));
|
adamc@88
|
316 <INITIAL> "constraints"=> (Tokens.CONSTRAINTS (pos yypos, pos yypos + size yytext));
|
adamc@109
|
317 <INITIAL> "export" => (Tokens.EXPORT (pos yypos, pos yypos + size yytext));
|
adamc@203
|
318 <INITIAL> "table" => (Tokens.TABLE (pos yypos, pos yypos + size yytext));
|
adamc@338
|
319 <INITIAL> "sequence" => (Tokens.SEQUENCE (pos yypos, pos yypos + size yytext));
|
adamc@211
|
320 <INITIAL> "class" => (Tokens.CLASS (pos yypos, pos yypos + size yytext));
|
adamc@459
|
321 <INITIAL> "cookie" => (Tokens.COOKIE (pos yypos, pos yypos + size yytext));
|
adamc@30
|
322
|
adamc@54
|
323 <INITIAL> "Type" => (Tokens.TYPE (pos yypos, pos yypos + size yytext));
|
adamc@54
|
324 <INITIAL> "Name" => (Tokens.NAME (pos yypos, pos yypos + size yytext));
|
adamc@82
|
325 <INITIAL> "Unit" => (Tokens.KUNIT (pos yypos, pos yypos + size yytext));
|
adamc@1
|
326
|
adamc@204
|
327 <INITIAL> "SELECT" => (Tokens.SELECT (pos yypos, pos yypos + size yytext));
|
adamc@204
|
328 <INITIAL> "FROM" => (Tokens.FROM (pos yypos, pos yypos + size yytext));
|
adamc@204
|
329 <INITIAL> "AS" => (Tokens.AS (pos yypos, pos yypos + size yytext));
|
adamc@209
|
330 <INITIAL> "WHERE" => (Tokens.CWHERE (pos yypos, pos yypos + size yytext));
|
adamc@339
|
331 <INITIAL> "SQL" => (Tokens.SQL (pos yypos, pos yypos + size yytext));
|
adamc@226
|
332 <INITIAL> "GROUP" => (Tokens.GROUP (pos yypos, pos yypos + size yytext));
|
adamc@230
|
333 <INITIAL> "ORDER" => (Tokens.ORDER (pos yypos, pos yypos + size yytext));
|
adamc@226
|
334 <INITIAL> "BY" => (Tokens.BY (pos yypos, pos yypos + size yytext));
|
adamc@227
|
335 <INITIAL> "HAVING" => (Tokens.HAVING (pos yypos, pos yypos + size yytext));
|
adamc@231
|
336 <INITIAL> "LIMIT" => (Tokens.LIMIT (pos yypos, pos yypos + size yytext));
|
adamc@231
|
337 <INITIAL> "OFFSET" => (Tokens.OFFSET (pos yypos, pos yypos + size yytext));
|
adamc@232
|
338 <INITIAL> "ALL" => (Tokens.ALL (pos yypos, pos yypos + size yytext));
|
adamc@209
|
339
|
adamc@229
|
340 <INITIAL> "UNION" => (Tokens.UNION (pos yypos, pos yypos + size yytext));
|
adamc@229
|
341 <INITIAL> "INTERSECT" => (Tokens.INTERSECT (pos yypos, pos yypos + size yytext));
|
adamc@229
|
342 <INITIAL> "EXCEPT" => (Tokens.EXCEPT (pos yypos, pos yypos + size yytext));
|
adamc@229
|
343
|
adamc@209
|
344 <INITIAL> "TRUE" => (Tokens.TRUE (pos yypos, pos yypos + size yytext));
|
adamc@209
|
345 <INITIAL> "FALSE" => (Tokens.FALSE (pos yypos, pos yypos + size yytext));
|
adamc@220
|
346 <INITIAL> "AND" => (Tokens.CAND (pos yypos, pos yypos + size yytext));
|
adamc@220
|
347 <INITIAL> "OR" => (Tokens.OR (pos yypos, pos yypos + size yytext));
|
adamc@220
|
348 <INITIAL> "NOT" => (Tokens.NOT (pos yypos, pos yypos + size yytext));
|
adamc@204
|
349
|
adamc@235
|
350 <INITIAL> "COUNT" => (Tokens.COUNT (pos yypos, pos yypos + size yytext));
|
adamc@236
|
351 <INITIAL> "AVG" => (Tokens.AVG (pos yypos, pos yypos + size yytext));
|
adamc@236
|
352 <INITIAL> "SUM" => (Tokens.SUM (pos yypos, pos yypos + size yytext));
|
adamc@236
|
353 <INITIAL> "MIN" => (Tokens.MIN (pos yypos, pos yypos + size yytext));
|
adamc@236
|
354 <INITIAL> "MAX" => (Tokens.MAX (pos yypos, pos yypos + size yytext));
|
adamc@235
|
355
|
adamc@268
|
356 <INITIAL> "ASC" => (Tokens.ASC (pos yypos, pos yypos + size yytext));
|
adamc@268
|
357 <INITIAL> "DESC" => (Tokens.DESC (pos yypos, pos yypos + size yytext));
|
adamc@268
|
358
|
adamc@302
|
359 <INITIAL> "INSERT" => (Tokens.INSERT (pos yypos, pos yypos + size yytext));
|
adamc@302
|
360 <INITIAL> "INTO" => (Tokens.INTO (pos yypos, pos yypos + size yytext));
|
adamc@302
|
361 <INITIAL> "VALUES" => (Tokens.VALUES (pos yypos, pos yypos + size yytext));
|
adamc@302
|
362 <INITIAL> "UPDATE" => (Tokens.UPDATE (pos yypos, pos yypos + size yytext));
|
adamc@302
|
363 <INITIAL> "SET" => (Tokens.SET (pos yypos, pos yypos + size yytext));
|
adamc@302
|
364 <INITIAL> "DELETE" => (Tokens.DELETE (pos yypos, pos yypos + size yytext));
|
adamc@467
|
365 <INITIAL> "NULL" => (Tokens.NULL (pos yypos, pos yypos + size yytext));
|
adamc@470
|
366 <INITIAL> "IS" => (Tokens.IS (pos yypos, pos yypos + size yytext));
|
adamc@302
|
367
|
adamc@704
|
368 <INITIAL> "CONSTRAINT"=> (Tokens.CCONSTRAINT (pos yypos, pos yypos + size yytext));
|
adamc@704
|
369 <INITIAL> "UNIQUE" => (Tokens.UNIQUE (pos yypos, pos yypos + size yytext));
|
adamc@704
|
370
|
adamc@441
|
371 <INITIAL> "CURRENT_TIMESTAMP" => (Tokens.CURRENT_TIMESTAMP (pos yypos, pos yypos + size yytext));
|
adamc@441
|
372
|
adamc@54
|
373 <INITIAL> {id} => (Tokens.SYMBOL (yytext, pos yypos, pos yypos + size yytext));
|
adamc@54
|
374 <INITIAL> {cid} => (Tokens.CSYMBOL (yytext, pos yypos, pos yypos + size yytext));
|
adamc@1
|
375
|
adamc@14
|
376 <INITIAL> {intconst} => (case Int64.fromString yytext of
|
adamc@120
|
377 SOME x => Tokens.INT (x, pos yypos, pos yypos + size yytext)
|
adamc@120
|
378 | NONE => (ErrorMsg.errorAt' (pos yypos, pos yypos)
|
adamc@120
|
379 ("Expected int, received: " ^ yytext);
|
adamc@120
|
380 continue ()));
|
adamc@14
|
381 <INITIAL> {realconst} => (case Real64.fromString yytext of
|
adamc@54
|
382 SOME x => Tokens.FLOAT (x, pos yypos, pos yypos + size yytext)
|
adamc@54
|
383 | NONE => (ErrorMsg.errorAt' (pos yypos, pos yypos)
|
adamc@14
|
384 ("Expected float, received: " ^ yytext);
|
adamc@14
|
385 continue ()));
|
adamc@14
|
386
|
adamc@1
|
387 <COMMENT> . => (continue());
|
adamc@1
|
388
|
adamc@54
|
389 <INITIAL> . => (ErrorMsg.errorAt' (pos yypos, pos yypos)
|
adamc@1
|
390 ("illegal character: \"" ^ yytext ^ "\"");
|
adamc@1
|
391 continue ());
|