aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/urweb.lex
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adam@chlipala.net>2015-03-05 15:03:04 -0500
committerGravatar Adam Chlipala <adam@chlipala.net>2015-03-05 15:03:04 -0500
commitb5e81a0d27da103e5e771f78a319bae1cfa1703c (patch)
tree12258661357344bccf46e22b59e68aa1c84f4d5b /src/urweb.lex
parent34ad77c2c2e35155af59f8637a6bda552112781e (diff)
Hexadecimal integer literals, contributed by Gabriel Riba
Diffstat (limited to 'src/urweb.lex')
-rw-r--r--src/urweb.lex7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/urweb.lex b/src/urweb.lex
index 716c44ba..e1ffd1c3 100644
--- a/src/urweb.lex
+++ b/src/urweb.lex
@@ -182,6 +182,7 @@ 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};
notags = ([^<{\n(]|(\([^\*<{\n]))+;
xcom = ([^\-]|(-[^\-]))+;
oint = [0-9][0-9][0-9];
@@ -541,6 +542,12 @@ xint = x[0-9a-fA-F][0-9a-fA-F];
<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
+ SOME x => Tokens.INT (x, pos yypos, pos yypos + size yytext)
+ | NONE => (ErrorMsg.errorAt' (pos yypos, pos yypos)
+ ("Expected hexInt, received: " ^ yytext);
+ continue ()));
+
<INITIAL> {intconst} => (case Int64.fromString yytext of
SOME x => Tokens.INT (x, pos yypos, pos yypos + size yytext)
| NONE => (ErrorMsg.errorAt' (pos yypos, pos yypos)