annotate src/urweb.lex @ 1225:950d1e540df6

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