# HG changeset patch # User Adam Chlipala # Date 1425585784 18000 # Node ID f3c24e6790ba2cb94197fea2cf074405c5fc78b5 # Parent 1218daa14279f092b823a2c14fae1380fe36dfa1 Hexadecimal integer literals, contributed by Gabriel Riba diff -r 1218daa14279 -r f3c24e6790ba src/urweb.lex --- a/src/urweb.lex Thu Mar 05 14:58:34 2015 -0500 +++ b/src/urweb.lex Thu Mar 05 15:03:04 2015 -0500 @@ -182,6 +182,7 @@ ws = [\ \t\012\r]; intconst = [0-9]+; realconst = [0-9]+\.[0-9]*; +hexconst = 0x[0-9A-F]{1,8}; notags = ([^<{\n(]|(\([^\*<{\n]))+; xcom = ([^\-]|(-[^\-]))+; oint = [0-9][0-9][0-9]; @@ -541,6 +542,12 @@ {id} => (Tokens.SYMBOL (yytext, pos yypos, pos yypos + size yytext)); {cid} => (Tokens.CSYMBOL (yytext, pos yypos, pos yypos + size yytext)); + {hexconst} => (case StringCvt.scanString (Int64.scan StringCvt.HEX) (String.extract (yytext, 2, NONE)) of + SOME x => Tokens.INT (x, pos yypos, pos yypos + size yytext) + | NONE => (ErrorMsg.errorAt' (pos yypos, pos yypos) + ("Expected hexInt, received: " ^ yytext); + continue ())); + {intconst} => (case Int64.fromString yytext of SOME x => Tokens.INT (x, pos yypos, pos yypos + size yytext) | NONE => (ErrorMsg.errorAt' (pos yypos, pos yypos)