From 8843aff1cf55256596bce77e90532b1115e8547e Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Tue, 29 Sep 2015 06:46:07 -0700 Subject: 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. --- regex.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/regex.c b/regex.c index 3943d93a..823f0c4e 100644 --- a/regex.c +++ b/regex.c @@ -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; -- cgit v1.2.3