Code inside @members called two times.

8 views
Skip to first unread message

Mohan Radhakrishnan

unread,
Jul 15, 2016, 10:20:32 AM7/15/16
to antlr-discussion
What could be the reason for calling this code multiple times ? This is called two times.

@members {

static{
System.out.println(" Create Graph DB");
}

}

My code is this.

ANTLRInputStream ais = new ANTLRInputStream( new FileInputStream("file.java"));
JavaLexer jl = new JavaLexer(ais);
CommonTokenStream stream = new CommonTokenStream(jl);
JavaParser jp = new JavaParser( stream);
ParseTree pt = jp.compilationUnit();


ConfiguredRuleRegenerator rewriters = new ConfiguredRuleRegenerator( stream );
jp.addParseListener( rewriters );

ParseTreeWalker walker = new ParseTreeWalker();

/* walkers */
walker.walk(rewriters, pt);

Thanks,
Mohan

Eric Vergnaud

unread,
Jul 15, 2016, 2:52:20 PM7/15/16
to antlr-discussion
It is called once for the lexer and one once for the parser.
You can narrow the generation by specifying lexer::members or parser::members

Mohan Radhakrishnan

unread,
Jul 16, 2016, 9:11:09 AM7/16/16
to antlr-discussion
 Thanks. I was facing a DB lock issue when i tried to put the ParseTree nodes in neo4j.

Mohan
Reply all
Reply to author
Forward
0 new messages