Acessing fields within rule - ANtlr4 -
i have rule have declaration returns
tablename returns [string fieldstring, tableobj obj]
tableobj custom class declare in same g4 file
class tableobj { public string realname; public string aliasname; public list<string> fields; public list<relation> relations; public tableobj(){ fields = new arraylist<string>(); relations = new arraylist<relation>(); } }
but when have try access field of obj using $obj.field generated code is:
_localctx.field
instead of
_localctx.obj.field
how do obtain second form instead of first?
if need or follows snippet of rule
tablename returns [string fieldstring, tableobj obj] : (tableprefix=id { $obj.aliasname = $tableprefix.text; system.out.println( "alias = " + $tableprefix.text + " " + $obj.aliasname ); } ;
this bug in antlr should report project issue tracker: https://github.com/antlr/antlr4/issues
Comments
Post a Comment