FilterException for right associativity
I get a FilterException error for this grammar:
module Testexports
context-free start-symbols
Startcontext-free syntax
Exp -> Start
Bool -> Exp
Exp “=” Exp -> Exp {right, cons(“Error”)}VARID -> Exp VARID -> Bool
lexical syntax
[A-Z]* -> VARIDlexical restrictions
VARID -/- [A-B]The problem appears only when I have ambiguities and right associativity.
Submitted by Radu Mereuta on 26 July 2011 at 14:32
Issue Log
Do you have a stack trace for this problem?
eclipse.buildId=M20110210-1200 java.version=1.6.0_24 java.vendor=Sun Microsystems Inc. BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=en_US Command-line arguments: -os win32 -ws win32 -arch x86_64 Error Tue Jul 26 18:11:11 EEST 2011 Internal parsing error: Runtime exception when applying filters org.spoofax.jsglr.client.FilterException: Runtime exception when applying filters at org.strategoxt.imp.runtime.parser.JSGLRI.doParse(JSGLRI.java:182) at org.strategoxt.imp.runtime.parser.AbstractSGLRI.parse(AbstractSGLRI.java:106) at org.strategoxt.imp.runtime.parser.SGLRParseController.doParse(SGLRParseController.java:352) at org.strategoxt.imp.runtime.parser.SGLRParseController.parse(SGLRParseController.java:287) at org.strategoxt.imp.runtime.parser.SGLRParseController.parse(SGLRParseController.java:1) at org.strategoxt.imp.runtime.dynamicloading.DynamicParseController.parse(DynamicParseController.java:168) at org.eclipse.imp.editor.ParserScheduler.run(ParserScheduler.java:86) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54) Caused by: org.spoofax.jsglr.client.FilterException: Runtime exception when applying filters at org.spoofax.jsglr.client.Disambiguator.applyFilters(Disambiguator.java:251) at org.spoofax.jsglr.client.SGLR.sglrParse(SGLR.java:318) at org.spoofax.jsglr.client.SGLR.parse(SGLR.java:265) at org.strategoxt.imp.runtime.parser.JSGLRI.doParse(JSGLRI.java:163) ... 7 more Caused by: java.lang.UnsupportedOperationException at org.spoofax.jsglr.client.ParseNode.getLabel(ParseNode.java:38) at org.spoofax.jsglr.client.Disambiguator.applyRightAssociativeFilter(Disambiguator.java:580) at org.spoofax.jsglr.client.Disambiguator.applyAssociativityPriorityFilter(Disambiguator.java:537) at org.spoofax.jsglr.client.Disambiguator.filterTree(Disambiguator.java:456) at org.spoofax.jsglr.client.Disambiguator.filterAmbiguities(Disambiguator.java:820) at org.spoofax.jsglr.client.Disambiguator.filterTree(Disambiguator.java:469) at org.spoofax.jsglr.client.Disambiguator.applyFilters(Disambiguator.java:245) ... 10 moreTried it with r23157
There seems to be a check for this case in the “left” associativity filter, I added one for the “right” one as well in
r23162
.
Sorry, but no change. The problem is still there. Try and see the grammar in my first comment, it triggers the bug.
Do you get the same stack trace?
A bit different: eclipse.buildId=M20110210-1200 java.version=1.6.0_24 java.vendor=Sun Microsystems Inc. BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=en_US Command-line arguments: -os win32 -ws win32 -arch x86_64 Error Wed Jul 27 23:49:47 EEST 2011 Internal parsing error: Runtime exception when applying filters org.spoofax.jsglr.client.FilterException: Runtime exception when applying filters at org.strategoxt.imp.runtime.parser.JSGLRI.doParse(JSGLRI.java:182) at org.strategoxt.imp.runtime.parser.AbstractSGLRI.parse(AbstractSGLRI.java:106) at org.strategoxt.imp.runtime.parser.SGLRParseController.doParse(SGLRParseController.java:352) at org.strategoxt.imp.runtime.parser.SGLRParseController.parse(SGLRParseController.java:287) at org.strategoxt.imp.runtime.parser.SGLRParseController.parse(SGLRParseController.java:1) at org.strategoxt.imp.runtime.dynamicloading.DynamicParseController.parse(DynamicParseController.java:169) at org.eclipse.imp.editor.ParserScheduler.run(ParserScheduler.java:86) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54) Caused by: org.spoofax.jsglr.client.FilterException: Runtime exception when applying filters at org.spoofax.jsglr.client.Disambiguator.applyFilters(Disambiguator.java:251) at org.spoofax.jsglr.client.SGLR.sglrParse(SGLR.java:318) at org.spoofax.jsglr.client.SGLR.parse(SGLR.java:265) at org.strategoxt.imp.runtime.parser.JSGLRI.doParse(JSGLRI.java:163) ... 7 more Caused by: java.lang.ArrayIndexOutOfBoundsException: 5 at org.spoofax.jsglr.client.Disambiguator.applyRightAssociativeFilter(Disambiguator.java:589) at org.spoofax.jsglr.client.Disambiguator.applyAssociativityPriorityFilter(Disambiguator.java:537) at org.spoofax.jsglr.client.Disambiguator.filterTree(Disambiguator.java:456) at org.spoofax.jsglr.client.Disambiguator.applyFilters(Disambiguator.java:245) ... 10 more
An update to this issue, I found a way to break the left filter as well. This example: "A+0", breaks for this grammar: context-free start-symbols Start context-free syntax Exp -> Start VARID -> Exp NAT -> Exp INT -> Exp Exp "+" Exp -> Exp {left, cons("Add")} lexical syntax [A-Z]+ -> VARID [0-9]+ -> NAT "-"?[0-9]+ -> INT lexical restrictions VARID -/- [A-B] Sometimes it hangs, sometimes it reports an error similar to the above, and sometimes I get this erroneous AST: amb(["A", amb(["", ""])]). If I switch left with right and try to parse "0+A" I get the same behaviors. I'm not sure what happens, but I hope that you can fix it.
I think with the latest fix in
r24658
this should be resolved: it no longer throws aFilterException
orArrayIndexOutOfBoundsException
for your grammar. The result it returns for the grammar above is now:Add("A",amb(["0","0"]))
. (There’s still an ambiguity since it can be aNAT
or anINT
.) Let me know if there’s still more trouble.
Thanks Lennart. I’ve updated eclipse and it works. I’m getting the expected result. I still have a request though. Could you update strategoxt.jar also?
This is the tool we’ll be using in our release. Right now the versions that I could find are based on r24429.
Alright, the buildfarm now provides a new version :)
Log in to post comments