summaryrefslogtreecommitdiffstats
path: root/parser.y
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2014-08-11 22:01:59 -0700
committerKaz Kylheku <kaz@kylheku.com>2014-08-11 22:01:59 -0700
commit17c43f985b8c707e997fe65a20ce31430f51bb36 (patch)
treee607df7e43896557804c3600f263c72748f60639 /parser.y
parent7876104ee7e73c190b67e90a87fe5a44f40c4af6 (diff)
downloadtxr-17c43f985b8c707e997fe65a20ce31430f51bb36.tar.gz
txr-17c43f985b8c707e997fe65a20ce31430f51bb36.tar.bz2
txr-17c43f985b8c707e997fe65a20ce31430f51bb36.zip
First cut at restructuring how variable matching works in the pattern
language. The goal is to remove the strict behavior of using only one element of context after a variable. variable form at parse time: we unravel that first. * parser.y (grammar): Simplifying the phrase structure rule for the var element. All the variants that have a trailing elem are removed. The abstract syntax changes; the modifier moves to the third position in the list. * match.c (h_var): Matching change: the element which follows a variable is now pulled from the specline rather than the variable syntax, which is how it should have been done in the first place. The modifiers are pulled from a different spot in the variable syntax.
Diffstat (limited to 'parser.y')
-rw-r--r--parser.y21
1 files changed, 3 insertions, 18 deletions
diff --git a/parser.y b/parser.y
index 37e066cc..b8fdbbd9 100644
--- a/parser.y
+++ b/parser.y
@@ -644,25 +644,10 @@ rep_parts_opt : SINGLE o_elems_opt
* that generates an empty phrase causes reduce/reduce conflicts.
*/
var : SYMTOK { $$ = list(var_s, symhlpr($1, nil), nao); }
- | SYMTOK elem { $$ = list(var_s, symhlpr($1, nil),
- $2, nao); }
| '{' SYMTOK '}' { $$ = list(var_s, symhlpr($2, nil), nao); }
- | '{' SYMTOK '}' elem { $$ = list(var_s, symhlpr($2, nil),
- $4, nao); }
- | '{' SYMTOK modifiers '}' { $$ = list(var_s, symhlpr($2, nil),
- nil, $3, nao); }
- | '{' SYMTOK modifiers '}' elem
- { $$ = list(var_s, symhlpr($2, nil),
- $5, $3, nao); }
- | var_op SYMTOK { $$ = list(var_s, symhlpr($2, nil),
- nil, $1, nao); }
- | var_op SYMTOK elem { $$ = list(var_s, symhlpr($2, nil),
- $3, $1, nao); }
- | var_op '{' SYMTOK '}' { $$ = list(var_s, symhlpr($3, nil),
- nil, $1, nao); }
- | var_op '{' SYMTOK '}' elem
- { $$ = list(var_s, symhlpr($3, nil),
- $5, $1, nao); }
+ | '{' SYMTOK modifiers '}' { $$ = list(var_s, symhlpr($2, nil), $3, nao); }
+ | var_op SYMTOK { $$ = list(var_s, symhlpr($2, nil), $1, nao); }
+ | var_op '{' SYMTOK '}' { $$ = list(var_s, symhlpr($3, nil), $1, nao); }
| var_op '{' SYMTOK regex '}' { $$ = nil;
yyerr("longest match "
"not useable with regex"); }