summaryrefslogtreecommitdiffstats
path: root/parser.y
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2010-01-15 16:33:51 -0800
committerKaz Kylheku <kaz@kylheku.com>2010-01-15 16:33:51 -0800
commit9d24c8a35c07201d3d947332a66cb148af4c24c9 (patch)
tree6f644109e45b68cad73ed1a8db8710c837243b0a /parser.y
parent5eab77fcd428e89303521df2830cdc0951672348 (diff)
downloadtxr-9d24c8a35c07201d3d947332a66cb148af4c24c9.tar.gz
txr-9d24c8a35c07201d3d947332a66cb148af4c24c9.tar.bz2
txr-9d24c8a35c07201d3d947332a66cb148af4c24c9.zip
Implemented non-greedy operator.
Diffstat (limited to 'parser.y')
-rw-r--r--parser.y8
1 files changed, 6 insertions, 2 deletions
diff --git a/parser.y b/parser.y
index a7773c08..3bc6253a 100644
--- a/parser.y
+++ b/parser.y
@@ -80,8 +80,8 @@ static val parsed_spec;
%right IDENT TEXT NUMBER
%left '^'
%left '|' '/'
-%left '&'
-%right '~' '*' '?' '+'
+%left '&'
+%right '~' '*' '?' '+' '%'
%right '.' '\\' REGCHAR LITCHAR
%%
@@ -477,6 +477,7 @@ regterm : '[' regclass ']' { $$ = cons(set_s, $2); }
| 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); }
| REGCHAR { $$ = chr($1); }
| '(' regexpr ')' { $$ = $2; }
| '(' error { $$ = nil;
@@ -505,6 +506,9 @@ regchar : '?' { $$ = '?'; }
| ')' { $$ = ')'; }
| '^' { $$ = '^'; }
| '|' { $$ = '|'; }
+ | '~' { $$ = '~'; }
+ | '&' { $$ = '&'; }
+ | '%' { $$ = '%'; }
| '/' { $$ = '/'; }
| REGCHAR { $$ = $1; }
;