summaryrefslogtreecommitdiffstats
path: root/parser.l
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2012-09-16 11:11:43 -0700
committerKaz Kylheku <kaz@kylheku.com>2012-09-16 11:11:43 -0700
commit04a89cc3d83a71b5c9b5df7088d2408e8f7b8a40 (patch)
treefbae8b38e6e6900ccb90c0e3769eef7af12eca57 /parser.l
parent80368daa62166345e31418d5fff72a5069801f2a (diff)
downloadtxr-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.l27
1 files changed, 25 insertions, 2 deletions
diff --git a/parser.l b/parser.l
index 344684fe..ad7b013f 100644
--- a/parser.l
+++ b/parser.l
@@ -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} {