summaryrefslogtreecommitdiffstats
path: root/parser.l
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2010-01-05 18:27:50 -0800
committerKaz Kylheku <kaz@kylheku.com>2010-01-05 18:27:50 -0800
commitb553f54bca43cda8ac0eaca5c21469dd36415d2b (patch)
treef2ccf026256a0cc8ee869ab62f1e964872c50a23 /parser.l
parentcd5959194340d95f08abf8230d7f5e5a72728eb9 (diff)
downloadtxr-b553f54bca43cda8ac0eaca5c21469dd36415d2b.tar.gz
txr-b553f54bca43cda8ac0eaca5c21469dd36415d2b.tar.bz2
txr-b553f54bca43cda8ac0eaca5c21469dd36415d2b.zip
Implemented the regular expression ~ and & operators.
This turns out to be easy to do in NFA land. The complement of an NFA has exactly the same number and configuration of states and transitions, except that the states have an inverted meaning; and furthermore, failed character transitions are routed to an extra state (which in this impelmentation is permanently allocated and shared by all regexes). The regex & is implemented trivially using DeMorgan's. Also, bugfix: regular expressions like A|B|C are allowed now by the syntax, rather than constituting syntax error. Previously, this would have been entered as (A|B)|C.
Diffstat (limited to 'parser.l')
-rw-r--r--parser.l8
1 files changed, 4 insertions, 4 deletions
diff --git a/parser.l b/parser.l
index dcb45ea9..e0c0f2d5 100644
--- a/parser.l
+++ b/parser.l
@@ -444,10 +444,10 @@ UONLY {U2}{U}|{U3}{U}{U}|{U4}{U}{U}{U}
yyerror("newline in regex");
}
-<REGEX>[.*?+^] {
- yylval.chr = yytext[0];
- return yytext[0];
- }
+<REGEX>[.*?+^~&] {
+ yylval.chr = yytext[0];
+ return yytext[0];
+ }
<REGEX>[\[\]\-] {