diff options
Diffstat (limited to 'parser.y')
-rw-r--r-- | parser.y | 14 |
1 files changed, 7 insertions, 7 deletions
@@ -453,17 +453,17 @@ regex : '/' regexpr '/' { $$ = $2; } yybadtoken(yychar, lit("regex")); } ; -regexpr : regbranch { $$ = $1; } - | regexpr '|' regexpr { $$ = list(list(or_s, $1, - $3, nao), nao); } - | regexpr '&' regexpr { $$ = list(list(and_s, $1, - $3, nao), nao); } +regexpr : regbranch { $$ = if3(cdr($1), + cons(compound_s, $1), + car($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); } | regterm regbranch { $$ = cons($1, $2); } - | '~' regbranch { $$ = cons(cons(compl_s, $2), nil); } ; regterm : '[' regclass ']' { $$ = cons(set_s, $2); } @@ -476,7 +476,7 @@ regterm : '[' regclass ']' { $$ = cons(set_s, $2); } | regterm '+' { $$ = list(oneplus_s, $1, nao); } | regterm '?' { $$ = list(optional_s, $1, nao); } | REGCHAR { $$ = chr($1); } - | '(' regexpr ')' { $$ = cons(compound_s, $2); } + | '(' regexpr ')' { $$ = $2; } | '(' error { $$ = nil; yybadtoken(yychar, lit("regex subexpression")); } |