antlr - ANTLR4: Error when I try to find which parser subrule matched -


i've got parser rule this, , need know subrule matched:

dt returns [dt v] :    (d1=date t1=time?|t2=time d2=date?)                  {if ($d1 == null) // right side matched ... } ; 

i antlr4 error message: "missing attribute access on rule reference 'd1' in '$d1'".

i can rid of error putting e.g. $d1.v, nullpointerexception @ runtime in antlr-generated code at

if (((dtrcontext)_localctx).d1.v != null) 

because _localctx.d1 null, _localtx.d1.v uses null ptr.

any ideas on how can resolve impass?

the context object d1 (parse tree node of type datecontext) can referenced $d1.ctx. equivalent assuming $d1 alone do.


Comments

Popular posts from this blog

curl - PHP fsockopen help required -

HTTP/1.0 407 Proxy Authentication Required PHP -

c# - Resource not found error -