]> granicus.if.org Git - re2c/commit
Fold output expressions in a separate pass over the output.
authorUlya Trofimovich <skvadrik@gmail.com>
Fri, 30 Dec 2016 17:15:16 +0000 (17:15 +0000)
committerUlya Trofimovich <skvadrik@gmail.com>
Fri, 30 Dec 2016 17:15:16 +0000 (17:15 +0000)
commit2d73eb3c3ac9183354a94c1569829352dc99060d
treee7ad3423b6abc50e4dc605d5dd9aaecc77460e73
parenta698ea6145a200890f222ce7545ff34d7c5aeede
Fold output expressions in a separate pass over the output.

re2c folds sequences of simple statements to complex tatements, e.g.:
    ++YYCURSOR;
    yych = *YYCURSOR;
is folded to:
    yych = *++YYCURSOR;

It is hard to fold expressions on the fly (at the time they are generated),
because one needs to forsee all the cases in advance. Some cases cannot be
anticipated (e.g. if substatements belong to different states, which is often
the case), so many statements remain unfolded.

This commit separates code generation and folding by delaying output of
skip, peek and backup primitives. Folding now is done in a separate pass
when all the substatements are already known.
60 files changed:
re2c/bootstrap/src/conf/parse_opts.cc
re2c/bootstrap/src/parse/lex_conf.cc
re2c/src/codegen/emit_action.cc
re2c/src/codegen/emit_dfa.cc
re2c/src/codegen/input_api.cc
re2c/src/codegen/input_api.h
re2c/src/codegen/output.cc
re2c/src/codegen/output.h
re2c/src/conf/opt.cc
re2c/src/conf/opt.h
re2c/src/conf/parse_opts.re
re2c/src/ir/compile.cc
re2c/src/ir/nfa/nfa.cc
re2c/src/ir/nfa/nfa.h
re2c/src/ir/nfa/regexps2nfa.cc
re2c/src/parse/lex_conf.re
re2c/test/bug1682718.c
re2c/test/bug1682718.is.c
re2c/test/bug57.c
re2c/test/bug57_original.bi--case-insensitive.c
re2c/test/calc_006.s.c
re2c/test/calc_007.b.c
re2c/test/calc_008.b.c
re2c/test/condtype_yysetcondition.cg.c
re2c/test/condtype_yysetcondition.cs.c
re2c/test/config6.c
re2c/test/control_flow_fail.c
re2c/test/control_flow_ok.c
re2c/test/control_flow_yymarker_fail.c
re2c/test/control_flow_yymarker_ok.c
re2c/test/control_flow_yymarker_yyaccept_fail.c
re2c/test/control_flow_yymarker_yyaccept_ok.c
re2c/test/default.8.c
re2c/test/default.c
re2c/test/default.e.c
re2c/test/default.u.c
re2c/test/default.w.c
re2c/test/default.x.c
re2c/test/default_dup_star_1.ic.c
re2c/test/default_full.c
re2c/test/default_full.e.c
re2c/test/default_full.u.c
re2c/test/default_full.w.c
re2c/test/input4.--empty-class(match-empty).c
re2c/test/input4.--empty-class(match-none).c
re2c/test/input4.c
re2c/test/input6.--empty-class(match-empty).c
re2c/test/input6.--empty-class(match-none).c
re2c/test/input6.c
re2c/test/php20150211_json_scanner.igc.c
re2c/test/range_full.c
re2c/test/range_full.e.c
re2c/test/range_full.u.c
re2c/test/range_full.w.c
re2c/test/tags/fix3.i--tags.c
re2c/test/tags/fix3_trail.i--tags.c
re2c/test/tags/fix4.i--tags.c
re2c/test/tags/fix4_trail.i--tags.c
re2c/test/tags/fix5.i--tags.c
re2c/test/tags/fix5_trail.i--tags.c