From 326abeb3ee05d3c3dbf818c8393e466e8d961855 Mon Sep 17 00:00:00 2001 From: Justin Viiret Date: Thu, 10 Dec 2015 15:35:12 +1100 Subject: [PATCH] Perform an early removeRedundancy call on graph This allows sibling character classes to be merged together before graph component splitting is done by calcComponents(). In particular, this transforms (A|a)(B|b)(C|c) into [Aa][Bb][Cc] earlier. --- src/nfagraph/ng.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/nfagraph/ng.cpp b/src/nfagraph/ng.cpp index 7f866a66..75884181 100644 --- a/src/nfagraph/ng.cpp +++ b/src/nfagraph/ng.cpp @@ -402,6 +402,13 @@ bool NG::addGraph(NGWrapper &w) { dumpDotWrapper(w, "03_early", cc.grey); + // Perform a reduction pass to merge sibling character classes together. + if (cc.grey.performGraphSimplification) { + removeRedundancy(w, som); + } + + dumpDotWrapper(w, "04_reduced", cc.grey); + // If we've got some literals that span the graph from start to accept, we // can split them off into Rose from here. if (!som) {