json to g4 only with "parser" cause some syntax error #43
Labels
bug
Something isn't working
enhancement
New feature or request
help wanted
Extra attention is needed
In my experimental environment, I found json to g4 only with "parser" cause some syntax error, syntax parsing errors may lead to the possibility of losing a large amount of mutated data.
I made mincase
lex.json
:Grammar-Mutator
make
it, generateGrammar.g4
is:we prepared input data
seed1 / seed2
, and useantlr4-parse
to testing:why is
10(10)
parsed incorrectly? because antlr4 is divided into two stages: lexer and parser. during lexer stage,node_NUMBER:10
will be recognized as TOKEN, and in the parser stage, the result isnode_NUMBER (node_NUMBER)
, so an error occurred.in the antlr4 grammar, lex rules begin with an uppercase letter, parser rules begin with a lowercase letter, so we should tell antlr4 the lexical rules clearly, patch
Grammar_patch.g4
:testing again:
maybe we can optimize the json to g4 generation code, to distinguish between lexer and parser?
The text was updated successfully, but these errors were encountered: