[antlr-interest] Error message in AST parser/lexer: expecting EOA, found
"Paul Bouché (NSN)"
paul.bouche at nsn.com
Fri Feb 13 09:42:20 PST 2009
Hi,
I tried everything I know so I am tending to you. I have a
context-sensitive construct in my lexer. I have two tokens where where
one is a superset of the other, but shall only be recognized after an
equals was found and is basically any character until a komma.
Therefore, I defined a predicate which is set to true once an equals is
reached which enables the gated superset token and when a comma is found
the predicate is set to false.
In order to allow the following:
key = value = 3
where key is key and everything after the '=' is a value until EOF or
',' ,i..e. in this case "value = 3". Yes I know this is very strange and
usually you would quote string, but we need it for legacy reasons,
mainly incoperating legacy hand-written parser funcitonality into ANTLR ;-)
But unfortunately I get a strange syntax error? Please see below: I also
attached the full grammar, in case you need that.
I include a snippet of the AST grammar, where the rule in question is used:
// parser...
properties
:
( property ( Delim property )* )? Delim?
-> property*
;
attributes
: // FIXME is this wanted h=(d=3 k=3) , i.e. with komma?
( attribute ( Delim attribute )* )* Delim?
-> ^( ATTRIBUTES attribute* )
;
list
:
( value ( Delim value )* )*
-> ^( TYPE LIST ) ^( VALUE value* )
;
// lexer...
Delim
:
','
{
unsetFoundFirstEqualsInPropert();
}
;
fragment USTRING_
:
{hasFoundFirstEqualsInProperty()}?=>
(~(' ' /*| '\t'*/ | '%' | Delim | '\n' | '[' | '{' | '"' | '\'' |
'`' | '<' | '\\' | '/') | HEXESCAPE | '%' ~HEXDIGIT_) (~('%' | Delim |
'\n' | '}' | ']' ) | HEXESCAPE | '%' ~HEXDIGIT_)*
;
The error is "syntax error: buildnfa: <AST>:227:2: expecting EOA, found '
unsetFoundFirstEqualsInPropert();
'".
I get from the list that EOA means End-Of-Alternative, but the rules
does not have an alternative. This may also be related to the bug
http://www.antlr.org/jira/browse/ANTLR-305 ? It seems very similar to my
problem.
Please help, we really need this. Also if you have another suggestion
for a solution to this problem.
Thanks,
Paul
ANTLR Parser Generator Version 3.1.1
error(100):
T:\Workspaces\paulb\AAA-nemip\ag\netzwert\nemip\StringProps.g:0:0:
syntax error: buildnfa: <AST>:227:2: expecting EOA, found '
unsetFoundFirstEqualsInPropert();
'
error(100):
T:\Workspaces\paulb\AAA-nemip\ag\netzwert\nemip\StringProps.g:0:0:
syntax error: buildnfa: <AST>: expecting EOA, found '<empty tree>'
error(100):
T:\Workspaces\paulb\AAA-nemip\ag\netzwert\nemip\StringProps.g:0:0:
syntax error: buildnfa: <AST>:227:2: expecting EOA, found '
unsetFoundFirstEqualsInPropert();
'
error(100):
T:\Workspaces\paulb\AAA-nemip\ag\netzwert\nemip\StringProps.g:0:0:
syntax error: buildnfa: <AST>: expecting EOA, found '<empty tree>'
error(10): internal error: Can't get property javaCompressedTransition
using method get/isJavaCompressedTransition from org.antlr.analysis.DFA
instance : java.lang.OutOfMemoryError: Java heap space
java.util.ArrayList.<init>(ArrayList.java:112)
org.antlr.analysis.DFA.getRunLengthEncoding(DFA.java:357)
org.antlr.analysis.DFA.getJavaCompressedTransition(DFA.java:333)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)
org.antlr.stringtemplate.language.ASTExpr.invokeMethod(ASTExpr.java:563)
org.antlr.stringtemplate.language.ASTExpr.rawGetObjectProperty(ASTExpr.java:514)
org.antlr.stringtemplate.language.ASTExpr.getObjectProperty(ASTExpr.java:416)
org.antlr.stringtemplate.language.ActionEvaluator.attribute(ActionEvaluator.java:351)
org.antlr.stringtemplate.language.ActionEvaluator.expr(ActionEvaluator.java:136)
org.antlr.stringtemplate.language.ActionEvaluator.templateApplication(ActionEvaluator.java:216)
org.antlr.stringtemplate.language.ActionEvaluator.expr(ActionEvaluator.java:126)
org.antlr.stringtemplate.language.ActionEvaluator.action(ActionEvaluator.java:84)
org.antlr.stringtemplate.language.ASTExpr.write(ASTExpr.java:148)
org.antlr.stringtemplate.StringTemplate.write(StringTemplate.java:700)
org.antlr.stringtemplate.language.ASTExpr.write(ASTExpr.java:722)
org.antlr.stringtemplate.language.ASTExpr.writeAttribute(ASTExpr.java:659)
org.antlr.stringtemplate.language.ActionEvaluator.action(ActionEvaluator.java:86)
org.antlr.stringtemplate.language.ASTExpr.write(ASTExpr.java:148)
org.antlr.stringtemplate.StringTemplate.write(StringTemplate.java:700)
org.antlr.stringtemplate.language.ASTExpr.write(ASTExpr.java:722)
org.antlr.stringtemplate.language.ASTExpr.writeAttribute(ASTExpr.java:659)
org.antlr.stringtemplate.language.ActionEvaluator.action(ActionEvaluator.java:86)
org.antlr.stringtemplate.language.ASTExpr.write(ASTExpr.java:148)
org.antlr.stringtemplate.StringTemplate.write(StringTemplate.java:700)
org.antlr.codegen.CodeGenerator.write(CodeGenerator.java:1275)
org.antlr.codegen.Target.genRecognizerFile(Target.java:94)
org.antlr.codegen.CodeGenerator.genRecognizer(CodeGenerator.java:460)
org.antlr.Tool.generateRecognizer(Tool.java:420)
org.antlr.Tool.process(Tool.java:342)
--
Paul Bouché
Voice: +49 30 590080-1284
Nokia Siemens Networks GmbH & Co. KG, An den Treptowers 1, 12435 Berlin, Germany
Sitz der Gesellschaft: München / Registered office: Munich
Registergericht: München / Commercial registry: Munich, HRA 88537
WEEE-Reg.-Nr.: DE 52984304
Persönlich haftende Gesellschafterin / General Partner: Nokia Siemens Networks Management GmbH
Geschäftsleitung / Board of Directors: Lydia Sommer, Olaf Horsthemke
Vorsitzender des Aufsichtsrats / Chairman of supervisory board: Lauri Kivinen
Sitz der Gesellschaft: München / Registered office: Munich
Registergericht: München / Commercial registry: Munich, HRB 163416
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: properties.g
Url: http://www.antlr.org/pipermail/antlr-interest/attachments/20090213/ea0e0508/attachment.pl
More information about the antlr-interest
mailing list