diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2012-09-16 11:11:43 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2012-09-16 11:11:43 -0700 |
commit | 04a89cc3d83a71b5c9b5df7088d2408e8f7b8a40 (patch) | |
tree | fbae8b38e6e6900ccb90c0e3769eef7af12eca57 /parser.l | |
parent | 80368daa62166345e31418d5fff72a5069801f2a (diff) | |
download | txr-04a89cc3d83a71b5c9b5df7088d2408e8f7b8a40.tar.gz txr-04a89cc3d83a71b5c9b5df7088d2408e8f7b8a40.tar.bz2 txr-04a89cc3d83a71b5c9b5df7088d2408e8f7b8a40.zip |
* parser.l: Implemented hexadecimal integer constants.
These will be very useful since bit operations are about
to be implemented.
* txr.1: Documented.
Diffstat (limited to 'parser.l')
-rw-r--r-- | parser.l | 27 |
1 files changed, 25 insertions, 2 deletions
@@ -152,16 +152,17 @@ SYM [a-zA-Z0-9_]+ SGN [+\-] EXP [eE][+\-]?[0-9]+ DIG [0-9] +XDIG [0-9A-Fa-f] NUM {SGN}?{DIG}+ FLO {SGN}?({DIG}*[.]{DIG}+{EXP}?|{DIG}+[.]?{EXP}) FLODOT {SGN}?{DIG}+[.] +XNUM #x{SGN}?{XDIG}+ BSCHR [a-zA-Z0-9!$%&*+\-<=>?\\^_~] BSYM {BSCHR}({BSCHR}|#)* NSCHR [a-zA-Z0-9!$%&*+\-<=>?\\^_~/] ID_END [^a-zA-Z0-9!$%&*+\-<=>?\\^_~/] NSYM {NSCHR}({NSCHR}|#)* TOK :?{SYM} -ATNUM @{NUM} BTOK [:@]?{BSYM} NTOK [:@]?{NSYM} WS [\t ]* @@ -194,6 +195,18 @@ UONLY {U2}{U}|{U3}{U}{U}|{U4}{U}{U}{U} return NUMBER; } +<SPECIAL,NESTED,BRACED>{XNUM} { + val str = string_own(utf8_dup_from(yytext + 2)); + + if (yy_top_state() == INITIAL + || yy_top_state() == QSILIT) + yy_pop_state(); + + yylval.val = int_str(str, num(16)); + return NUMBER; +} + + <SPECIAL,NESTED,BRACED>{FLO} { val str = string_own(utf8_dup_from(yytext)); @@ -216,7 +229,7 @@ UONLY {U2}{U}|{U3}{U}{U}|{U4}{U}{U}{U} return NUMBER; } -<NESTED,QSILIT>{ATNUM} { +<NESTED,QSILIT>@{NUM} { val str = string_own(utf8_dup_from(yytext + 1)); if (yy_top_state() == INITIAL @@ -226,6 +239,16 @@ UONLY {U2}{U}|{U3}{U}{U}|{U4}{U}{U}{U} return METANUM; } +<NESTED,QSILIT>@{XNUM} { + val str = string_own(utf8_dup_from(yytext + 3)); + + if (yy_top_state() == INITIAL + || yy_top_state() == QSILIT) + yy_pop_state(); + yylval.val = int_str(str, num(16)); + return METANUM; +} + <SPECIAL>{TOK} | <BRACED>{BTOK} | <NESTED>{NTOK} { |