diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2014-02-24 08:03:59 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2014-02-24 19:17:30 -0800 |
commit | 501453a261771e2874bd065a78772e987616b14c (patch) | |
tree | 569029b676c1df641959e14528a0d28303593f5e | |
parent | fd795adb279719bf77a7a6333b1e97500c454964 (diff) | |
download | txr-501453a261771e2874bd065a78772e987616b14c.tar.gz txr-501453a261771e2874bd065a78772e987616b14c.tar.bz2 txr-501453a261771e2874bd065a78772e987616b14c.zip |
* parser.l: Support octal and binary numbers.
* txr.1: Documented.
* genvim.txr, txr.vim: Updated.
-rw-r--r-- | ChangeLog | 8 | ||||
-rw-r--r-- | genvim.txr | 2 | ||||
-rw-r--r-- | parser.l | 44 | ||||
-rw-r--r-- | txr.1 | 9 | ||||
-rw-r--r-- | txr.vim | 2 |
5 files changed, 65 insertions, 0 deletions
@@ -1,5 +1,13 @@ 2014-02-24 Kaz Kylheku <kaz@kylheku.com> + * parser.l: Support octal and binary numbers. + + * txr.1: Documented. + + * genvim.txr, txr.vim: Updated. + +2014-02-24 Kaz Kylheku <kaz@kylheku.com> + * parser.y (modifiers): Bugfix: list element not subject to expansion of Lisp forms denoted by @. (expand_meta): Bugfix: failure to expand vars, which can be @@ -85,6 +85,8 @@ syn match txr_ncomment ";.*" contained syn match txr_dot "\." contained syn match txr_num "#x[+\-]\?[0-9A-Fa-f]\+" contained +syn match txr_num "#o[+\-]\?[0-7]\+" contained +syn match txr_num "#b[+\-]\?[0-1]\+" contained syn match txr_num "[+\-]\?[0-9]\+" contained syn match txr_ident "[:@@]\?[A-Za-z0-9!$%&*+\-<=>?\\^_~]*[A-Za-z!$%&*+\-<=>?\\^_~][A-Za-z0-9!$%&*+\-<=>?\\^_~]*" contained syn match txl_ident "[:@@]\?[A-Za-z0-9!$%&*+\-<=>?\\^_~/]*[A-Za-z!$%&*+\-<=>?\\^_~/][A-Za-z0-9!$%&*+\-<=>?\\^_~/]*" contained @@ -156,6 +156,8 @@ NUM {SGN}?{DIG}+ FLO {SGN}?({DIG}*[.]{DIG}+{EXP}?|{DIG}+[.]?{EXP}) FLODOT {SGN}?{DIG}+[.] XNUM #x{SGN}?{XDIG}+ +ONUM #o{SGN}?[0-7]+ +BNUM #b{SGN}?[0-1]+ BSCHR [a-zA-Z0-9!$%&*+\-<=>?\\^_~] NSCHR [a-zA-Z0-9!$%&*+\-<=>?\\^_~/] ID_END [^a-zA-Z0-9!$%&*+\-<=>?\\^_~/] @@ -213,6 +215,28 @@ UONLY {U2}{U}|{U3}{U}{U}|{U4}{U}{U}{U} return NUMBER; } +<SPECIAL,NESTED,BRACED>{ONUM} { + 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(8)); + return NUMBER; +} + +<SPECIAL,NESTED,BRACED>{BNUM} { + 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(2)); + return NUMBER; +} + <SPECIAL>({FLO}|{FLODOT}){TOK} | <BRACED>({FLO}|{FLODOT}){BTOK} | <NESTED>({FLO}|{FLODOT}){NTOK} { @@ -270,6 +294,26 @@ UONLY {U2}{U}|{U3}{U}{U}|{U4}{U}{U}{U} return METANUM; } +<NESTED,QSILIT>@{ONUM} { + 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(8)); + return METANUM; +} + +<NESTED,QSILIT>@{BNUM} { + 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(2)); + return METANUM; +} + <SPECIAL>{TOK} | <BRACED>{BTOK} | <NESTED>{NTOK} { @@ -1152,6 +1152,15 @@ and the upper or lower case letters A through F: #xFF ;; 255 #x-ABC ;; -2748 +Similarly, octal numbers are supported with the prefix #o followed by +octal digits: + + #b777 ;; 511 + +and binary numbers can be written with a #b prefix: + + #b1110 ;; 14 + 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 @@ -184,6 +184,8 @@ syn match txr_ncomment ";.*" contained syn match txr_dot "\." contained syn match txr_num "#x[+\-]\?[0-9A-Fa-f]\+" contained +syn match txr_num "#o[+\-]\?[0-7]\+" contained +syn match txr_num "#b[+\-]\?[0-1]\+" contained syn match txr_num "[+\-]\?[0-9]\+" contained syn match txr_ident "[:@]\?[A-Za-z0-9!$%&*+\-<=>?\\^_~]*[A-Za-z!$%&*+\-<=>?\\^_~][A-Za-z0-9!$%&*+\-<=>?\\^_~]*" contained syn match txl_ident "[:@]\?[A-Za-z0-9!$%&*+\-<=>?\\^_~/]*[A-Za-z!$%&*+\-<=>?\\^_~/][A-Za-z0-9!$%&*+\-<=>?\\^_~/]*" contained |