diff options
author | Ziv Scully <ziv@mit.edu> | 2015-07-19 19:05:16 -0700 |
---|---|---|
committer | Ziv Scully <ziv@mit.edu> | 2015-07-19 19:05:16 -0700 |
commit | a197d648e075a696f5ca86b23913b668f2baf940 (patch) | |
tree | 4c044e00c2df8ca6fd76d072f05bf1e3ff202140 /src/urweb.lex | |
parent | bc38beafd07b7ae6106a2fffda82084a08af7f06 (diff) | |
parent | c6e4d352f01eff2ddcdcc53c0f2a14666c2af8b2 (diff) |
Merge.
Diffstat (limited to 'src/urweb.lex')
-rw-r--r-- | src/urweb.lex | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/src/urweb.lex b/src/urweb.lex index 8b109727..ca45eb6d 100644 --- a/src/urweb.lex +++ b/src/urweb.lex @@ -178,11 +178,11 @@ fun unescape loc s = id = [a-z_][A-Za-z0-9_']*; xmlid = [A-Za-z][A-Za-z0-9_-]*; -cid = [A-Z][A-Za-z0-9_]*; +cid = [A-Z][A-Za-z0-9_']*; ws = [\ \t\012\r]; intconst = [0-9]+; realconst = [0-9]+\.[0-9]*; -hexconst = 0x[0-9A-F]{1,8}; +hexconst = 0x[0-9A-F]+; notags = ([^<{\n(]|(\([^\*<{\n]))+; xcom = ([^\-]|(-[^\-]))+; oint = [0-9][0-9][0-9]; @@ -537,22 +537,34 @@ xint = x[0-9a-fA-F][0-9a-fA-F]; <INITIAL> "CURRENT_TIMESTAMP" => (Tokens.CURRENT_TIMESTAMP (pos yypos, pos yypos + size yytext)); -<INITIAL> "CURRENT_TIMESTAMP" => (Tokens.CURRENT_TIMESTAMP (pos yypos, pos yypos + size yytext)); +<INITIAL> "_LOC_" => (let val strLoc = ErrorMsg.spanToString (ErrorMsg.spanOf + (pos yypos, pos yypos + size yytext)) + in + Tokens.STRING (strLoc, pos yypos, pos yypos + size yytext) + end); <INITIAL> {id} => (Tokens.SYMBOL (yytext, pos yypos, pos yypos + size yytext)); <INITIAL> {cid} => (Tokens.CSYMBOL (yytext, pos yypos, pos yypos + size yytext)); -<INITIAL> {hexconst} => (case StringCvt.scanString (Int64.scan StringCvt.HEX) (String.extract (yytext, 2, NONE)) of +<INITIAL> {hexconst} => (let val digits = String.extract (yytext, 2, NONE) + val v = (StringCvt.scanString (Int64.scan StringCvt.HEX) digits) + handle Overflow => NONE + in + case v of SOME x => Tokens.INT (x, pos yypos, pos yypos + size yytext) | NONE => (ErrorMsg.errorAt' (pos yypos, pos yypos) ("Expected hexInt, received: " ^ yytext); - continue ())); + continue ()) + end); -<INITIAL> {intconst} => (case Int64.fromString yytext of +<INITIAL> {intconst} => (let val v = (Int64.fromString yytext) handle Overflow => NONE + in + case v of SOME x => Tokens.INT (x, pos yypos, pos yypos + size yytext) | NONE => (ErrorMsg.errorAt' (pos yypos, pos yypos) ("Expected int, received: " ^ yytext); - continue ())); + continue ()) + end); <INITIAL> {realconst} => (case Real64.fromString yytext of SOME x => Tokens.FLOAT (x, pos yypos, pos yypos + size yytext) | NONE => (ErrorMsg.errorAt' (pos yypos, pos yypos) |