summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog8
-rw-r--r--parser.l27
-rw-r--r--txr.114
3 files changed, 44 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index 94dd5903..3281ad6a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2012-09-16 Kaz Kylheku <kaz@kylheku.com>
+
+ * parser.l: Implemented hexadecimal integer constants.
+ These will be very useful since bit operations are about
+ to be implemented.
+
+ * txr.1: Documented.
+
2012-09-12 Kaz Kylheku <kaz@kylheku.com>
* eval.c (eval_init): New intrinsics: make-similar-hash, copy-hash,
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} {
diff --git a/txr.1 b/txr.1
index 5750d954..a641d91f 100644
--- a/txr.1
+++ b/txr.1
@@ -124,9 +124,10 @@ for a failed query, even if the program produced output.
Print the variable bindings in Lisp syntax instead of shell syntax.
.IP "-a num"
-Specifies the maximum number of array dimensions to use for variables
-arising out of collect. The default is 1. Additional dimensions are
-expressed using numeric suffixes in the generated variable names.
+The decimal integer argument specifies the maximum number of array dimensions
+to use for variables arising out of collect. The default is 1. Additional
+dimensions are expressed using numeric suffixes in the generated variable
+names.
For instance, consider the three-dimensional list arising out of a triply
nested collect: ((("a" "b") ("c" "d")) (("e" "f") ("g" "h"))).
Suppose this is bound to a variable V. With -a 1, this will be
@@ -1117,6 +1118,13 @@ Examples:
-0
+234483527304983792384729384723234
+An integer constant can also be specified in hexadecimal using the prefix
+#x followed by an optional sign, followed by hexadecimal digits: 0 through 9
+and the upper or lower case letters A through F:
+
+ #xFF ;; 255
+ #x-ABC ;; -2748
+
A floating-point constant is marked by the inclusion of a decimal point, the
exponential "e notation", or both. It is an optional sign, followed
by a mantissa consisting of digits, a decimal point, more digits, and then an