[antlr-interest] Trouble with ANTLR 3 grammar
Emond Papegaaij
e.papegaaij at student.utwente.nl
Thu Jun 29 02:01:16 PDT 2006
Hello,
I'm still working on an ANTLR 3 grammar. However I'm having trouble with
version b1. In my lexer I've got several tokens that match almost everything.
These tokens are guarded with semantic predicates. Due to these tokens, I
have to use filtered mode (else ANTLR will run out of memory trying to
construct the DFA). This used to work fine, however with b1 my parser seems
to receive whitespace tokens:
[specification, nodeDecl]: line 1:9 mismatched token: [@1,9:9=' ',<12>,1:9];
expecting type L_CURLY
These tokens are sent to channel=99. Disabling filtered mode now gives the
following error:
tpl2.g:1:10: ANTLR could not analyze this decision in rule Tokens; often this
is because of recursive rule references visible from the left edge of
alternatives. ANTLR will re-analyze the decision with a fixed lookahead of
k=1. Consider using "options {k=1;}" for that decision and adding a
syntactic predicate.
trying decision 8 again with k=1
tpl2.g:1:10: Multiple token rules can match input such as "'a'": T18,
METHOD_SIG_ACTION, IDENTIFIER, EXPRESSION_ACTION
As a result, tokens(s) METHOD_SIG_ACTION,IDENTIFIER,EXPRESSION_ACTION were
disabled for that input
tpl2.g:1:10: Multiple token rules can match input such as "'i'": IFACE,
METHOD_SIG_ACTION, IDENTIFIER, EXPRESSION_ACTION
As a result, tokens(s) METHOD_SIG_ACTION,IDENTIFIER,EXPRESSION_ACTION were
disabled for that input
I've tried to minimise the grammar preserving the error, but that proves very
difficult. For example, after removing STRING_LITERAL_ACTION I get the
following error:
tpl2.g:1:10: Alternative 10: after matching input such
as '{''{''{''{''\'''\\''\'''\'''}''\'''\\''\'''\'''\'''}''\'''}''\'''}''\'''\\''\'''}''\'''\\''\'''\'''\'''}''\'''{''\'''\\''\'''\'''{''\'''\\''\'''\'''\'''}''\'''\\''\'''\'''\'''{''\'''{''\'''\\''\'''\'''\'''{'
decision cannot predict what comes next due to recursion overflow to
NESTED_METHOD_BODY_ACTION from NESTED_METHOD_BODY_ACTION
I've attached the minimised parser and a sample of the input it should parse.
Best regards,
Emond Papegaaij
-------------- next part --------------
A non-text attachment was scrubbed...
Name: tpl2.g
Type: text/x-java
Size: 1318 bytes
Desc: not available
Url : http://www.antlr.org/pipermail/antlr-interest/attachments/20060629/97a86dff/tpl2.bin
-------------- next part --------------
Printable {
attr int[] testAttr = new int[10];
iface public String getString() {
return #this.visitStmt(indentation = 0);
}
}
IndentedConstruct {
iface protected String writeIndentation(int indentation) {
String ret = "";
for (int count=0; count<indentation; count++) {
ret += " ";
}
return ret;
}
}
More information about the antlr-interest
mailing list