annotate src/urweb.lex @ 835:b0a85cbefed2

Less whining about match failures; fix singleton record Jscomp bug
author Adam Chlipala <adamc@hcoop.net>
date Tue, 02 Jun 2009 12:40:09 -0400
parents 395a5d450cc0
children 5154a047c6bc
rev   line source
adamc@763 1 (* -*- mode: sml-lex -*- *)
adamc@763 2
adamc@763 3 (* Copyright (c) 2008-2009, Adam Chlipala
adamc@1 4 * All rights reserved.
adamc@1 5 *
adamc@1 6 * Redistribution and use in source and binary forms, with or without
adamc@1 7 * modification, are permitted provided that the following conditions are met:
adamc@1 8 *
adamc@1 9 * - Redistributions of source code must retain the above copyright notice,
adamc@1 10 * this list of conditions and the following disclaimer.
adamc@1 11 * - Redistributions in binary form must reproduce the above copyright notice,
adamc@1 12 * this list of conditions and the following disclaimer in the documentation
adamc@1 13 * and/or other materials provided with the distribution.
adamc@1 14 * - The names of contributors may not be used to endorse or promote products
adamc@1 15 * derived from this software without specific prior written permission.
adamc@1 16 *
adamc@1 17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
adamc@1 18 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
adamc@1 19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
adamc@1 20 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
adamc@1 21 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
adamc@1 22 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
adamc@1 23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
adamc@1 24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
adamc@1 25 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
adamc@1 26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
adamc@1 27 * POSSIBILITY OF SUCH DAMAGE.
adamc@1 28 *)
adamc@1 29
adamc@244 30 (* Lexing info for Ur/Web programs *)
adamc@1 31
adamc@1 32 type pos = int
adamc@1 33 type svalue = Tokens.svalue
adamc@1 34 type ('a,'b) token = ('a,'b) Tokens.token
adamc@1 35 type lexresult = (svalue,pos) Tokens.token
adamc@1 36
adamc@1 37 local
adamc@1 38 val commentLevel = ref 0
adamc@1 39 val commentPos = ref 0
adamc@1 40 in
adamc@1 41 fun enterComment pos =
adamc@1 42 (if !commentLevel = 0 then
adamc@1 43 commentPos := pos
adamc@1 44 else
adamc@1 45 ();
adamc@1 46 commentLevel := !commentLevel + 1)
adamc@1 47
adamc@1 48 fun exitComment () =
adamc@1 49 (ignore (commentLevel := !commentLevel - 1);
adamc@1 50 !commentLevel = 0)
adamc@1 51
adamc@1 52 fun eof () =
adamc@1 53 let
adamc@1 54 val pos = ErrorMsg.lastLineStart ()
adamc@1 55 in
adamc@1 56 if !commentLevel > 0 then
adamc@1 57 ErrorMsg.errorAt' (!commentPos, !commentPos) "Unterminated comment"
adamc@1 58 else
adamc@1 59 ();
adamc@1 60 Tokens.EOF (pos, pos)
adamc@1 61 end
adamc@1 62 end
adamc@1 63
adamc@229 64 val strEnder = ref #"\""
adamc@14 65 val str = ref ([] : char list)
adamc@14 66 val strStart = ref 0
adamc@14 67
adamc@54 68 local
adamc@54 69 val initSig = ref false
adamc@54 70 val offset = ref 0
adamc@54 71 in
adamc@54 72
adamc@54 73 fun initialSig () = initSig := true
adamc@54 74
adamc@54 75 fun pos yypos = yypos - !offset
adamc@54 76
adamc@54 77 fun newline yypos =
adamc@54 78 if !initSig then
adamc@54 79 (initSig := false;
adamc@54 80 offset := yypos + 1)
adamc@54 81 else
adamc@54 82 ErrorMsg.newline (pos yypos)
adamc@54 83
adamc@54 84 end
adamc@54 85
adamc@91 86 val xmlTag = ref ([] : string list)
adamc@91 87 val xmlString = ref true
adamc@91 88 val braceLevels = ref ([] : ((unit -> unit) * int) list)
adamc@91 89
adamc@91 90 fun pushLevel s = braceLevels := (s, 1) :: (!braceLevels)
adamc@91 91
adamc@91 92 fun enterBrace () =
adamc@91 93 case !braceLevels of
adamc@91 94 (s, i) :: rest => braceLevels := (s, i+1) :: rest
adamc@91 95 | _ => ()
adamc@91 96
adamc@91 97 fun exitBrace () =
adamc@91 98 case !braceLevels of
adamc@91 99 (s, i) :: rest =>
adamc@91 100 if i = 1 then
adamc@91 101 (braceLevels := rest;
adamc@91 102 s ())
adamc@91 103 else
adamc@91 104 braceLevels := (s, i-1) :: rest
adamc@91 105 | _ => ()
adamc@91 106
adamc@91 107 fun initialize () = (xmlTag := [];
adamc@91 108 xmlString := false)
adamc@91 109
adamc@54 110
adamc@763 111 fun unescape loc s =
adamc@763 112 let
adamc@763 113 fun process (s, acc) =
adamc@763 114 let
adamc@763 115 val (befor, after) = Substring.splitl (fn ch => ch <> #"&") s
adamc@763 116 in
adamc@763 117 if Substring.size after = 0 then
adamc@763 118 Substring.concat (rev (s :: acc))
adamc@763 119 else
adamc@763 120 let
adamc@763 121 val after = Substring.slice (after, 1, NONE)
adamc@763 122 val (befor', after') = Substring.splitl (fn ch => ch <> #";") after
adamc@763 123 in
adamc@763 124 if Substring.size after' = 0 then
adamc@763 125 (ErrorMsg.errorAt' loc "Missing ';' after '&'";
adamc@763 126 "")
adamc@763 127 else
adamc@763 128 let
adamc@763 129 val pre = befor
adamc@763 130 val code = befor'
adamc@763 131 val s = Substring.slice (after', 1, NONE)
adamc@763 132
adamc@763 133 val special =
adamc@763 134 if Substring.size code > 0 andalso Substring.sub (code, 0) = #"#"
adamc@763 135 andalso CharVectorSlice.all Char.isDigit (Substring.slice (code, 1, NONE)) then
adamc@763 136 let
adamc@763 137 val code = Substring.string (Substring.slice (code, 1, NONE))
adamc@763 138 in
adamc@763 139 Option.map chr (Int.fromString code)
adamc@763 140 end
adamc@763 141 else case Substring.string code of
adamc@763 142 "amp" => SOME #"&"
adamc@763 143 | "lt" => SOME #"<"
adamc@763 144 | "gt" => SOME #">"
adamc@763 145 | "quot" => SOME #"\""
adamc@763 146 | _ => NONE
adamc@763 147 in
adamc@763 148 case special of
adamc@763 149 NONE => (ErrorMsg.errorAt' loc ("Unsupported XML character entity "
adamc@763 150 ^ Substring.string code);
adamc@763 151 "")
adamc@763 152 | SOME ch => process (s, Substring.full (String.str ch) :: pre :: acc)
adamc@763 153 end
adamc@763 154 end
adamc@763 155 end
adamc@763 156 in
adamc@763 157 process (Substring.full s, [])
adamc@763 158 end
adamc@763 159
adamc@1 160 %%
adamc@244 161 %header (functor UrwebLexFn(structure Tokens : Urweb_TOKENS));
adamc@1 162 %full
adamc@821 163 %s COMMENT STRING CHAR XML XMLTAG;
adamc@1 164
adamc@48 165 id = [a-z_][A-Za-z0-9_']*;
adamc@316 166 cid = [A-Z][A-Za-z0-9_]*;
adamc@1 167 ws = [\ \t\012];
adamc@14 168 intconst = [0-9]+;
adamc@14 169 realconst = [0-9]+\.[0-9]*;
adamc@91 170 notags = [^<{\n]+;
adamc@1 171
adamc@1 172 %%
adamc@1 173
adamc@54 174 <INITIAL> \n => (newline yypos;
adamc@1 175 continue ());
adamc@54 176 <COMMENT> \n => (newline yypos;
adamc@1 177 continue ());
adamc@91 178 <XMLTAG> \n => (newline yypos;
adamc@91 179 continue ());
adamc@91 180 <XML> \n => (newline yypos;
adamc@91 181 Tokens.NOTAGS (yytext, yypos, yypos + size yytext));
adamc@1 182
adamc@1 183 <INITIAL> {ws}+ => (lex ());
adamc@1 184
adamc@1 185 <INITIAL> "(*" => (YYBEGIN COMMENT;
adamc@54 186 enterComment (pos yypos);
adamc@1 187 continue ());
adamc@54 188 <INITIAL> "*)" => (ErrorMsg.errorAt' (pos yypos, pos yypos) "Unbalanced comments";
adamc@1 189 continue ());
adamc@1 190
adamc@54 191 <COMMENT> "(*" => (enterComment (pos yypos);
adamc@1 192 continue ());
adamc@1 193 <COMMENT> "*)" => (if exitComment () then YYBEGIN INITIAL else ();
adamc@1 194 continue ());
adamc@1 195
adamc@821 196 <INITIAL> "#\"" => (YYBEGIN CHAR; strEnder := #"\""; strStart := pos yypos; str := []; continue());
adamc@821 197 <CHAR> "\\\"" => (str := #"\"" :: !str; continue());
adamc@821 198 <CHAR> "\\'" => (str := #"'" :: !str; continue());
adamc@821 199 <CHAR> "\n" => (newline yypos;
adamc@821 200 str := #"\n" :: !str; continue());
adamc@821 201 <CHAR> . => (let
adamc@821 202 val ch = String.sub (yytext, 0)
adamc@821 203 in
adamc@821 204 if ch = !strEnder then
adamc@821 205 let
adamc@821 206 val s = String.implode (List.rev (!str))
adamc@821 207 in
adamc@821 208 YYBEGIN INITIAL;
adamc@821 209 if size s = 1 then
adamc@821 210 Tokens.CHAR (String.sub (s, 0), !strStart, pos yypos + 1)
adamc@821 211 else
adamc@821 212 (ErrorMsg.errorAt' (yypos, yypos)
adamc@821 213 "Character constant is zero or multiple characters";
adamc@821 214 continue ())
adamc@821 215 end
adamc@821 216 else
adamc@821 217 (str := ch :: !str;
adamc@821 218 continue ())
adamc@821 219 end);
adamc@821 220
adamc@229 221 <INITIAL> "\"" => (YYBEGIN STRING; strEnder := #"\""; strStart := pos yypos; str := []; continue());
adamc@229 222 <INITIAL> "'" => (YYBEGIN STRING; strEnder := #"'"; strStart := pos yypos; str := []; continue());
adamc@14 223 <STRING> "\\\"" => (str := #"\"" :: !str; continue());
adamc@229 224 <STRING> "\\'" => (str := #"'" :: !str; continue());
adamc@54 225 <STRING> "\n" => (newline yypos;
adamc@14 226 str := #"\n" :: !str; continue());
adamc@229 227 <STRING> . => (let
adamc@229 228 val ch = String.sub (yytext, 0)
adamc@229 229 in
adamc@229 230 if ch = !strEnder then
adamc@229 231 (if !xmlString then
adamc@229 232 (xmlString := false; YYBEGIN XMLTAG)
adamc@229 233 else
adamc@229 234 YYBEGIN INITIAL;
adamc@229 235 Tokens.STRING (String.implode (List.rev (!str)), !strStart, pos yypos + 1))
adamc@229 236 else
adamc@229 237 (str := ch :: !str;
adamc@229 238 continue ())
adamc@229 239 end);
adamc@14 240
adamc@360 241 <INITIAL> "<" {id} "/>"=>(let
adamc@360 242 val tag = String.substring (yytext, 1, size yytext - 3)
adamc@360 243 in
adamc@360 244 Tokens.XML_BEGIN_END (tag, yypos, yypos + size yytext)
adamc@360 245 end);
adamc@91 246 <INITIAL> "<" {id} ">"=> (let
adamc@91 247 val tag = String.substring (yytext, 1, size yytext - 2)
adamc@91 248 in
adamc@91 249 YYBEGIN XML;
adamc@91 250 xmlTag := tag :: (!xmlTag);
adamc@91 251 Tokens.XML_BEGIN (tag, yypos, yypos + size yytext)
adamc@91 252 end);
adamc@91 253 <XML> "</" {id} ">" => (let
adamc@91 254 val id = String.substring (yytext, 2, size yytext - 3)
adamc@91 255 in
adamc@91 256 case !xmlTag of
adamc@91 257 id' :: rest =>
adamc@91 258 if id = id' then
adamc@91 259 (YYBEGIN INITIAL;
adamc@91 260 xmlTag := rest;
adamc@91 261 Tokens.XML_END (yypos, yypos + size yytext))
adamc@91 262 else
adamc@91 263 Tokens.END_TAG (id, yypos, yypos + size yytext)
adamc@91 264 | _ =>
adamc@91 265 Tokens.END_TAG (id, yypos, yypos + size yytext)
adamc@91 266 end);
adamc@91 267
adamc@91 268 <XML> "<" {id} => (YYBEGIN XMLTAG;
adamc@91 269 Tokens.BEGIN_TAG (String.extract (yytext, 1, NONE),
adamc@91 270 yypos, yypos + size yytext));
adamc@91 271
adamc@91 272 <XMLTAG> "/" => (Tokens.DIVIDE (yypos, yypos + size yytext));
adamc@91 273 <XMLTAG> ">" => (YYBEGIN XML;
adamc@91 274 Tokens.GT (yypos, yypos + size yytext));
adamc@91 275
adamc@91 276 <XMLTAG> {ws}+ => (lex ());
adamc@91 277
adamc@91 278 <XMLTAG> {id} => (Tokens.SYMBOL (yytext, yypos, yypos + size yytext));
adamc@91 279 <XMLTAG> "=" => (Tokens.EQ (yypos, yypos + size yytext));
adamc@91 280
adamc@91 281 <XMLTAG> {intconst} => (case Int64.fromString yytext of
adamc@91 282 SOME x => Tokens.INT (x, yypos, yypos + size yytext)
adamc@91 283 | NONE => (ErrorMsg.errorAt' (yypos, yypos)
adamc@91 284 ("Expected int, received: " ^ yytext);
adamc@91 285 continue ()));
adamc@91 286 <XMLTAG> {realconst} => (case Real.fromString yytext of
adamc@91 287 SOME x => Tokens.FLOAT (x, yypos, yypos + size yytext)
adamc@91 288 | NONE => (ErrorMsg.errorAt' (yypos, yypos)
adamc@91 289 ("Expected float, received: " ^ yytext);
adamc@91 290 continue ()));
adamc@91 291 <XMLTAG> "\"" => (YYBEGIN STRING;
adamc@91 292 xmlString := true;
adamc@104 293 strStart := yypos; str := []; continue ());
adamc@91 294
adamc@91 295 <XMLTAG> "{" => (YYBEGIN INITIAL;
adamc@91 296 pushLevel (fn () => YYBEGIN XMLTAG);
adamc@91 297 Tokens.LBRACE (yypos, yypos + 1));
adamc@91 298 <XMLTAG> "(" => (YYBEGIN INITIAL;
adamc@91 299 pushLevel (fn () => YYBEGIN XMLTAG);
adamc@91 300 Tokens.LPAREN (yypos, yypos + 1));
adamc@91 301
adamc@91 302 <XMLTAG> . => (ErrorMsg.errorAt' (yypos, yypos)
adamc@91 303 ("illegal XML tag character: \"" ^ yytext ^ "\"");
adamc@91 304 continue ());
adamc@91 305
adamc@91 306 <XML> "{" => (YYBEGIN INITIAL;
adamc@91 307 pushLevel (fn () => YYBEGIN XML);
adamc@91 308 Tokens.LBRACE (yypos, yypos + 1));
adamc@91 309
adamc@763 310 <XML> {notags} => (Tokens.NOTAGS (unescape (yypos, yypos + size yytext) yytext, yypos, yypos + size yytext));
adamc@91 311
adamc@91 312 <XML> . => (ErrorMsg.errorAt' (yypos, yypos)
adamc@91 313 ("illegal XML character: \"" ^ yytext ^ "\"");
adamc@91 314 continue ());
adamc@91 315
adamc@82 316 <INITIAL> "()" => (Tokens.UNIT (pos yypos, pos yypos + size yytext));
adamc@54 317 <INITIAL> "(" => (Tokens.LPAREN (pos yypos, pos yypos + size yytext));
adamc@54 318 <INITIAL> ")" => (Tokens.RPAREN (pos yypos, pos yypos + size yytext));
adamc@54 319 <INITIAL> "[" => (Tokens.LBRACK (pos yypos, pos yypos + size yytext));
adamc@54 320 <INITIAL> "]" => (Tokens.RBRACK (pos yypos, pos yypos + size yytext));
adamc@110 321 <INITIAL> "{" => (enterBrace ();
adamc@110 322 Tokens.LBRACE (pos yypos, pos yypos + size yytext));
adamc@110 323 <INITIAL> "}" => (exitBrace ();
adamc@110 324 Tokens.RBRACE (pos yypos, pos yypos + size yytext));
adamc@1 325
adamc@623 326 <INITIAL> "-->" => (Tokens.KARROW (pos yypos, pos yypos + size yytext));
adamc@54 327 <INITIAL> "->" => (Tokens.ARROW (pos yypos, pos yypos + size yytext));
adamc@623 328 <INITIAL> "==>" => (Tokens.DKARROW (pos yypos, pos yypos + size yytext));
adamc@54 329 <INITIAL> "=>" => (Tokens.DARROW (pos yypos, pos yypos + size yytext));
adamc@54 330 <INITIAL> "++" => (Tokens.PLUSPLUS (pos yypos, pos yypos + size yytext));
adamc@149 331 <INITIAL> "--" => (Tokens.MINUSMINUS (pos yypos, pos yypos + size yytext));
adamc@493 332 <INITIAL> "---" => (Tokens.MINUSMINUSMINUS (pos yypos, pos yypos + size yytext));
adamc@674 333 <INITIAL> "^" => (Tokens.CARET (pos yypos, pos yypos + size yytext));
adamc@1 334
adamc@54 335 <INITIAL> "=" => (Tokens.EQ (pos yypos, pos yypos + size yytext));
adamc@219 336 <INITIAL> "<>" => (Tokens.NE (pos yypos, pos yypos + size yytext));
adamc@219 337 <INITIAL> "<" => (Tokens.LT (pos yypos, pos yypos + size yytext));
adamc@219 338 <INITIAL> ">" => (Tokens.GT (pos yypos, pos yypos + size yytext));
adamc@219 339 <INITIAL> "<=" => (Tokens.LE (pos yypos, pos yypos + size yytext));
adamc@219 340 <INITIAL> ">=" => (Tokens.GE (pos yypos, pos yypos + size yytext));
adamc@54 341 <INITIAL> "," => (Tokens.COMMA (pos yypos, pos yypos + size yytext));
adamc@54 342 <INITIAL> ":::" => (Tokens.TCOLON (pos yypos, pos yypos + size yytext));
adamc@54 343 <INITIAL> "::" => (Tokens.DCOLON (pos yypos, pos yypos + size yytext));
adamc@54 344 <INITIAL> ":" => (Tokens.COLON (pos yypos, pos yypos + size yytext));
adamc@174 345 <INITIAL> "..." => (Tokens.DOTDOTDOT (pos yypos, pos yypos + size yytext));
adamc@54 346 <INITIAL> "." => (Tokens.DOT (pos yypos, pos yypos + size yytext));
adamc@54 347 <INITIAL> "$" => (Tokens.DOLLAR (pos yypos, pos yypos + size yytext));
adamc@54 348 <INITIAL> "#" => (Tokens.HASH (pos yypos, pos yypos + size yytext));
adamc@54 349 <INITIAL> "__" => (Tokens.UNDERUNDER (pos yypos, pos yypos + size yytext));
adamc@54 350 <INITIAL> "_" => (Tokens.UNDER (pos yypos, pos yypos + size yytext));
adamc@84 351 <INITIAL> "~" => (Tokens.TWIDDLE (pos yypos, pos yypos + size yytext));
adamc@156 352 <INITIAL> "|" => (Tokens.BAR (pos yypos, pos yypos + size yytext));
adamc@195 353 <INITIAL> "*" => (Tokens.STAR (pos yypos, pos yypos + size yytext));
adamc@243 354 <INITIAL> "<-" => (Tokens.LARROW (pos yypos, pos yypos + size yytext));
adamc@243 355 <INITIAL> ";" => (Tokens.SEMI (pos yypos, pos yypos + size yytext));
adamc@629 356 <INITIAL> "!" => (Tokens.BANG (pos yypos, pos yypos + size yytext));
adamc@1 357
adamc@389 358 <INITIAL> "+" => (Tokens.PLUS (pos yypos, pos yypos + size yytext));
adamc@389 359 <INITIAL> "-" => (Tokens.MINUS (pos yypos, pos yypos + size yytext));
adamc@389 360 <INITIAL> "/" => (Tokens.DIVIDE (yypos, yypos + size yytext));
adamc@389 361 <INITIAL> "%" => (Tokens.MOD (pos yypos, pos yypos + size yytext));
adamc@403 362 <INITIAL> "@" => (Tokens.AT (pos yypos, pos yypos + size yytext));
adamc@389 363
adamc@54 364 <INITIAL> "con" => (Tokens.CON (pos yypos, pos yypos + size yytext));
adamc@54 365 <INITIAL> "type" => (Tokens.LTYPE (pos yypos, pos yypos + size yytext));
adamc@156 366 <INITIAL> "datatype" => (Tokens.DATATYPE (pos yypos, pos yypos + size yytext));
adamc@156 367 <INITIAL> "of" => (Tokens.OF (pos yypos, pos yypos + size yytext));
adamc@54 368 <INITIAL> "val" => (Tokens.VAL (pos yypos, pos yypos + size yytext));
adamc@123 369 <INITIAL> "rec" => (Tokens.REC (pos yypos, pos yypos + size yytext));
adamc@123 370 <INITIAL> "and" => (Tokens.AND (pos yypos, pos yypos + size yytext));
adamc@242 371 <INITIAL> "fun" => (Tokens.FUN (pos yypos, pos yypos + size yytext));
adamc@54 372 <INITIAL> "fn" => (Tokens.FN (pos yypos, pos yypos + size yytext));
adamc@621 373 <INITIAL> "map" => (Tokens.MAP (pos yypos, pos yypos + size yytext));
adamc@170 374 <INITIAL> "case" => (Tokens.CASE (pos yypos, pos yypos + size yytext));
adamc@190 375 <INITIAL> "if" => (Tokens.IF (pos yypos, pos yypos + size yytext));
adamc@190 376 <INITIAL> "then" => (Tokens.THEN (pos yypos, pos yypos + size yytext));
adamc@190 377 <INITIAL> "else" => (Tokens.ELSE (pos yypos, pos yypos + size yytext));
adamc@1 378
adamc@54 379 <INITIAL> "structure" => (Tokens.STRUCTURE (pos yypos, pos yypos + size yytext));
adamc@54 380 <INITIAL> "signature" => (Tokens.SIGNATURE (pos yypos, pos yypos + size yytext));
adamc@54 381 <INITIAL> "struct" => (Tokens.STRUCT (pos yypos, pos yypos + size yytext));
adamc@54 382 <INITIAL> "sig" => (if yypos = 2 then initialSig () else (); Tokens.SIG (pos yypos, pos yypos + size yytext));
adamc@446 383 <INITIAL> "let" => (Tokens.LET (pos yypos, pos yypos + size yytext));
adamc@446 384 <INITIAL> "in" => (Tokens.IN (pos yypos, pos yypos + size yytext));
adamc@54 385 <INITIAL> "end" => (Tokens.END (pos yypos, pos yypos + size yytext));
adamc@54 386 <INITIAL> "functor" => (Tokens.FUNCTOR (pos yypos, pos yypos + size yytext));
adamc@54 387 <INITIAL> "where" => (Tokens.WHERE (pos yypos, pos yypos + size yytext));
adamc@54 388 <INITIAL> "extern" => (Tokens.EXTERN (pos yypos, pos yypos + size yytext));
adamc@58 389 <INITIAL> "include" => (Tokens.INCLUDE (pos yypos, pos yypos + size yytext));
adamc@58 390 <INITIAL> "open" => (Tokens.OPEN (pos yypos, pos yypos + size yytext));
adamc@88 391 <INITIAL> "constraint"=> (Tokens.CONSTRAINT (pos yypos, pos yypos + size yytext));
adamc@88 392 <INITIAL> "constraints"=> (Tokens.CONSTRAINTS (pos yypos, pos yypos + size yytext));
adamc@109 393 <INITIAL> "export" => (Tokens.EXPORT (pos yypos, pos yypos + size yytext));
adamc@203 394 <INITIAL> "table" => (Tokens.TABLE (pos yypos, pos yypos + size yytext));
adamc@338 395 <INITIAL> "sequence" => (Tokens.SEQUENCE (pos yypos, pos yypos + size yytext));
adamc@754 396 <INITIAL> "view" => (Tokens.VIEW (pos yypos, pos yypos + size yytext));
adamc@211 397 <INITIAL> "class" => (Tokens.CLASS (pos yypos, pos yypos + size yytext));
adamc@459 398 <INITIAL> "cookie" => (Tokens.COOKIE (pos yypos, pos yypos + size yytext));
adamc@718 399 <INITIAL> "style" => (Tokens.STYLE (pos yypos, pos yypos + size yytext));
adamc@30 400
adamc@54 401 <INITIAL> "Type" => (Tokens.TYPE (pos yypos, pos yypos + size yytext));
adamc@54 402 <INITIAL> "Name" => (Tokens.NAME (pos yypos, pos yypos + size yytext));
adamc@82 403 <INITIAL> "Unit" => (Tokens.KUNIT (pos yypos, pos yypos + size yytext));
adamc@1 404
adamc@204 405 <INITIAL> "SELECT" => (Tokens.SELECT (pos yypos, pos yypos + size yytext));
adamc@204 406 <INITIAL> "FROM" => (Tokens.FROM (pos yypos, pos yypos + size yytext));
adamc@204 407 <INITIAL> "AS" => (Tokens.AS (pos yypos, pos yypos + size yytext));
adamc@209 408 <INITIAL> "WHERE" => (Tokens.CWHERE (pos yypos, pos yypos + size yytext));
adamc@339 409 <INITIAL> "SQL" => (Tokens.SQL (pos yypos, pos yypos + size yytext));
adamc@226 410 <INITIAL> "GROUP" => (Tokens.GROUP (pos yypos, pos yypos + size yytext));
adamc@230 411 <INITIAL> "ORDER" => (Tokens.ORDER (pos yypos, pos yypos + size yytext));
adamc@226 412 <INITIAL> "BY" => (Tokens.BY (pos yypos, pos yypos + size yytext));
adamc@227 413 <INITIAL> "HAVING" => (Tokens.HAVING (pos yypos, pos yypos + size yytext));
adamc@231 414 <INITIAL> "LIMIT" => (Tokens.LIMIT (pos yypos, pos yypos + size yytext));
adamc@231 415 <INITIAL> "OFFSET" => (Tokens.OFFSET (pos yypos, pos yypos + size yytext));
adamc@232 416 <INITIAL> "ALL" => (Tokens.ALL (pos yypos, pos yypos + size yytext));
adamc@209 417
adamc@749 418 <INITIAL> "JOIN" => (Tokens.JOIN (pos yypos, pos yypos + size yytext));
adamc@749 419 <INITIAL> "INNER" => (Tokens.INNER (pos yypos, pos yypos + size yytext));
adamc@749 420 <INITIAL> "CROSS" => (Tokens.CROSS (pos yypos, pos yypos + size yytext));
adamc@751 421 <INITIAL> "OUTER" => (Tokens.OUTER (pos yypos, pos yypos + size yytext));
adamc@750 422 <INITIAL> "LEFT" => (Tokens.LEFT (pos yypos, pos yypos + size yytext));
adamc@751 423 <INITIAL> "RIGHT" => (Tokens.RIGHT (pos yypos, pos yypos + size yytext));
adamc@751 424 <INITIAL> "FULL" => (Tokens.FULL (pos yypos, pos yypos + size yytext));
adamc@749 425
adamc@229 426 <INITIAL> "UNION" => (Tokens.UNION (pos yypos, pos yypos + size yytext));
adamc@229 427 <INITIAL> "INTERSECT" => (Tokens.INTERSECT (pos yypos, pos yypos + size yytext));
adamc@229 428 <INITIAL> "EXCEPT" => (Tokens.EXCEPT (pos yypos, pos yypos + size yytext));
adamc@229 429
adamc@209 430 <INITIAL> "TRUE" => (Tokens.TRUE (pos yypos, pos yypos + size yytext));
adamc@209 431 <INITIAL> "FALSE" => (Tokens.FALSE (pos yypos, pos yypos + size yytext));
adamc@220 432 <INITIAL> "AND" => (Tokens.CAND (pos yypos, pos yypos + size yytext));
adamc@220 433 <INITIAL> "OR" => (Tokens.OR (pos yypos, pos yypos + size yytext));
adamc@220 434 <INITIAL> "NOT" => (Tokens.NOT (pos yypos, pos yypos + size yytext));
adamc@204 435
adamc@235 436 <INITIAL> "COUNT" => (Tokens.COUNT (pos yypos, pos yypos + size yytext));
adamc@236 437 <INITIAL> "AVG" => (Tokens.AVG (pos yypos, pos yypos + size yytext));
adamc@236 438 <INITIAL> "SUM" => (Tokens.SUM (pos yypos, pos yypos + size yytext));
adamc@236 439 <INITIAL> "MIN" => (Tokens.MIN (pos yypos, pos yypos + size yytext));
adamc@236 440 <INITIAL> "MAX" => (Tokens.MAX (pos yypos, pos yypos + size yytext));
adamc@235 441
adamc@268 442 <INITIAL> "ASC" => (Tokens.ASC (pos yypos, pos yypos + size yytext));
adamc@268 443 <INITIAL> "DESC" => (Tokens.DESC (pos yypos, pos yypos + size yytext));
adamc@268 444
adamc@302 445 <INITIAL> "INSERT" => (Tokens.INSERT (pos yypos, pos yypos + size yytext));
adamc@302 446 <INITIAL> "INTO" => (Tokens.INTO (pos yypos, pos yypos + size yytext));
adamc@302 447 <INITIAL> "VALUES" => (Tokens.VALUES (pos yypos, pos yypos + size yytext));
adamc@302 448 <INITIAL> "UPDATE" => (Tokens.UPDATE (pos yypos, pos yypos + size yytext));
adamc@302 449 <INITIAL> "SET" => (Tokens.SET (pos yypos, pos yypos + size yytext));
adamc@302 450 <INITIAL> "DELETE" => (Tokens.DELETE (pos yypos, pos yypos + size yytext));
adamc@467 451 <INITIAL> "NULL" => (Tokens.NULL (pos yypos, pos yypos + size yytext));
adamc@470 452 <INITIAL> "IS" => (Tokens.IS (pos yypos, pos yypos + size yytext));
adamc@302 453
adamc@704 454 <INITIAL> "CONSTRAINT"=> (Tokens.CCONSTRAINT (pos yypos, pos yypos + size yytext));
adamc@704 455 <INITIAL> "UNIQUE" => (Tokens.UNIQUE (pos yypos, pos yypos + size yytext));
adamc@714 456 <INITIAL> "CHECK" => (Tokens.CHECK (pos yypos, pos yypos + size yytext));
adamc@707 457 <INITIAL> "PRIMARY" => (Tokens.PRIMARY (pos yypos, pos yypos + size yytext));
adamc@709 458 <INITIAL> "FOREIGN" => (Tokens.FOREIGN (pos yypos, pos yypos + size yytext));
adamc@707 459 <INITIAL> "KEY" => (Tokens.KEY (pos yypos, pos yypos + size yytext));
adamc@709 460 <INITIAL> "ON" => (Tokens.ON (pos yypos, pos yypos + size yytext));
adamc@709 461 <INITIAL> "NO" => (Tokens.NO (pos yypos, pos yypos + size yytext));
adamc@709 462 <INITIAL> "ACTION" => (Tokens.ACTION (pos yypos, pos yypos + size yytext));
adamc@709 463 <INITIAL> "RESTRICT" => (Tokens.RESTRICT (pos yypos, pos yypos + size yytext));
adamc@709 464 <INITIAL> "CASCADE" => (Tokens.CASCADE (pos yypos, pos yypos + size yytext));
adamc@709 465 <INITIAL> "REFERENCES"=> (Tokens.REFERENCES (pos yypos, pos yypos + size yytext));
adamc@709 466
adamc@709 467 <INITIAL> "CURRENT_TIMESTAMP" => (Tokens.CURRENT_TIMESTAMP (pos yypos, pos yypos + size yytext));
adamc@704 468
adamc@441 469 <INITIAL> "CURRENT_TIMESTAMP" => (Tokens.CURRENT_TIMESTAMP (pos yypos, pos yypos + size yytext));
adamc@441 470
adamc@54 471 <INITIAL> {id} => (Tokens.SYMBOL (yytext, pos yypos, pos yypos + size yytext));
adamc@54 472 <INITIAL> {cid} => (Tokens.CSYMBOL (yytext, pos yypos, pos yypos + size yytext));
adamc@1 473
adamc@14 474 <INITIAL> {intconst} => (case Int64.fromString yytext of
adamc@120 475 SOME x => Tokens.INT (x, pos yypos, pos yypos + size yytext)
adamc@120 476 | NONE => (ErrorMsg.errorAt' (pos yypos, pos yypos)
adamc@120 477 ("Expected int, received: " ^ yytext);
adamc@120 478 continue ()));
adamc@14 479 <INITIAL> {realconst} => (case Real64.fromString yytext of
adamc@54 480 SOME x => Tokens.FLOAT (x, pos yypos, pos yypos + size yytext)
adamc@54 481 | NONE => (ErrorMsg.errorAt' (pos yypos, pos yypos)
adamc@14 482 ("Expected float, received: " ^ yytext);
adamc@14 483 continue ()));
adamc@14 484
adamc@1 485 <COMMENT> . => (continue());
adamc@1 486
adamc@54 487 <INITIAL> . => (ErrorMsg.errorAt' (pos yypos, pos yypos)
adamc@1 488 ("illegal character: \"" ^ yytext ^ "\"");
adamc@1 489 continue ());