summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog12
-rw-r--r--parser.y4
2 files changed, 14 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index f71577ca..56ae1379 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2010-01-06 Kaz Kylheku <kkylheku@gmail.com>
+
+ Some fine tuning in regex grammar.
+
+ * parser.y (regex): Empty regex handled by
+ allowing regex to generate empty, rather than
+ a special case production for '/' '/'. Thus
+ empty subexpressions are possible.
+ (regbranch, regterm): Complement is handled
+ in regbranch, so that it has lower precedence
+ than aggregation.
+
2010-01-05 Kaz Kylheku <kkylheku@gmail.com>
Implemented the regular expression ~ and & operators.
diff --git a/parser.y b/parser.y
index 51386217..cc0815c8 100644
--- a/parser.y
+++ b/parser.y
@@ -449,7 +449,6 @@ expr : IDENT { $$ = intern(string_own($1), nil); }
;
regex : '/' regexpr '/' { $$ = $2; }
- | '/' '/' { $$ = nil; }
| '/' error { $$ = nil;
yybadtoken(yychar, lit("regex")); }
;
@@ -459,10 +458,12 @@ regexpr : regbranch { $$ = $1; }
$3, nao), nao); }
| regexpr '&' regexpr { $$ = list(list(and_s, $1,
$3, nao), 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); }
@@ -474,7 +475,6 @@ 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 { $$ = list(compl_s, $2, nao); }
| REGCHAR { $$ = chr($1); }
| '(' regexpr ')' { $$ = cons(compound_s, $2); }
| '(' error { $$ = nil;