c# - NoViableAltException in Antlr4.3 grammar -
problem
i started using antlr (4.3 .net) , after debugging quite while, have surrender. noviablealtexception
in last 4 lines - have no idea how fix ...
so have hints me?
supposed behavior
the generated parser supposed parse strings hello {user.name}!
or hello {{ {user.name("}")} }}!
user.name
, user.name("}")
expected derive expression
rule , else plainstring
. however, not yet able test ...
grammar
grammar patternstring; @namespace{patternstringparser.antlrgenerated} patternstring: (plainstring | expressionstring)+; plainstring: (plainstringliteral | '""' | '{{' | '}}' )+; expressionstring: '{' expression* '}'; expression: balancedstringliteral+ | '(' expression ')' | '[' expression ']' | '{' expression '}' | '"' string '"' | '\'' character '\''; string: (stringliteral | '\\"')+; character: (characterliteral | '\'' )+; plainstringliteral: ~[\"\{\}]; // <= noviablealtexception balancedstringliteral: ~[\"\{\(\[\']; // <= noviablealtexception characterliteral: ~[\']; // <= noviablealtexception stringliteral: ~[\"]; // <= noviablealtexception
to analyze kind of problem, dump token stream see lexer doing. dump tokens, see answer - in java, c# implementation should quite similar.
Comments
Post a Comment