From b553f54bca43cda8ac0eaca5c21469dd36415d2b Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Tue, 5 Jan 2010 18:27:50 -0800 Subject: 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. --- parser.l | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'parser.l') 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"); } -[.*?+^] { - yylval.chr = yytext[0]; - return yytext[0]; - } +[.*?+^~&] { + yylval.chr = yytext[0]; + return yytext[0]; + } [\[\]\-] { -- cgit v1.2.3