diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2010-01-05 18:27:50 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2010-01-05 18:27:50 -0800 |
commit | b553f54bca43cda8ac0eaca5c21469dd36415d2b (patch) | |
tree | f2ccf026256a0cc8ee869ab62f1e964872c50a23 /parser.l | |
parent | cd5959194340d95f08abf8230d7f5e5a72728eb9 (diff) | |
download | txr-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.l | 8 |
1 files changed, 4 insertions, 4 deletions
@@ -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>[\[\]\-] { |