c# - Antlr 4 Lexer rule ambiguity -
so i'm building grammar parse c++
header files.
i have written grammar header files, , don't intend write implementation.
my problem if method implemented in header rather defined.
foo bar() { //some code };
i want match implementation of bar
block : '{' internal_block*? '}' ; fragment internal_block : block | ~('}') ;
but interferes other grammar includes { ... }
because match in between 2 braces. there anyway specify token use when there ambiguity?
p.s. don't know if grammar block
works gist.
so, significant parser rules be:
method : mtype mtypename lparen rparen block ; // simplified unknown : . ;
block tokens produced lexer not matched part of method rule appear in parse-tree in unknown context nodes. analyze method context nodes , ignore unknown nodes.
Comments
Post a Comment