annotate src/urweb.lex @ 1113:40d48a2b78a7

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