]> granicus.if.org Git - re2c/commit
Simplified POSIX disambiguation by reconstructing capture hierarchy.
authorUlya Trofimovich <skvadrik@gmail.com>
Fri, 19 May 2017 07:47:36 +0000 (08:47 +0100)
committerUlya Trofimovich <skvadrik@gmail.com>
Fri, 19 May 2017 07:47:36 +0000 (08:47 +0100)
commit733494c2e1399d753d0b8e3b32e852545923bbf2
tree5dd4c148591875b7fdb261735f02f8afb5d84518
parente53781621b4dda5e08ced984e9059b6a073eb9d5
Simplified POSIX disambiguation by reconstructing capture hierarchy.

POSIX treats captured and non-captured subexpressions on equal terms.
However, non-captured subexpressions have no tags to guard them.
Previously we used default tags to infer ambiguous paths that correspond
to the missing captures: if one path had default tag and the other did
not, then desicion which path is better was made according to the leftmost
strategy. This algorithm works because in POSIX expressions without
captures have the property that leftmost path is the best path (for
example, 'a?' is greedy, it means 'a or epsilon').

However, this algorithm has one downside: because we may need leftmost
comparison, we have to impose leftmost order on NFA substates of each
DFA state, as well as maximize and orbit order for tags. This prevents
us from mapping perfectly mappable DFA states and we end up with a larger
DFA (which is sometimes folded back to smaller DFA, but not always).

Also, default-leftmost algorithm is more complex than inserting missing
hierarchy pieces: proving that it works is non-trivial.
12 files changed:
re2c/bootstrap/src/ast/lex.cc
re2c/bootstrap/src/ast/parser.cc
re2c/src/ast/parser.ypp
re2c/src/code/emit_action.cc
re2c/src/dfa/closure.cc
re2c/src/dfa/determinization.cc
re2c/src/dfa/dump.cc
re2c/src/dfa/find_state.cc
re2c/src/re/ast_to_re.cc
re2c/src/re/fixed_tags.cc
re2c/src/re/tag.cc
re2c/src/re/tag.h