]> granicus.if.org Git - re2c/commit
Fixed bug #115 "flex-style named definitions cause ambiguity in re2c grammar".
authorUlya Trofimovich <skvadrik@gmail.com>
Thu, 30 Jul 2015 14:11:03 +0000 (15:11 +0100)
committerUlya Trofimovich <skvadrik@gmail.com>
Thu, 30 Jul 2015 14:11:03 +0000 (15:11 +0100)
commite02b761a748833293b39fd69766f8073c0e6fe29
tree5486602fa4ac7f0e1999e3384abf1f9e032f4b37
parentc8c8426f1305d3e541c74229a504a32b62f490fe
Fixed bug #115 "flex-style named definitions cause ambiguity in re2c grammar".

This commit removes 10 shift/reduce conflicts in bison grammar for re2c.
These conflicts are caused by allowing flex-style named definitions
    name regular-expression
to contain newlines and to be mixed with rules. It's not just some
conflicts in LALR(1) grammar, it is genuine ambiguity as can be observed
from the following example:
    /*!re2c
        name "a"
        "b" "c" {}
    */
which can be parsed in two ways:
    definition -> name "a"
    rule -> "b" "c" {}
and
    definition -> name "a" "b"
    rule -> "c" {}
, both ways being perfectly valid.

This commit resolves ambiguity by forbidding newlines in flex-style
named definitions (conforming to flex syntax). Newline in these
definitions is treated in a special way: lexer emits token 'FID_END',
which marks the end of flex-style named definition in parser.
re2c/bootstrap/src/conf/parse_opts.cc
re2c/bootstrap/src/parse/scanner_lex.cc
re2c/src/parse/parser.ypp
re2c/src/parse/scanner.cc
re2c/src/parse/scanner.h
re2c/src/parse/scanner_lex.re