antlr4
antlr4 copied to clipboard
Refactoring of grammar literals parsing
Code for parsing grammar string literals 'abc'
and grammar char set [abc]
have a lot of in common and I unified it. I extracted the functionality into GrammarLiteralParser
that is responsible for parsing from string literals and char sets. It has the following methods:
-
parseStringFromStringLiteral
-
parseCharFromStringLiteral
(returnsCharParseResult
) -
parseChar
(returnsCharParseResult
) -
parseNextChar
(returnsCharParseResult
)
CharParseResult
can be either INVALID
or CODE_POINT
or PROPERTY
. PROPERTY
is supported only by char set.
Also, I unraveled ANTLR tool and ANTLR runtime functionality of char processing.
@parrt it's also ready. Tool tests will be fine after #3779
Hmm...pretty risky modifying the ATN construction...
Can you help me understand the prime motivation here? There's a lot to review and a lot of changes that could affect allow users, because it touches the tool itself.
Can you help me understand the prime motivation here? There's a lot to review and a lot of changes that could affect allow users, because it touches the tool itself.
I decided to rebase and suggest my old commits since they exist, remove code duplication (more removed lines than added) and fix inaccurancy in error messages (see tests). Our test coverage is good enough especially for the tool. Error messages without location look akward.
I've touched the tool several times, and it almost hasn't cause any trouble.
I'm going to leave this active as it could be useful but I'm allocating my time to antlr-as-a-service proj at moment. thanks!