diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2015-09-29 06:46:07 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2015-09-29 06:46:07 -0700 |
commit | 8843aff1cf55256596bce77e90532b1115e8547e (patch) | |
tree | d4adbd8fd2631869e2dab7a5b8b209fd5a134215 /regex.c | |
parent | d20e981aeec0413c01421920d80f5b077ba95769 (diff) | |
download | txr-8843aff1cf55256596bce77e90532b1115e8547e.tar.gz txr-8843aff1cf55256596bce77e90532b1115e8547e.tar.bz2 txr-8843aff1cf55256596bce77e90532b1115e8547e.zip |
Additional reductions for and.
* regex.c (reg_optimize): If the empty regex is and-ed with
another regex, that other regex must be nullable, otherwise
the and matches nothing. This is captured in some new
reductions for the and operator.
Diffstat (limited to 'regex.c')
-rw-r--r-- | regex.c | 6 |
1 files changed, 6 insertions, 0 deletions
@@ -1945,6 +1945,12 @@ static val reg_optimize(val exp) if (arg1 == t || arg2 == t) return t; + if (arg1 == nil) + return null(reg_nullable(arg2)); + + if (arg2 == nil) + return null(reg_nullable(arg1)); + if (reg_matches_all(arg1)) return arg2; |