質問

I am new to Antlr and my setup is as follows: Windows 7, Java JDK 1.7.0_17, AntlrWorks 1.5, Antlr 3.5.

The AntlrWorks Help-About shows the following information:

ANTLRWorks 1.5
ANTLR 3.5
StringTemplate v3 3.2.1
StringTemplate v4 4.0.7-SNAPSHOT
Java 1.7.0_17 (Oracle Corporation)

Chapter 3 of the Definitive Antlr Reference book introduces a sample grammar for expression evaluation (Expr.g), which I downloaded from the hyperlink in the PDF version of the book.

The book recomends using AntlrWorks and I am, however when I Generate Code (Ctrl+Shift+G) in AntlrWorks it produces code without the "throws" clause.

For example, the following is generated in AntlrWorks:

// $ANTLR start "prog"
// C:\\Users\\Mark\\Documents\\output\\Expr.g:12:1: prog : ( stat )+ ;
public final void prog() throws  {
    try {

Note the missing code after the throws keyword...

If I generate from the command prompt using this command line:
java -cp antlr-3.5-complete.jar org.antlr.Tool Expr.g

I get this output:

// $ANTLR start "prog"
// Expr.g:12:1: prog : ( stat )+ ;
public final void prog() throws RecognitionException {
    try {

My question is this - how do I get AntlrWorks to generate the same code?

役に立ちましたか?

解決

This is a known issue in ANTLRWorks 1.5 which has been resolved for the next release.

#5: ANTLRworks fails to generate proper Java Code

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top