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

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -