[antlr-interest] What's wrong with org.antlr.Tool.main(String[] args)?

John B. Brodie jbb at acm.org
Tue May 25 12:54:23 PDT 2010


On Tue, 2010-05-25 at 21:12 +0200, Sameh W. Zaky wrote:
> Hi all,
> 
> Using ANTLR v3.2, in the runtime I generate the lexer and parser Java files
> using this code:
> org.antlr.Tool.main(new String[]{projectPath+"GrammarFile.g"});
> 
> The problem is that, after this line of code, no other code gets executed,
> for example, in this piece of code:
> System.out.println("Before");
> org.antlr.Tool.main(new String[]{projectPath+"GrammarFile.g"});
> System.out.println("After");
> 
> Output: "Before" will be printed, the lexer and parser will be generated,
> BUT "After" will NOT be printed..
> Using Java Graphical User Interface, whenever I call this line of code in my
> application, it indeed creates the lexer and parser but then the application
> freezes..
> 
> Any idea why this happens? Or how I can avoid it?
> 

the main may call System.exit() ....

have you looked at how ANTLRWorks does this?

a *VERY* quick scan of the github sources gives us the file

main/src/org/antlr/works/generate/CodeGenerate.java

which contains the method generate() which seems to do the invocation of
the Tool.

as I say I did not spend any time trying to understand what is really
happening in that method so it may be a complete waste of time....

hope this helps
   -jbb




More information about the antlr-interest mailing list