diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2010-01-19 14:43:40 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2010-01-19 14:43:40 -0800 |
commit | da3ffa806c910ba2d03dcca145eea52b90ebdbdf (patch) | |
tree | 39ea11c9d746df8307a4f3353bb9ce610269ace8 /parser.y | |
parent | 667a0b7d777cfdd479f260f32e5344c28ebb30a1 (diff) | |
download | txr-da3ffa806c910ba2d03dcca145eea52b90ebdbdf.tar.gz txr-da3ffa806c910ba2d03dcca145eea52b90ebdbdf.tar.bz2 txr-da3ffa806c910ba2d03dcca145eea52b90ebdbdf.zip |
Resolving parser conflicts.
Diffstat (limited to 'parser.y')
-rw-r--r-- | parser.y | 37 |
1 files changed, 20 insertions, 17 deletions
@@ -74,11 +74,12 @@ static val parsed_spec; %type <obj> regterm regclass regclassterm regrange %type <obj> strlit chrlit quasilit quasi_items quasi_item litchars %type <chr> regchar +%nonassoc LOW /* used for precedence assertion */ %nonassoc ALL SOME NONE MAYBE CASES AND OR END COLLECT UNTIL COLL %nonassoc OUTPUT REPEAT REP FIRST LAST EMPTY DEFINE %nonassoc '{' '}' '[' ']' '(' ')' %right IDENT TEXT NUMBER -%left '^' +%left '-' %left '|' '/' %left '&' %right '~' '*' '?' '+' '%' @@ -450,6 +451,7 @@ expr : IDENT { $$ = intern(string_own($1), nil); } ; regex : '/' regexpr '/' { $$ = $2; end_of_regex(); } + | '/' '/' { $$ = nil; end_of_regex(); } | '/' error { $$ = nil; yybadtoken(yychar, lit("regex")); end_of_regex(); } @@ -461,37 +463,39 @@ regexpr : regbranch { $$ = if3(cdr($1), | regexpr '|' regexpr { $$ = list(or_s, $1, $3, nao); } | regexpr '&' regexpr { $$ = list(and_s, $1, $3, nao); } | '~' regexpr { $$ = list(compl_s, $2, nao); } - | /* empty */ { $$ = nil; } ; -regbranch : regterm { $$ = cons($1, nil); } +regbranch : regterm %prec LOW { $$ = cons($1, nil); } | regterm regbranch { $$ = cons($1, $2); } ; -regterm : '[' regclass ']' { $$ = cons(set_s, $2); } - | '[' '^' regclass ']' { $$ = if3(nullp($3), wild_s, - cons(cset_s, $3)); } - | '.' { $$ = wild_s; } - | '^' { $$ = chr('^'); } - | ']' { $$ = chr(']'); } - | '-' { $$ = chr('-'); } - | regterm '*' { $$ = list(zeroplus_s, $1, nao); } +regterm : regterm '*' { $$ = list(zeroplus_s, $1, nao); } | regterm '+' { $$ = list(oneplus_s, $1, nao); } | regterm '?' { $$ = list(optional_s, $1, nao); } | regterm '%' regexpr { $$ = list(nongreedy_s, $1, $3, nao); } + | '[' regclass ']' { if (first($2) == chr('^')) + { if (rest($2)) + $$ = cons(cset_s, rest($2)); + else + $$ = wild_s; } + else + $$ = cons(set_s, $2); } + | '[' ']' { $$ = cons(set_s, nil); } + | '[' error { $$ = nil; + yybadtoken(yychar, + lit("regex character class")); } + | '.' { $$ = wild_s; } + | ']' { $$ = chr(']'); } + | '-' { $$ = chr('-'); } | REGCHAR { $$ = chr($1); } | '(' regexpr ')' { $$ = $2; } | '(' error { $$ = nil; - yybadtoken(yychar, + yybadtoken(yychar, lit("regex subexpression")); } - | '[' error { $$ = nil; - yybadtoken(yychar, - lit("regex character class")); } ; regclass : regclassterm { $$ = cons($1, nil); } | regclassterm regclass { $$ = cons($1, $2); } - | /* empty */ { $$ = nil; } ; regclassterm : regrange { $$ = $1; } @@ -506,7 +510,6 @@ regchar : '?' { $$ = '?'; } | '+' { $$ = '+'; } | '(' { $$ = '('; } | ')' { $$ = ')'; } - | '^' { $$ = '^'; } | '|' { $$ = '|'; } | '~' { $$ = '~'; } | '&' { $$ = '&'; } |