From 681c02622c94ea17ebe417333e3dd078ee49ba5c Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Mon, 27 Jan 2014 22:52:08 -0800 Subject: 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. --- parser.l | 33 +++++++++++++-------------------- 1 file changed, 13 insertions(+), 20 deletions(-) (limited to 'parser.l') 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]; } -@[(\['] { - 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; - } +@ { + yylval.lineno = lineno; + return yytext[0]; } ,[*] { -- cgit v1.2.3