Mercurial > urweb
comparison src/urweb.lex @ 2124:f3c24e6790ba
Hexadecimal integer literals, contributed by Gabriel Riba
author | Adam Chlipala <adam@chlipala.net> |
---|---|
date | Thu, 05 Mar 2015 15:03:04 -0500 |
parents | 8cf40452c900 |
children | a49c12ddf47d e10881cd92da |
comparison
equal
deleted
inserted
replaced
2123:1218daa14279 | 2124:f3c24e6790ba |
---|---|
180 xmlid = [A-Za-z][A-Za-z0-9_-]*; | 180 xmlid = [A-Za-z][A-Za-z0-9_-]*; |
181 cid = [A-Z][A-Za-z0-9_]*; | 181 cid = [A-Z][A-Za-z0-9_]*; |
182 ws = [\ \t\012\r]; | 182 ws = [\ \t\012\r]; |
183 intconst = [0-9]+; | 183 intconst = [0-9]+; |
184 realconst = [0-9]+\.[0-9]*; | 184 realconst = [0-9]+\.[0-9]*; |
185 hexconst = 0x[0-9A-F]{1,8}; | |
185 notags = ([^<{\n(]|(\([^\*<{\n]))+; | 186 notags = ([^<{\n(]|(\([^\*<{\n]))+; |
186 xcom = ([^\-]|(-[^\-]))+; | 187 xcom = ([^\-]|(-[^\-]))+; |
187 oint = [0-9][0-9][0-9]; | 188 oint = [0-9][0-9][0-9]; |
188 xint = x[0-9a-fA-F][0-9a-fA-F]; | 189 xint = x[0-9a-fA-F][0-9a-fA-F]; |
189 | 190 |
539 <INITIAL> "CURRENT_TIMESTAMP" => (Tokens.CURRENT_TIMESTAMP (pos yypos, pos yypos + size yytext)); | 540 <INITIAL> "CURRENT_TIMESTAMP" => (Tokens.CURRENT_TIMESTAMP (pos yypos, pos yypos + size yytext)); |
540 | 541 |
541 <INITIAL> {id} => (Tokens.SYMBOL (yytext, pos yypos, pos yypos + size yytext)); | 542 <INITIAL> {id} => (Tokens.SYMBOL (yytext, pos yypos, pos yypos + size yytext)); |
542 <INITIAL> {cid} => (Tokens.CSYMBOL (yytext, pos yypos, pos yypos + size yytext)); | 543 <INITIAL> {cid} => (Tokens.CSYMBOL (yytext, pos yypos, pos yypos + size yytext)); |
543 | 544 |
545 <INITIAL> {hexconst} => (case StringCvt.scanString (Int64.scan StringCvt.HEX) (String.extract (yytext, 2, NONE)) of | |
546 SOME x => Tokens.INT (x, pos yypos, pos yypos + size yytext) | |
547 | NONE => (ErrorMsg.errorAt' (pos yypos, pos yypos) | |
548 ("Expected hexInt, received: " ^ yytext); | |
549 continue ())); | |
550 | |
544 <INITIAL> {intconst} => (case Int64.fromString yytext of | 551 <INITIAL> {intconst} => (case Int64.fromString yytext of |
545 SOME x => Tokens.INT (x, pos yypos, pos yypos + size yytext) | 552 SOME x => Tokens.INT (x, pos yypos, pos yypos + size yytext) |
546 | NONE => (ErrorMsg.errorAt' (pos yypos, pos yypos) | 553 | NONE => (ErrorMsg.errorAt' (pos yypos, pos yypos) |
547 ("Expected int, received: " ^ yytext); | 554 ("Expected int, received: " ^ yytext); |
548 continue ())); | 555 continue ())); |