summaryrefslogtreecommitdiffstats
path: root/parser.l
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2014-01-27 22:52:08 -0800
committerKaz Kylheku <kaz@kylheku.com>2014-01-27 22:52:08 -0800
commit681c02622c94ea17ebe417333e3dd078ee49ba5c (patch)
treeeacb631e69cc7b821b7d544319c86cd306a19d18 /parser.l
parent05c9d8a60d75f58655b75f2fda3f2696a56637e6 (diff)
downloadtxr-681c02622c94ea17ebe417333e3dd078ee49ba5c.tar.gz
txr-681c02622c94ea17ebe417333e3dd078ee49ba5c.tar.bz2
txr-681c02622c94ea17ebe417333e3dd078ee49ba5c.zip
Lexing and parsing improvements, leaving things less hacky than before,
albeit hacky. * parser.l (BSYM, NSYM): Regex definitions gone. (BT0, BT1, BT2, NT0, NT1, NT2): New regex definitions. (BTREG, BTKEY, NTREG, NTKEY): Rewritten, so that they cannot match a lone @ character as a symbol name. (grammar): Rules for returning METAPAR, METABKT and METAQUO are gone. Instead, we just recognize a @ in the NESTED and BRACED states and return it as a token. * parser.y (METAPAR, METABKT, METAQUO): Token types removed. (meta_expr): Nonterminal symbol removed. ('@'): New token type. (list): Quotes and splices handling removed from this rule. The new token '@' is handled here, on the other hand, because there are places that reference the list rule that need to support @ expressions. (n_expr): Reference to meta_expr removed. Quote, unquote and splice added here. (yybadtoken): Removed references to METAPAR, METABKT and METAQUO.
Diffstat (limited to 'parser.l')
-rw-r--r--parser.l33
1 files changed, 13 insertions, 20 deletions
diff --git a/parser.l b/parser.l
index cc348cc2..39a825a3 100644
--- a/parser.l
+++ b/parser.l
@@ -157,16 +157,20 @@ 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}
-BTREG ({BSYM}|@)({BSYM}|#)*(:({BSYM}|#)*)?
-BTKEY @?:({BSYM}|#)*
+BT0 {BSCHR}({BSCHR}|#)*
+BT1 @({BSCHR}|#)+
+BT2 ({BSCHR}|#)+
+BTREG (({BT0}|{BT1})?:{BT2}|({BT0}|{BT1})(:{BT2})?|:)
+BTKEY @?:{BT2}?
BTOK {BTREG}|{BTKEY}
-NTREG ({NSYM}|@)({NSYM}|#)*(:({NSYM}|#)*)?
-NTKEY @?:({NSYM}|#)*
+NT0 {NSCHR}({NSCHR}|#)*
+NT1 @({NSCHR}|#)+
+NT2 ({NSCHR}|#)+
+NTREG (({NT0}|{NT1})?:{NT2}|({NT0}|{NT1})(:{NT2})?|:)
+NTKEY @?:{NT2}?
NTOK {NTREG}|{NTKEY}
WS [\t ]*
HEX [0-9A-Fa-f]
@@ -438,20 +442,9 @@ UONLY {U2}{U}|{U3}{U}{U}|{U4}{U}{U}{U}
return yytext[0];
}
-<NESTED,BRACED>@[(\['] {
- yylval.chr = yytext[1];
- yylval.lineno = lineno;
- switch (yytext[1]) {
- case '(':
- yy_push_state(NESTED);
- return METAPAR;
- case '[':
- yy_push_state(NESTED);
- return METABKT;
- default:
- case '\'':
- return METAQUO;
- }
+<NESTED,BRACED>@ {
+ yylval.lineno = lineno;
+ return yytext[0];
}
<NESTED>,[*] {