Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Restrict lexical contexts where
%{
is recognized as a block start.
As Krishna noticed in bug #392 "Cannot compile when user c string has a special pattern", `%{` in the middle of a string makes re2c think that this is a start of a re2c block. The user has to braek the string in two in order to separate `%` from `{`. The problem is exacerbated by the fact that `%{` does not require -F, --flex-support option. It affects all re2c programs. In general re2c cannot be sure if `%{` appears in the middle of a string, a comment, a macro defintion or some other lexical context where it is a part of a larger lexeme and not a standalone block start marker. This is because re2c doesn't parse user-defined code in-between re2c blocks (doing that would require implementing multiple language frontends in re2c, which is out of the question). This commit mitigates the problem in #392 by restricting lexical context wheer `%{` is recognized as a block start: the marker must be on a new line, optionally preceded by whitespace characters. This does not cover all the cases and it may break some re2c programs that used block start `%{` in other lexical contexts, but it is a reasonable compromise between usability and backards compatibility.
- Loading branch information