| 1 |
structure CalcLex = struct |
| 2 |
|
| 3 |
datatype yystart_state = |
| 4 |
INITIAL |
| 5 |
structure UserDeclarations = |
| 6 |
struct |
| 7 |
|
| 8 |
|
| 9 |
structure T = CalcParseTokens |
| 10 |
type lex_result = T.token |
| 11 |
|
| 12 |
fun eof() = T.EOF |
| 13 |
|
| 14 |
|
| 15 |
end |
| 16 |
|
| 17 |
local |
| 18 |
datatype yymatch |
| 19 |
= yyNO_MATCH |
| 20 |
| yyMATCH of ULexBuffer.stream * action * yymatch |
| 21 |
withtype action = ULexBuffer.stream * yymatch -> UserDeclarations.lex_result |
| 22 |
|
| 23 |
val yytable : ((UTF8.wchar * UTF8.wchar * int) list * int list) Vector.vector = |
| 24 |
Vector.fromList [] |
| 25 |
fun yystreamify' p input = ULexBuffer.mkStream (p, input) |
| 26 |
|
| 27 |
fun yystreamifyReader' p readFn strm = let |
| 28 |
val s = ref strm |
| 29 |
fun iter(strm, n, accum) = |
| 30 |
if n > 1024 then (String.implode (rev accum), strm) |
| 31 |
else (case readFn strm |
| 32 |
of NONE => (String.implode (rev accum), strm) |
| 33 |
| SOME(c, strm') => iter (strm', n+1, c::accum)) |
| 34 |
fun input() = let |
| 35 |
val (data, strm) = iter(!s, 0, []) |
| 36 |
in |
| 37 |
s := strm; |
| 38 |
data |
| 39 |
end |
| 40 |
in |
| 41 |
yystreamify' p input |
| 42 |
end |
| 43 |
|
| 44 |
fun yystreamifyInstream' p strm = yystreamify' p (fn ()=>TextIO.input strm) |
| 45 |
|
| 46 |
fun innerLex |
| 47 |
(yystrm_, yyss_, yysm) = let |
| 48 |
(* current start state *) |
| 49 |
val yyss = ref yyss_ |
| 50 |
fun YYBEGIN ss = (yyss := ss) |
| 51 |
(* current input stream *) |
| 52 |
val yystrm = ref yystrm_ |
| 53 |
fun yysetStrm strm = yystrm := strm |
| 54 |
fun yygetPos() = ULexBuffer.getpos (!yystrm) |
| 55 |
fun yystreamify input = yystreamify' (yygetPos()) input |
| 56 |
fun yystreamifyReader readFn strm = yystreamifyReader' (yygetPos()) readFn strm |
| 57 |
fun yystreamifyInstream strm = yystreamifyInstream' (yygetPos()) strm |
| 58 |
(* start position of token -- can be updated via skip() *) |
| 59 |
val yystartPos = ref (yygetPos()) |
| 60 |
(* get one char of input *) |
| 61 |
fun yygetc strm = (case UTF8.getu ULexBuffer.getc strm |
| 62 |
of (SOME (0w10, s')) => |
| 63 |
(AntlrStreamPos.markNewLine yysm (ULexBuffer.getpos strm); |
| 64 |
SOME (0w10, s')) |
| 65 |
| x => x) |
| 66 |
fun yygetList getc strm = let |
| 67 |
val get1 = UTF8.getu getc |
| 68 |
fun iter (strm, accum) = |
| 69 |
(case get1 strm |
| 70 |
of NONE => rev accum |
| 71 |
| SOME (w, strm') => iter (strm', w::accum) |
| 72 |
(* end case *)) |
| 73 |
in |
| 74 |
iter (strm, []) |
| 75 |
end |
| 76 |
(* create yytext *) |
| 77 |
fun yymksubstr(strm) = ULexBuffer.subtract (strm, !yystrm) |
| 78 |
fun yymktext(strm) = Substring.string (yymksubstr strm) |
| 79 |
fun yymkunicode(strm) = yygetList Substring.getc (yymksubstr strm) |
| 80 |
open UserDeclarations |
| 81 |
fun lex () = let |
| 82 |
fun yystuck (yyNO_MATCH) = raise Fail "lexer reached a stuck state" |
| 83 |
| yystuck (yyMATCH (strm, action, old)) = |
| 84 |
action (strm, old) |
| 85 |
val yypos = yygetPos() |
| 86 |
fun yygetlineNo strm = AntlrStreamPos.lineNo yysm (ULexBuffer.getpos strm) |
| 87 |
fun yygetcolNo strm = AntlrStreamPos.colNo yysm (ULexBuffer.getpos strm) |
| 88 |
fun yyactsToMatches (strm, [], oldMatches) = oldMatches |
| 89 |
| yyactsToMatches (strm, act::acts, oldMatches) = |
| 90 |
yyMATCH (strm, act, yyactsToMatches (strm, acts, oldMatches)) |
| 91 |
fun yygo actTable = |
| 92 |
(fn (~1, _, oldMatches) => yystuck oldMatches |
| 93 |
| (curState, strm, oldMatches) => let |
| 94 |
val (transitions, finals') = Vector.sub (yytable, curState) |
| 95 |
val finals = map (fn i => Vector.sub (actTable, i)) finals' |
| 96 |
fun tryfinal() = |
| 97 |
yystuck (yyactsToMatches (strm, finals, oldMatches)) |
| 98 |
fun find (c, []) = NONE |
| 99 |
| find (c, (c1, c2, s)::ts) = |
| 100 |
if c1 <= c andalso c <= c2 then SOME s |
| 101 |
else find (c, ts) |
| 102 |
in case yygetc strm |
| 103 |
of SOME(c, strm') => |
| 104 |
(case find (c, transitions) |
| 105 |
of NONE => tryfinal() |
| 106 |
| SOME n => |
| 107 |
yygo actTable |
| 108 |
(n, strm', |
| 109 |
yyactsToMatches (strm, finals, oldMatches))) |
| 110 |
| NONE => tryfinal() |
| 111 |
end) |
| 112 |
val yylastwasnref = ref (ULexBuffer.lastWasNL (!yystrm)) |
| 113 |
fun continue() = let val yylastwasn = !yylastwasnref in |
| 114 |
let |
| 115 |
fun yyAction0 (strm, lastMatch : yymatch) = (yystrm := strm; T.KW_let ) |
| 116 |
fun yyAction1 (strm, lastMatch : yymatch) = (yystrm := strm; T.KW_in ) |
| 117 |
fun yyAction2 (strm, lastMatch : yymatch) = let |
| 118 |
val yytext = yymktext(strm) |
| 119 |
in |
| 120 |
yystrm := strm; T.ID (yytext) |
| 121 |
end |
| 122 |
fun yyAction3 (strm, lastMatch : yymatch) = let |
| 123 |
val yytext = yymktext(strm) |
| 124 |
in |
| 125 |
yystrm := strm; T.NUM (valOf (Int.fromString (yytext))) |
| 126 |
end |
| 127 |
fun yyAction4 (strm, lastMatch : yymatch) = (yystrm := strm; T.EQ ) |
| 128 |
fun yyAction5 (strm, lastMatch : yymatch) = (yystrm := strm; T.PLUS ) |
| 129 |
fun yyAction6 (strm, lastMatch : yymatch) = (yystrm := strm; T.MINUS ) |
| 130 |
fun yyAction7 (strm, lastMatch : yymatch) = (yystrm := strm; T.TIMES ) |
| 131 |
fun yyAction8 (strm, lastMatch : yymatch) = (yystrm := strm; T.LP ) |
| 132 |
fun yyAction9 (strm, lastMatch : yymatch) = (yystrm := strm; T.RP ) |
| 133 |
fun yyAction10 (strm, lastMatch : yymatch) = (yystrm := strm; T.SEMI ) |
| 134 |
fun yyAction11 (strm, lastMatch : yymatch) = (yystrm := strm; continue() ) |
| 135 |
fun yyQ10 (strm, lastMatch : yymatch) = (case (yygetc(strm)) |
| 136 |
of NONE => yyAction2(strm, yyNO_MATCH) |
| 137 |
| SOME(inp, strm') => |
| 138 |
if inp = 0wx41 |
| 139 |
then yyQ10(strm', yyMATCH(strm, yyAction2, yyNO_MATCH)) |
| 140 |
else if inp < 0wx41 |
| 141 |
then if inp = 0wx30 |
| 142 |
then yyQ10(strm', yyMATCH(strm, yyAction2, yyNO_MATCH)) |
| 143 |
else if inp < 0wx30 |
| 144 |
then yyAction2(strm, yyNO_MATCH) |
| 145 |
else if inp <= 0wx39 |
| 146 |
then yyQ10(strm', yyMATCH(strm, yyAction2, yyNO_MATCH)) |
| 147 |
else yyAction2(strm, yyNO_MATCH) |
| 148 |
else if inp = 0wx61 |
| 149 |
then yyQ10(strm', yyMATCH(strm, yyAction2, yyNO_MATCH)) |
| 150 |
else if inp < 0wx61 |
| 151 |
then if inp <= 0wx5A |
| 152 |
then yyQ10(strm', yyMATCH(strm, yyAction2, yyNO_MATCH)) |
| 153 |
else yyAction2(strm, yyNO_MATCH) |
| 154 |
else if inp <= 0wx7A |
| 155 |
then yyQ10(strm', yyMATCH(strm, yyAction2, yyNO_MATCH)) |
| 156 |
else yyAction2(strm, yyNO_MATCH) |
| 157 |
(* end case *)) |
| 158 |
fun yyQ14 (strm, lastMatch : yymatch) = (case (yygetc(strm)) |
| 159 |
of NONE => yyAction0(strm, yyNO_MATCH) |
| 160 |
| SOME(inp, strm') => |
| 161 |
if inp = 0wx41 |
| 162 |
then yyQ10(strm', yyMATCH(strm, yyAction0, yyNO_MATCH)) |
| 163 |
else if inp < 0wx41 |
| 164 |
then if inp = 0wx30 |
| 165 |
then yyQ10(strm', yyMATCH(strm, yyAction0, yyNO_MATCH)) |
| 166 |
else if inp < 0wx30 |
| 167 |
then yyAction0(strm, yyNO_MATCH) |
| 168 |
else if inp <= 0wx39 |
| 169 |
then yyQ10(strm', yyMATCH(strm, yyAction0, yyNO_MATCH)) |
| 170 |
else yyAction0(strm, yyNO_MATCH) |
| 171 |
else if inp = 0wx61 |
| 172 |
then yyQ10(strm', yyMATCH(strm, yyAction0, yyNO_MATCH)) |
| 173 |
else if inp < 0wx61 |
| 174 |
then if inp <= 0wx5A |
| 175 |
then yyQ10(strm', yyMATCH(strm, yyAction0, yyNO_MATCH)) |
| 176 |
else yyAction0(strm, yyNO_MATCH) |
| 177 |
else if inp <= 0wx7A |
| 178 |
then yyQ10(strm', yyMATCH(strm, yyAction0, yyNO_MATCH)) |
| 179 |
else yyAction0(strm, yyNO_MATCH) |
| 180 |
(* end case *)) |
| 181 |
fun yyQ13 (strm, lastMatch : yymatch) = (case (yygetc(strm)) |
| 182 |
of NONE => yyAction2(strm, yyNO_MATCH) |
| 183 |
| SOME(inp, strm') => |
| 184 |
if inp = 0wx5B |
| 185 |
then yyAction2(strm, yyNO_MATCH) |
| 186 |
else if inp < 0wx5B |
| 187 |
then if inp = 0wx3A |
| 188 |
then yyAction2(strm, yyNO_MATCH) |
| 189 |
else if inp < 0wx3A |
| 190 |
then if inp <= 0wx2F |
| 191 |
then yyAction2(strm, yyNO_MATCH) |
| 192 |
else yyQ10(strm', yyMATCH(strm, yyAction2, yyNO_MATCH)) |
| 193 |
else if inp <= 0wx40 |
| 194 |
then yyAction2(strm, yyNO_MATCH) |
| 195 |
else yyQ10(strm', yyMATCH(strm, yyAction2, yyNO_MATCH)) |
| 196 |
else if inp = 0wx74 |
| 197 |
then yyQ14(strm', yyMATCH(strm, yyAction2, yyNO_MATCH)) |
| 198 |
else if inp < 0wx74 |
| 199 |
then if inp <= 0wx60 |
| 200 |
then yyAction2(strm, yyNO_MATCH) |
| 201 |
else yyQ10(strm', yyMATCH(strm, yyAction2, yyNO_MATCH)) |
| 202 |
else if inp <= 0wx7A |
| 203 |
then yyQ10(strm', yyMATCH(strm, yyAction2, yyNO_MATCH)) |
| 204 |
else yyAction2(strm, yyNO_MATCH) |
| 205 |
(* end case *)) |
| 206 |
fun yyQ12 (strm, lastMatch : yymatch) = (case (yygetc(strm)) |
| 207 |
of NONE => yyAction2(strm, yyNO_MATCH) |
| 208 |
| SOME(inp, strm') => |
| 209 |
if inp = 0wx5B |
| 210 |
then yyAction2(strm, yyNO_MATCH) |
| 211 |
else if inp < 0wx5B |
| 212 |
then if inp = 0wx3A |
| 213 |
then yyAction2(strm, yyNO_MATCH) |
| 214 |
else if inp < 0wx3A |
| 215 |
then if inp <= 0wx2F |
| 216 |
then yyAction2(strm, yyNO_MATCH) |
| 217 |
else yyQ10(strm', yyMATCH(strm, yyAction2, yyNO_MATCH)) |
| 218 |
else if inp <= 0wx40 |
| 219 |
then yyAction2(strm, yyNO_MATCH) |
| 220 |
else yyQ10(strm', yyMATCH(strm, yyAction2, yyNO_MATCH)) |
| 221 |
else if inp = 0wx65 |
| 222 |
then yyQ13(strm', yyMATCH(strm, yyAction2, yyNO_MATCH)) |
| 223 |
else if inp < 0wx65 |
| 224 |
then if inp <= 0wx60 |
| 225 |
then yyAction2(strm, yyNO_MATCH) |
| 226 |
else yyQ10(strm', yyMATCH(strm, yyAction2, yyNO_MATCH)) |
| 227 |
else if inp <= 0wx7A |
| 228 |
then yyQ10(strm', yyMATCH(strm, yyAction2, yyNO_MATCH)) |
| 229 |
else yyAction2(strm, yyNO_MATCH) |
| 230 |
(* end case *)) |
| 231 |
fun yyQ15 (strm, lastMatch : yymatch) = (case (yygetc(strm)) |
| 232 |
of NONE => yyAction1(strm, yyNO_MATCH) |
| 233 |
| SOME(inp, strm') => |
| 234 |
if inp = 0wx41 |
| 235 |
then yyQ10(strm', yyMATCH(strm, yyAction1, yyNO_MATCH)) |
| 236 |
else if inp < 0wx41 |
| 237 |
then if inp = 0wx30 |
| 238 |
then yyQ10(strm', yyMATCH(strm, yyAction1, yyNO_MATCH)) |
| 239 |
else if inp < 0wx30 |
| 240 |
then yyAction1(strm, yyNO_MATCH) |
| 241 |
else if inp <= 0wx39 |
| 242 |
then yyQ10(strm', yyMATCH(strm, yyAction1, yyNO_MATCH)) |
| 243 |
else yyAction1(strm, yyNO_MATCH) |
| 244 |
else if inp = 0wx61 |
| 245 |
then yyQ10(strm', yyMATCH(strm, yyAction1, yyNO_MATCH)) |
| 246 |
else if inp < 0wx61 |
| 247 |
then if inp <= 0wx5A |
| 248 |
then yyQ10(strm', yyMATCH(strm, yyAction1, yyNO_MATCH)) |
| 249 |
else yyAction1(strm, yyNO_MATCH) |
| 250 |
else if inp <= 0wx7A |
| 251 |
then yyQ10(strm', yyMATCH(strm, yyAction1, yyNO_MATCH)) |
| 252 |
else yyAction1(strm, yyNO_MATCH) |
| 253 |
(* end case *)) |
| 254 |
fun yyQ11 (strm, lastMatch : yymatch) = (case (yygetc(strm)) |
| 255 |
of NONE => yyAction2(strm, yyNO_MATCH) |
| 256 |
| SOME(inp, strm') => |
| 257 |
if inp = 0wx5B |
| 258 |
then yyAction2(strm, yyNO_MATCH) |
| 259 |
else if inp < 0wx5B |
| 260 |
then if inp = 0wx3A |
| 261 |
then yyAction2(strm, yyNO_MATCH) |
| 262 |
else if inp < 0wx3A |
| 263 |
then if inp <= 0wx2F |
| 264 |
then yyAction2(strm, yyNO_MATCH) |
| 265 |
else yyQ10(strm', yyMATCH(strm, yyAction2, yyNO_MATCH)) |
| 266 |
else if inp <= 0wx40 |
| 267 |
then yyAction2(strm, yyNO_MATCH) |
| 268 |
else yyQ10(strm', yyMATCH(strm, yyAction2, yyNO_MATCH)) |
| 269 |
else if inp = 0wx6E |
| 270 |
then yyQ15(strm', yyMATCH(strm, yyAction2, yyNO_MATCH)) |
| 271 |
else if inp < 0wx6E |
| 272 |
then if inp <= 0wx60 |
| 273 |
then yyAction2(strm, yyNO_MATCH) |
| 274 |
else yyQ10(strm', yyMATCH(strm, yyAction2, yyNO_MATCH)) |
| 275 |
else if inp <= 0wx7A |
| 276 |
then yyQ10(strm', yyMATCH(strm, yyAction2, yyNO_MATCH)) |
| 277 |
else yyAction2(strm, yyNO_MATCH) |
| 278 |
(* end case *)) |
| 279 |
fun yyQ9 (strm, lastMatch : yymatch) = (case (yygetc(strm)) |
| 280 |
of NONE => yyAction4(strm, yyNO_MATCH) |
| 281 |
| SOME(inp, strm') => yyAction4(strm, yyNO_MATCH) |
| 282 |
(* end case *)) |
| 283 |
fun yyQ8 (strm, lastMatch : yymatch) = (case (yygetc(strm)) |
| 284 |
of NONE => yyAction10(strm, yyNO_MATCH) |
| 285 |
| SOME(inp, strm') => yyAction10(strm, yyNO_MATCH) |
| 286 |
(* end case *)) |
| 287 |
fun yyQ7 (strm, lastMatch : yymatch) = (case (yygetc(strm)) |
| 288 |
of NONE => yyAction3(strm, yyNO_MATCH) |
| 289 |
| SOME(inp, strm') => |
| 290 |
if inp = 0wx30 |
| 291 |
then yyQ7(strm', yyMATCH(strm, yyAction3, yyNO_MATCH)) |
| 292 |
else if inp < 0wx30 |
| 293 |
then yyAction3(strm, yyNO_MATCH) |
| 294 |
else if inp <= 0wx39 |
| 295 |
then yyQ7(strm', yyMATCH(strm, yyAction3, yyNO_MATCH)) |
| 296 |
else yyAction3(strm, yyNO_MATCH) |
| 297 |
(* end case *)) |
| 298 |
fun yyQ6 (strm, lastMatch : yymatch) = (case (yygetc(strm)) |
| 299 |
of NONE => yyAction6(strm, yyNO_MATCH) |
| 300 |
| SOME(inp, strm') => yyAction6(strm, yyNO_MATCH) |
| 301 |
(* end case *)) |
| 302 |
fun yyQ5 (strm, lastMatch : yymatch) = (case (yygetc(strm)) |
| 303 |
of NONE => yyAction5(strm, yyNO_MATCH) |
| 304 |
| SOME(inp, strm') => yyAction5(strm, yyNO_MATCH) |
| 305 |
(* end case *)) |
| 306 |
fun yyQ4 (strm, lastMatch : yymatch) = (case (yygetc(strm)) |
| 307 |
of NONE => yyAction7(strm, yyNO_MATCH) |
| 308 |
| SOME(inp, strm') => yyAction7(strm, yyNO_MATCH) |
| 309 |
(* end case *)) |
| 310 |
fun yyQ3 (strm, lastMatch : yymatch) = (case (yygetc(strm)) |
| 311 |
of NONE => yyAction9(strm, yyNO_MATCH) |
| 312 |
| SOME(inp, strm') => yyAction9(strm, yyNO_MATCH) |
| 313 |
(* end case *)) |
| 314 |
fun yyQ2 (strm, lastMatch : yymatch) = (case (yygetc(strm)) |
| 315 |
of NONE => yyAction8(strm, yyNO_MATCH) |
| 316 |
| SOME(inp, strm') => yyAction8(strm, yyNO_MATCH) |
| 317 |
(* end case *)) |
| 318 |
fun yyQ1 (strm, lastMatch : yymatch) = (case (yygetc(strm)) |
| 319 |
of NONE => yyAction11(strm, yyNO_MATCH) |
| 320 |
| SOME(inp, strm') => yyAction11(strm, yyNO_MATCH) |
| 321 |
(* end case *)) |
| 322 |
fun yyQ0 (strm, lastMatch : yymatch) = (case (yygetc(strm)) |
| 323 |
of NONE => |
| 324 |
if ULexBuffer.eof(!(yystrm)) |
| 325 |
then let |
| 326 |
val yycolno = ref(yygetcolNo(!(yystrm))) |
| 327 |
val yylineno = ref(yygetlineNo(!(yystrm))) |
| 328 |
in |
| 329 |
(case (!(yyss)) |
| 330 |
of _ => (UserDeclarations.eof()) |
| 331 |
(* end case *)) |
| 332 |
end |
| 333 |
else yystuck(lastMatch) |
| 334 |
| SOME(inp, strm') => |
| 335 |
if inp = 0wx3A |
| 336 |
then if ULexBuffer.eof(!(yystrm)) |
| 337 |
then let |
| 338 |
val yycolno = ref(yygetcolNo(!(yystrm))) |
| 339 |
val yylineno = ref(yygetlineNo(!(yystrm))) |
| 340 |
in |
| 341 |
(case (!(yyss)) |
| 342 |
of _ => (UserDeclarations.eof()) |
| 343 |
(* end case *)) |
| 344 |
end |
| 345 |
else yystuck(lastMatch) |
| 346 |
else if inp < 0wx3A |
| 347 |
then if inp = 0wx29 |
| 348 |
then yyQ3(strm', lastMatch) |
| 349 |
else if inp < 0wx29 |
| 350 |
then if inp = 0wx20 |
| 351 |
then yyQ1(strm', lastMatch) |
| 352 |
else if inp < 0wx20 |
| 353 |
then if inp = 0wx9 |
| 354 |
then yyQ1(strm', lastMatch) |
| 355 |
else if inp < 0wx9 |
| 356 |
then if ULexBuffer.eof(!(yystrm)) |
| 357 |
then let |
| 358 |
val yycolno = ref(yygetcolNo(!(yystrm))) |
| 359 |
val yylineno = ref(yygetlineNo(!(yystrm))) |
| 360 |
in |
| 361 |
(case (!(yyss)) |
| 362 |
of _ => (UserDeclarations.eof()) |
| 363 |
(* end case *)) |
| 364 |
end |
| 365 |
else yystuck(lastMatch) |
| 366 |
else if inp <= 0wxA |
| 367 |
then yyQ1(strm', lastMatch) |
| 368 |
else if ULexBuffer.eof(!(yystrm)) |
| 369 |
then let |
| 370 |
val yycolno = ref(yygetcolNo(!(yystrm))) |
| 371 |
val yylineno = ref(yygetlineNo(!(yystrm))) |
| 372 |
in |
| 373 |
(case (!(yyss)) |
| 374 |
of _ => (UserDeclarations.eof()) |
| 375 |
(* end case *)) |
| 376 |
end |
| 377 |
else yystuck(lastMatch) |
| 378 |
else if inp = 0wx28 |
| 379 |
then yyQ2(strm', lastMatch) |
| 380 |
else if ULexBuffer.eof(!(yystrm)) |
| 381 |
then let |
| 382 |
val yycolno = ref(yygetcolNo(!(yystrm))) |
| 383 |
val yylineno = ref(yygetlineNo(!(yystrm))) |
| 384 |
in |
| 385 |
(case (!(yyss)) |
| 386 |
of _ => (UserDeclarations.eof()) |
| 387 |
(* end case *)) |
| 388 |
end |
| 389 |
else yystuck(lastMatch) |
| 390 |
else if inp = 0wx2D |
| 391 |
then yyQ6(strm', lastMatch) |
| 392 |
else if inp < 0wx2D |
| 393 |
then if inp = 0wx2B |
| 394 |
then yyQ5(strm', lastMatch) |
| 395 |
else if inp = 0wx2A |
| 396 |
then yyQ4(strm', lastMatch) |
| 397 |
else if ULexBuffer.eof(!(yystrm)) |
| 398 |
then let |
| 399 |
val yycolno = ref(yygetcolNo(!(yystrm))) |
| 400 |
val yylineno = ref(yygetlineNo(!(yystrm))) |
| 401 |
in |
| 402 |
(case (!(yyss)) |
| 403 |
of _ => (UserDeclarations.eof()) |
| 404 |
(* end case *)) |
| 405 |
end |
| 406 |
else yystuck(lastMatch) |
| 407 |
else if inp <= 0wx2F |
| 408 |
then if ULexBuffer.eof(!(yystrm)) |
| 409 |
then let |
| 410 |
val yycolno = ref(yygetcolNo(!(yystrm))) |
| 411 |
val yylineno = ref(yygetlineNo(!(yystrm))) |
| 412 |
in |
| 413 |
(case (!(yyss)) |
| 414 |
of _ => (UserDeclarations.eof()) |
| 415 |
(* end case *)) |
| 416 |
end |
| 417 |
else yystuck(lastMatch) |
| 418 |
else yyQ7(strm', lastMatch) |
| 419 |
else if inp = 0wx61 |
| 420 |
then yyQ10(strm', lastMatch) |
| 421 |
else if inp < 0wx61 |
| 422 |
then if inp = 0wx3E |
| 423 |
then if ULexBuffer.eof(!(yystrm)) |
| 424 |
then let |
| 425 |
val yycolno = ref(yygetcolNo(!(yystrm))) |
| 426 |
val yylineno = ref(yygetlineNo(!(yystrm))) |
| 427 |
in |
| 428 |
(case (!(yyss)) |
| 429 |
of _ => (UserDeclarations.eof()) |
| 430 |
(* end case *)) |
| 431 |
end |
| 432 |
else yystuck(lastMatch) |
| 433 |
else if inp < 0wx3E |
| 434 |
then if inp = 0wx3C |
| 435 |
then if ULexBuffer.eof(!(yystrm)) |
| 436 |
then let |
| 437 |
val yycolno = ref(yygetcolNo(!(yystrm))) |
| 438 |
val yylineno = ref(yygetlineNo(!(yystrm))) |
| 439 |
in |
| 440 |
(case (!(yyss)) |
| 441 |
of _ => (UserDeclarations.eof()) |
| 442 |
(* end case *)) |
| 443 |
end |
| 444 |
else yystuck(lastMatch) |
| 445 |
else if inp = 0wx3B |
| 446 |
then yyQ8(strm', lastMatch) |
| 447 |
else yyQ9(strm', lastMatch) |
| 448 |
else if inp = 0wx41 |
| 449 |
then yyQ10(strm', lastMatch) |
| 450 |
else if inp < 0wx41 |
| 451 |
then if ULexBuffer.eof(!(yystrm)) |
| 452 |
then let |
| 453 |
val yycolno = ref(yygetcolNo(!(yystrm))) |
| 454 |
val yylineno = ref(yygetlineNo(!(yystrm))) |
| 455 |
in |
| 456 |
(case (!(yyss)) |
| 457 |
of _ => (UserDeclarations.eof()) |
| 458 |
(* end case *)) |
| 459 |
end |
| 460 |
else yystuck(lastMatch) |
| 461 |
else if inp <= 0wx5A |
| 462 |
then yyQ10(strm', lastMatch) |
| 463 |
else if ULexBuffer.eof(!(yystrm)) |
| 464 |
then let |
| 465 |
val yycolno = ref(yygetcolNo(!(yystrm))) |
| 466 |
val yylineno = ref(yygetlineNo(!(yystrm))) |
| 467 |
in |
| 468 |
(case (!(yyss)) |
| 469 |
of _ => (UserDeclarations.eof()) |
| 470 |
(* end case *)) |
| 471 |
end |
| 472 |
else yystuck(lastMatch) |
| 473 |
else if inp = 0wx6C |
| 474 |
then yyQ12(strm', lastMatch) |
| 475 |
else if inp < 0wx6C |
| 476 |
then if inp = 0wx69 |
| 477 |
then yyQ11(strm', lastMatch) |
| 478 |
else yyQ10(strm', lastMatch) |
| 479 |
else if inp <= 0wx7A |
| 480 |
then yyQ10(strm', lastMatch) |
| 481 |
else if ULexBuffer.eof(!(yystrm)) |
| 482 |
then let |
| 483 |
val yycolno = ref(yygetcolNo(!(yystrm))) |
| 484 |
val yylineno = ref(yygetlineNo(!(yystrm))) |
| 485 |
in |
| 486 |
(case (!(yyss)) |
| 487 |
of _ => (UserDeclarations.eof()) |
| 488 |
(* end case *)) |
| 489 |
end |
| 490 |
else yystuck(lastMatch) |
| 491 |
(* end case *)) |
| 492 |
in |
| 493 |
(case (!(yyss)) |
| 494 |
of INITIAL => yyQ0(!(yystrm), yyNO_MATCH) |
| 495 |
(* end case *)) |
| 496 |
end |
| 497 |
end |
| 498 |
and skip() = (yystartPos := yygetPos(); |
| 499 |
yylastwasnref := ULexBuffer.lastWasNL (!yystrm); |
| 500 |
continue()) |
| 501 |
in (continue(), (!yystartPos, yygetPos()), !yystrm, !yyss) end |
| 502 |
in |
| 503 |
lex() |
| 504 |
end |
| 505 |
in |
| 506 |
type pos = AntlrStreamPos.pos |
| 507 |
type span = AntlrStreamPos.span |
| 508 |
type tok = UserDeclarations.lex_result |
| 509 |
|
| 510 |
datatype prestrm = STRM of ULexBuffer.stream * |
| 511 |
(yystart_state * tok * span * prestrm * yystart_state) option ref |
| 512 |
type strm = (prestrm * yystart_state) |
| 513 |
|
| 514 |
fun lex sm |
| 515 |
(STRM (yystrm, memo), ss) = (case !memo |
| 516 |
of NONE => let |
| 517 |
val (tok, span, yystrm', ss') = innerLex |
| 518 |
(yystrm, ss, sm) |
| 519 |
val strm' = STRM (yystrm', ref NONE); |
| 520 |
in |
| 521 |
memo := SOME (ss, tok, span, strm', ss'); |
| 522 |
(tok, span, (strm', ss')) |
| 523 |
end |
| 524 |
| SOME (ss', tok, span, strm', ss'') => |
| 525 |
if ss = ss' then |
| 526 |
(tok, span, (strm', ss'')) |
| 527 |
else ( |
| 528 |
memo := NONE; |
| 529 |
lex sm |
| 530 |
(STRM (yystrm, memo), ss)) |
| 531 |
(* end case *)) |
| 532 |
|
| 533 |
fun streamify input = (STRM (yystreamify' 0 input, ref NONE), INITIAL) |
| 534 |
fun streamifyReader readFn strm = (STRM (yystreamifyReader' 0 readFn strm, ref NONE), |
| 535 |
INITIAL) |
| 536 |
fun streamifyInstream strm = (STRM (yystreamifyInstream' 0 strm, ref NONE), |
| 537 |
INITIAL) |
| 538 |
|
| 539 |
fun getPos (STRM (strm, _), _) = ULexBuffer.getpos strm |
| 540 |
|
| 541 |
end |
| 542 |
end |