annotate src/urweb.lex @ 1010:6b0f3853cc81

authorship table
author Adam Chlipala <adamc@hcoop.net>
date Thu, 22 Oct 2009 14:05:48 -0400
parents 10114d7b7477
children 757397bb9609
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@838 196 <STRING,CHAR> "\\\"" => (str := #"\"" :: !str; continue());
adamc@838 197 <STRING,CHAR> "\\'" => (str := #"'" :: !str; continue());
adamc@838 198 <STRING,CHAR> "\\n" => (str := #"\n" :: !str; continue());
adamc@838 199 <STRING,CHAR> "\\t" => (str := #"\t" :: !str; continue());
adamc@838 200 <STRING,CHAR> "\n" => (newline yypos;
adamc@838 201 str := #"\n" :: !str; continue());
adamc@838 202
adamc@821 203 <INITIAL> "#\"" => (YYBEGIN CHAR; strEnder := #"\""; strStart := pos yypos; str := []; continue());
adamc@838 204
adamc@821 205 <CHAR> . => (let
adamc@821 206 val ch = String.sub (yytext, 0)
adamc@821 207 in
adamc@821 208 if ch = !strEnder then
adamc@821 209 let
adamc@821 210 val s = String.implode (List.rev (!str))
adamc@821 211 in
adamc@821 212 YYBEGIN INITIAL;
adamc@821 213 if size s = 1 then
adamc@821 214 Tokens.CHAR (String.sub (s, 0), !strStart, pos yypos + 1)
adamc@821 215 else
adamc@821 216 (ErrorMsg.errorAt' (yypos, yypos)
adamc@821 217 "Character constant is zero or multiple characters";
adamc@821 218 continue ())
adamc@821 219 end
adamc@821 220 else
adamc@821 221 (str := ch :: !str;
adamc@821 222 continue ())
adamc@821 223 end);
adamc@821 224
adamc@229 225 <INITIAL> "\"" => (YYBEGIN STRING; strEnder := #"\""; strStart := pos yypos; str := []; continue());
adamc@229 226 <INITIAL> "'" => (YYBEGIN STRING; strEnder := #"'"; strStart := pos yypos; str := []; continue());
adamc@838 227
adamc@229 228 <STRING> . => (let
adamc@229 229 val ch = String.sub (yytext, 0)
adamc@229 230 in
adamc@229 231 if ch = !strEnder then
adamc@229 232 (if !xmlString then
adamc@229 233 (xmlString := false; YYBEGIN XMLTAG)
adamc@229 234 else
adamc@229 235 YYBEGIN INITIAL;
adamc@229 236 Tokens.STRING (String.implode (List.rev (!str)), !strStart, pos yypos + 1))
adamc@229 237 else
adamc@229 238 (str := ch :: !str;
adamc@229 239 continue ())
adamc@229 240 end);
adamc@14 241
adamc@360 242 <INITIAL> "<" {id} "/>"=>(let
adamc@360 243 val tag = String.substring (yytext, 1, size yytext - 3)
adamc@360 244 in
adamc@360 245 Tokens.XML_BEGIN_END (tag, yypos, yypos + size yytext)
adamc@360 246 end);
adamc@91 247 <INITIAL> "<" {id} ">"=> (let
adamc@91 248 val tag = String.substring (yytext, 1, size yytext - 2)
adamc@91 249 in
adamc@91 250 YYBEGIN XML;
adamc@91 251 xmlTag := tag :: (!xmlTag);
adamc@91 252 Tokens.XML_BEGIN (tag, yypos, yypos + size yytext)
adamc@91 253 end);
adamc@91 254 <XML> "</" {id} ">" => (let
adamc@91 255 val id = String.substring (yytext, 2, size yytext - 3)
adamc@91 256 in
adamc@91 257 case !xmlTag of
adamc@91 258 id' :: rest =>
adamc@91 259 if id = id' then
adamc@91 260 (YYBEGIN INITIAL;
adamc@91 261 xmlTag := rest;
adamc@91 262 Tokens.XML_END (yypos, yypos + size yytext))
adamc@91 263 else
adamc@91 264 Tokens.END_TAG (id, yypos, yypos + size yytext)
adamc@91 265 | _ =>
adamc@91 266 Tokens.END_TAG (id, yypos, yypos + size yytext)
adamc@91 267 end);
adamc@91 268
adamc@91 269 <XML> "<" {id} => (YYBEGIN XMLTAG;
adamc@91 270 Tokens.BEGIN_TAG (String.extract (yytext, 1, NONE),
adamc@91 271 yypos, yypos + size yytext));
adamc@91 272
adamc@91 273 <XMLTAG> "/" => (Tokens.DIVIDE (yypos, yypos + size yytext));
adamc@91 274 <XMLTAG> ">" => (YYBEGIN XML;
adamc@91 275 Tokens.GT (yypos, yypos + size yytext));
adamc@91 276
adamc@91 277 <XMLTAG> {ws}+ => (lex ());
adamc@91 278
adamc@91 279 <XMLTAG> {id} => (Tokens.SYMBOL (yytext, yypos, yypos + size yytext));
adamc@91 280 <XMLTAG> "=" => (Tokens.EQ (yypos, yypos + size yytext));
adamc@91 281
adamc@91 282 <XMLTAG> {intconst} => (case Int64.fromString yytext of
adamc@91 283 SOME x => Tokens.INT (x, yypos, yypos + size yytext)
adamc@91 284 | NONE => (ErrorMsg.errorAt' (yypos, yypos)
adamc@91 285 ("Expected int, received: " ^ yytext);
adamc@91 286 continue ()));
adamc@91 287 <XMLTAG> {realconst} => (case Real.fromString yytext of
adamc@91 288 SOME x => Tokens.FLOAT (x, yypos, yypos + size yytext)
adamc@91 289 | NONE => (ErrorMsg.errorAt' (yypos, yypos)
adamc@91 290 ("Expected float, received: " ^ yytext);
adamc@91 291 continue ()));
adamc@91 292 <XMLTAG> "\"" => (YYBEGIN STRING;
adamc@91 293 xmlString := true;
adamc@104 294 strStart := yypos; str := []; continue ());
adamc@91 295
adamc@91 296 <XMLTAG> "{" => (YYBEGIN INITIAL;
adamc@91 297 pushLevel (fn () => YYBEGIN XMLTAG);
adamc@91 298 Tokens.LBRACE (yypos, yypos + 1));
adamc@91 299 <XMLTAG> "(" => (YYBEGIN INITIAL;
adamc@91 300 pushLevel (fn () => YYBEGIN XMLTAG);
adamc@91 301 Tokens.LPAREN (yypos, yypos + 1));
adamc@91 302
adamc@91 303 <XMLTAG> . => (ErrorMsg.errorAt' (yypos, yypos)
adamc@91 304 ("illegal XML tag character: \"" ^ yytext ^ "\"");
adamc@91 305 continue ());
adamc@91 306
adamc@91 307 <XML> "{" => (YYBEGIN INITIAL;
adamc@91 308 pushLevel (fn () => YYBEGIN XML);
adamc@91 309 Tokens.LBRACE (yypos, yypos + 1));
adamc@91 310
adamc@763 311 <XML> {notags} => (Tokens.NOTAGS (unescape (yypos, yypos + size yytext) yytext, yypos, yypos + size yytext));
adamc@91 312
adamc@91 313 <XML> . => (ErrorMsg.errorAt' (yypos, yypos)
adamc@91 314 ("illegal XML character: \"" ^ yytext ^ "\"");
adamc@91 315 continue ());
adamc@91 316
adamc@82 317 <INITIAL> "()" => (Tokens.UNIT (pos yypos, pos yypos + size yytext));
adamc@54 318 <INITIAL> "(" => (Tokens.LPAREN (pos yypos, pos yypos + size yytext));
adamc@54 319 <INITIAL> ")" => (Tokens.RPAREN (pos yypos, pos yypos + size yytext));
adamc@54 320 <INITIAL> "[" => (Tokens.LBRACK (pos yypos, pos yypos + size yytext));
adamc@54 321 <INITIAL> "]" => (Tokens.RBRACK (pos yypos, pos yypos + size yytext));
adamc@110 322 <INITIAL> "{" => (enterBrace ();
adamc@110 323 Tokens.LBRACE (pos yypos, pos yypos + size yytext));
adamc@110 324 <INITIAL> "}" => (exitBrace ();
adamc@110 325 Tokens.RBRACE (pos yypos, pos yypos + size yytext));
adamc@1 326
adamc@623 327 <INITIAL> "-->" => (Tokens.KARROW (pos yypos, pos yypos + size yytext));
adamc@54 328 <INITIAL> "->" => (Tokens.ARROW (pos yypos, pos yypos + size yytext));
adamc@623 329 <INITIAL> "==>" => (Tokens.DKARROW (pos yypos, pos yypos + size yytext));
adamc@54 330 <INITIAL> "=>" => (Tokens.DARROW (pos yypos, pos yypos + size yytext));
adamc@54 331 <INITIAL> "++" => (Tokens.PLUSPLUS (pos yypos, pos yypos + size yytext));
adamc@149 332 <INITIAL> "--" => (Tokens.MINUSMINUS (pos yypos, pos yypos + size yytext));
adamc@493 333 <INITIAL> "---" => (Tokens.MINUSMINUSMINUS (pos yypos, pos yypos + size yytext));
adamc@674 334 <INITIAL> "^" => (Tokens.CARET (pos yypos, pos yypos + size yytext));
adamc@1 335
adamc@842 336 <INITIAL> "&&" => (Tokens.ANDALSO (pos yypos, pos yypos + size yytext));
adamc@842 337 <INITIAL> "||" => (Tokens.ORELSE (pos yypos, pos yypos + size yytext));
adamc@842 338
adamc@54 339 <INITIAL> "=" => (Tokens.EQ (pos yypos, pos yypos + size yytext));
adamc@219 340 <INITIAL> "<>" => (Tokens.NE (pos yypos, pos yypos + size yytext));
adamc@219 341 <INITIAL> "<" => (Tokens.LT (pos yypos, pos yypos + size yytext));
adamc@219 342 <INITIAL> ">" => (Tokens.GT (pos yypos, pos yypos + size yytext));
adamc@219 343 <INITIAL> "<=" => (Tokens.LE (pos yypos, pos yypos + size yytext));
adamc@219 344 <INITIAL> ">=" => (Tokens.GE (pos yypos, pos yypos + size yytext));
adamc@54 345 <INITIAL> "," => (Tokens.COMMA (pos yypos, pos yypos + size yytext));
adamc@54 346 <INITIAL> ":::" => (Tokens.TCOLON (pos yypos, pos yypos + size yytext));
adamc@54 347 <INITIAL> "::" => (Tokens.DCOLON (pos yypos, pos yypos + size yytext));
adamc@54 348 <INITIAL> ":" => (Tokens.COLON (pos yypos, pos yypos + size yytext));
adamc@174 349 <INITIAL> "..." => (Tokens.DOTDOTDOT (pos yypos, pos yypos + size yytext));
adamc@54 350 <INITIAL> "." => (Tokens.DOT (pos yypos, pos yypos + size yytext));
adamc@54 351 <INITIAL> "$" => (Tokens.DOLLAR (pos yypos, pos yypos + size yytext));
adamc@54 352 <INITIAL> "#" => (Tokens.HASH (pos yypos, pos yypos + size yytext));
adamc@54 353 <INITIAL> "__" => (Tokens.UNDERUNDER (pos yypos, pos yypos + size yytext));
adamc@54 354 <INITIAL> "_" => (Tokens.UNDER (pos yypos, pos yypos + size yytext));
adamc@84 355 <INITIAL> "~" => (Tokens.TWIDDLE (pos yypos, pos yypos + size yytext));
adamc@156 356 <INITIAL> "|" => (Tokens.BAR (pos yypos, pos yypos + size yytext));
adamc@195 357 <INITIAL> "*" => (Tokens.STAR (pos yypos, pos yypos + size yytext));
adamc@243 358 <INITIAL> "<-" => (Tokens.LARROW (pos yypos, pos yypos + size yytext));
adamc@243 359 <INITIAL> ";" => (Tokens.SEMI (pos yypos, pos yypos + size yytext));
adamc@629 360 <INITIAL> "!" => (Tokens.BANG (pos yypos, pos yypos + size yytext));
adamc@1 361
adamc@389 362 <INITIAL> "+" => (Tokens.PLUS (pos yypos, pos yypos + size yytext));
adamc@389 363 <INITIAL> "-" => (Tokens.MINUS (pos yypos, pos yypos + size yytext));
adamc@389 364 <INITIAL> "/" => (Tokens.DIVIDE (yypos, yypos + size yytext));
adamc@389 365 <INITIAL> "%" => (Tokens.MOD (pos yypos, pos yypos + size yytext));
adamc@403 366 <INITIAL> "@" => (Tokens.AT (pos yypos, pos yypos + size yytext));
adamc@389 367
adamc@54 368 <INITIAL> "con" => (Tokens.CON (pos yypos, pos yypos + size yytext));
adamc@54 369 <INITIAL> "type" => (Tokens.LTYPE (pos yypos, pos yypos + size yytext));
adamc@156 370 <INITIAL> "datatype" => (Tokens.DATATYPE (pos yypos, pos yypos + size yytext));
adamc@156 371 <INITIAL> "of" => (Tokens.OF (pos yypos, pos yypos + size yytext));
adamc@54 372 <INITIAL> "val" => (Tokens.VAL (pos yypos, pos yypos + size yytext));
adamc@123 373 <INITIAL> "rec" => (Tokens.REC (pos yypos, pos yypos + size yytext));
adamc@123 374 <INITIAL> "and" => (Tokens.AND (pos yypos, pos yypos + size yytext));
adamc@242 375 <INITIAL> "fun" => (Tokens.FUN (pos yypos, pos yypos + size yytext));
adamc@54 376 <INITIAL> "fn" => (Tokens.FN (pos yypos, pos yypos + size yytext));
adamc@621 377 <INITIAL> "map" => (Tokens.MAP (pos yypos, pos yypos + size yytext));
adamc@170 378 <INITIAL> "case" => (Tokens.CASE (pos yypos, pos yypos + size yytext));
adamc@190 379 <INITIAL> "if" => (Tokens.IF (pos yypos, pos yypos + size yytext));
adamc@190 380 <INITIAL> "then" => (Tokens.THEN (pos yypos, pos yypos + size yytext));
adamc@190 381 <INITIAL> "else" => (Tokens.ELSE (pos yypos, pos yypos + size yytext));
adamc@1 382
adamc@842 383
adamc@54 384 <INITIAL> "structure" => (Tokens.STRUCTURE (pos yypos, pos yypos + size yytext));
adamc@54 385 <INITIAL> "signature" => (Tokens.SIGNATURE (pos yypos, pos yypos + size yytext));
adamc@54 386 <INITIAL> "struct" => (Tokens.STRUCT (pos yypos, pos yypos + size yytext));
adamc@54 387 <INITIAL> "sig" => (if yypos = 2 then initialSig () else (); Tokens.SIG (pos yypos, pos yypos + size yytext));
adamc@446 388 <INITIAL> "let" => (Tokens.LET (pos yypos, pos yypos + size yytext));
adamc@446 389 <INITIAL> "in" => (Tokens.IN (pos yypos, pos yypos + size yytext));
adamc@54 390 <INITIAL> "end" => (Tokens.END (pos yypos, pos yypos + size yytext));
adamc@54 391 <INITIAL> "functor" => (Tokens.FUNCTOR (pos yypos, pos yypos + size yytext));
adamc@54 392 <INITIAL> "where" => (Tokens.WHERE (pos yypos, pos yypos + size yytext));
adamc@54 393 <INITIAL> "extern" => (Tokens.EXTERN (pos yypos, pos yypos + size yytext));
adamc@58 394 <INITIAL> "include" => (Tokens.INCLUDE (pos yypos, pos yypos + size yytext));
adamc@58 395 <INITIAL> "open" => (Tokens.OPEN (pos yypos, pos yypos + size yytext));
adamc@88 396 <INITIAL> "constraint"=> (Tokens.CONSTRAINT (pos yypos, pos yypos + size yytext));
adamc@88 397 <INITIAL> "constraints"=> (Tokens.CONSTRAINTS (pos yypos, pos yypos + size yytext));
adamc@109 398 <INITIAL> "export" => (Tokens.EXPORT (pos yypos, pos yypos + size yytext));
adamc@203 399 <INITIAL> "table" => (Tokens.TABLE (pos yypos, pos yypos + size yytext));
adamc@338 400 <INITIAL> "sequence" => (Tokens.SEQUENCE (pos yypos, pos yypos + size yytext));
adamc@754 401 <INITIAL> "view" => (Tokens.VIEW (pos yypos, pos yypos + size yytext));
adamc@211 402 <INITIAL> "class" => (Tokens.CLASS (pos yypos, pos yypos + size yytext));
adamc@459 403 <INITIAL> "cookie" => (Tokens.COOKIE (pos yypos, pos yypos + size yytext));
adamc@718 404 <INITIAL> "style" => (Tokens.STYLE (pos yypos, pos yypos + size yytext));
adamc@30 405
adamc@54 406 <INITIAL> "Type" => (Tokens.TYPE (pos yypos, pos yypos + size yytext));
adamc@54 407 <INITIAL> "Name" => (Tokens.NAME (pos yypos, pos yypos + size yytext));
adamc@82 408 <INITIAL> "Unit" => (Tokens.KUNIT (pos yypos, pos yypos + size yytext));
adamc@1 409
adamc@204 410 <INITIAL> "SELECT" => (Tokens.SELECT (pos yypos, pos yypos + size yytext));
adamc@993 411 <INITIAL> "DISTINCT" => (Tokens.DISTINCT (pos yypos, pos yypos + size yytext));
adamc@204 412 <INITIAL> "FROM" => (Tokens.FROM (pos yypos, pos yypos + size yytext));
adamc@204 413 <INITIAL> "AS" => (Tokens.AS (pos yypos, pos yypos + size yytext));
adamc@209 414 <INITIAL> "WHERE" => (Tokens.CWHERE (pos yypos, pos yypos + size yytext));
adamc@339 415 <INITIAL> "SQL" => (Tokens.SQL (pos yypos, pos yypos + size yytext));
adamc@226 416 <INITIAL> "GROUP" => (Tokens.GROUP (pos yypos, pos yypos + size yytext));
adamc@230 417 <INITIAL> "ORDER" => (Tokens.ORDER (pos yypos, pos yypos + size yytext));
adamc@226 418 <INITIAL> "BY" => (Tokens.BY (pos yypos, pos yypos + size yytext));
adamc@227 419 <INITIAL> "HAVING" => (Tokens.HAVING (pos yypos, pos yypos + size yytext));
adamc@231 420 <INITIAL> "LIMIT" => (Tokens.LIMIT (pos yypos, pos yypos + size yytext));
adamc@231 421 <INITIAL> "OFFSET" => (Tokens.OFFSET (pos yypos, pos yypos + size yytext));
adamc@232 422 <INITIAL> "ALL" => (Tokens.ALL (pos yypos, pos yypos + size yytext));
adamc@209 423
adamc@749 424 <INITIAL> "JOIN" => (Tokens.JOIN (pos yypos, pos yypos + size yytext));
adamc@749 425 <INITIAL> "INNER" => (Tokens.INNER (pos yypos, pos yypos + size yytext));
adamc@749 426 <INITIAL> "CROSS" => (Tokens.CROSS (pos yypos, pos yypos + size yytext));
adamc@751 427 <INITIAL> "OUTER" => (Tokens.OUTER (pos yypos, pos yypos + size yytext));
adamc@750 428 <INITIAL> "LEFT" => (Tokens.LEFT (pos yypos, pos yypos + size yytext));
adamc@751 429 <INITIAL> "RIGHT" => (Tokens.RIGHT (pos yypos, pos yypos + size yytext));
adamc@751 430 <INITIAL> "FULL" => (Tokens.FULL (pos yypos, pos yypos + size yytext));
adamc@749 431
adamc@229 432 <INITIAL> "UNION" => (Tokens.UNION (pos yypos, pos yypos + size yytext));
adamc@229 433 <INITIAL> "INTERSECT" => (Tokens.INTERSECT (pos yypos, pos yypos + size yytext));
adamc@229 434 <INITIAL> "EXCEPT" => (Tokens.EXCEPT (pos yypos, pos yypos + size yytext));
adamc@229 435
adamc@209 436 <INITIAL> "TRUE" => (Tokens.TRUE (pos yypos, pos yypos + size yytext));
adamc@209 437 <INITIAL> "FALSE" => (Tokens.FALSE (pos yypos, pos yypos + size yytext));
adamc@220 438 <INITIAL> "AND" => (Tokens.CAND (pos yypos, pos yypos + size yytext));
adamc@220 439 <INITIAL> "OR" => (Tokens.OR (pos yypos, pos yypos + size yytext));
adamc@220 440 <INITIAL> "NOT" => (Tokens.NOT (pos yypos, pos yypos + size yytext));
adamc@204 441
adamc@235 442 <INITIAL> "COUNT" => (Tokens.COUNT (pos yypos, pos yypos + size yytext));
adamc@236 443 <INITIAL> "AVG" => (Tokens.AVG (pos yypos, pos yypos + size yytext));
adamc@236 444 <INITIAL> "SUM" => (Tokens.SUM (pos yypos, pos yypos + size yytext));
adamc@236 445 <INITIAL> "MIN" => (Tokens.MIN (pos yypos, pos yypos + size yytext));
adamc@236 446 <INITIAL> "MAX" => (Tokens.MAX (pos yypos, pos yypos + size yytext));
adamc@235 447
adamc@268 448 <INITIAL> "ASC" => (Tokens.ASC (pos yypos, pos yypos + size yytext));
adamc@268 449 <INITIAL> "DESC" => (Tokens.DESC (pos yypos, pos yypos + size yytext));
adamc@268 450
adamc@302 451 <INITIAL> "INSERT" => (Tokens.INSERT (pos yypos, pos yypos + size yytext));
adamc@302 452 <INITIAL> "INTO" => (Tokens.INTO (pos yypos, pos yypos + size yytext));
adamc@302 453 <INITIAL> "VALUES" => (Tokens.VALUES (pos yypos, pos yypos + size yytext));
adamc@302 454 <INITIAL> "UPDATE" => (Tokens.UPDATE (pos yypos, pos yypos + size yytext));
adamc@302 455 <INITIAL> "SET" => (Tokens.SET (pos yypos, pos yypos + size yytext));
adamc@302 456 <INITIAL> "DELETE" => (Tokens.DELETE (pos yypos, pos yypos + size yytext));
adamc@467 457 <INITIAL> "NULL" => (Tokens.NULL (pos yypos, pos yypos + size yytext));
adamc@470 458 <INITIAL> "IS" => (Tokens.IS (pos yypos, pos yypos + size yytext));
adamc@302 459
adamc@704 460 <INITIAL> "CONSTRAINT"=> (Tokens.CCONSTRAINT (pos yypos, pos yypos + size yytext));
adamc@704 461 <INITIAL> "UNIQUE" => (Tokens.UNIQUE (pos yypos, pos yypos + size yytext));
adamc@714 462 <INITIAL> "CHECK" => (Tokens.CHECK (pos yypos, pos yypos + size yytext));
adamc@707 463 <INITIAL> "PRIMARY" => (Tokens.PRIMARY (pos yypos, pos yypos + size yytext));
adamc@709 464 <INITIAL> "FOREIGN" => (Tokens.FOREIGN (pos yypos, pos yypos + size yytext));
adamc@707 465 <INITIAL> "KEY" => (Tokens.KEY (pos yypos, pos yypos + size yytext));
adamc@709 466 <INITIAL> "ON" => (Tokens.ON (pos yypos, pos yypos + size yytext));
adamc@709 467 <INITIAL> "NO" => (Tokens.NO (pos yypos, pos yypos + size yytext));
adamc@709 468 <INITIAL> "ACTION" => (Tokens.ACTION (pos yypos, pos yypos + size yytext));
adamc@709 469 <INITIAL> "RESTRICT" => (Tokens.RESTRICT (pos yypos, pos yypos + size yytext));
adamc@709 470 <INITIAL> "CASCADE" => (Tokens.CASCADE (pos yypos, pos yypos + size yytext));
adamc@709 471 <INITIAL> "REFERENCES"=> (Tokens.REFERENCES (pos yypos, pos yypos + size yytext));
adamc@709 472
adamc@709 473 <INITIAL> "CURRENT_TIMESTAMP" => (Tokens.CURRENT_TIMESTAMP (pos yypos, pos yypos + size yytext));
adamc@704 474
adamc@441 475 <INITIAL> "CURRENT_TIMESTAMP" => (Tokens.CURRENT_TIMESTAMP (pos yypos, pos yypos + size yytext));
adamc@441 476
adamc@54 477 <INITIAL> {id} => (Tokens.SYMBOL (yytext, pos yypos, pos yypos + size yytext));
adamc@54 478 <INITIAL> {cid} => (Tokens.CSYMBOL (yytext, pos yypos, pos yypos + size yytext));
adamc@1 479
adamc@14 480 <INITIAL> {intconst} => (case Int64.fromString yytext of
adamc@120 481 SOME x => Tokens.INT (x, pos yypos, pos yypos + size yytext)
adamc@120 482 | NONE => (ErrorMsg.errorAt' (pos yypos, pos yypos)
adamc@120 483 ("Expected int, received: " ^ yytext);
adamc@120 484 continue ()));
adamc@14 485 <INITIAL> {realconst} => (case Real64.fromString yytext of
adamc@54 486 SOME x => Tokens.FLOAT (x, pos yypos, pos yypos + size yytext)
adamc@54 487 | NONE => (ErrorMsg.errorAt' (pos yypos, pos yypos)
adamc@14 488 ("Expected float, received: " ^ yytext);
adamc@14 489 continue ()));
adamc@14 490
adamc@1 491 <COMMENT> . => (continue());
adamc@1 492
adamc@54 493 <INITIAL> . => (ErrorMsg.errorAt' (pos yypos, pos yypos)
adamc@1 494 ("illegal character: \"" ^ yytext ^ "\"");
adamc@1 495 continue ());