[antlr-interest] Questions to Java.g

mail.acc at freenet.de mail.acc at freenet.de
Sun Jul 15 04:27:11 PDT 2007


Hi,
I have got two questions to the Java.g grammar.

1st:
I am very impressed by the precise error description of ANTLR when it applies "Recovery bysingle deletion" or "Recovery by single insertion", but I tested it with a special input, which is not valid Java (the keyword "import" is mising), and ANTLR reported not a single error. It, however , doesn't execute the actions which I inserted when it finds an block statement.
Because it is the first Token missing I dare say this isn't the same situation as described in "Recovery by single insertion" in the book, but...
Shouldn't there be at least an error message: "line 1:0 something is wrong", that I can pass to the user?
---------------------
 java.io.*;
  public class Code {
    public void doSomething() {
    int i = 0;
  }
}
---------------------


2nd:
I made further tests with this grammar and by chance noticed something weird. This time I have an valid Java file, but Java.g reported an lexer-error (at least I think it is an lexer-error). But it occurs only in this special situation.
If the last line of the file ends with an single line comment, and if there is no newline after this, I get the following error:
> line 2:12 mismatched character '<EOF>' expecting 'n'
Input:
---------------------
public class Code {}
// End Class
---------------------


I would be grateful if anyone can help me especially with the first question.

Best wishes from Germany
Andreas










More information about the antlr-interest mailing list