SDF/JSGLR: NPE when parsing in GM
When parsing the following randomly generated program Green-Marl program (commit 70443881fc501ab3f5300022dcab038d612de80d) using Spoofax 2.4.1
local Q(qP: v, iVect[findAny(AQ : _.nbrs )] JgwV, T1, Kikn5: Dd) : uGraph { do if(false) ; else do ; while(+INF); while(false); return true + NIL; { } }
we get
16:10 | ERROR | o.m.s.e.e.EditorUpdateJob - Failed to update editor for eclipse:///gm_lang/y.gm java.lang.NullPointerException: null at org.spoofax.jsglr.client.imploder.AbstractTokenizer.markPossibleSyntaxError(AbstractTokenizer.java:88) ~[na:na] at org.spoofax.jsglr.client.imploder.TreeBuilder.buildTreeNode(TreeBuilder.java:342) ~[na:na] at org.spoofax.jsglr.client.ParseNode.toTreeTopdown(ParseNode.java:338) ~[na:na] at org.spoofax.jsglr.client.imploder.TreeBuilder.buildTreeNode(TreeBuilder.java:292) ~[na:na] at org.spoofax.jsglr.client.imploder.TreeBuilder.buildTreeAmb(TreeBuilder.java:435) ~[na:na] at org.spoofax.jsglr.client.ParseNode.toTreeTopdown(ParseNode.java:337) ~[na:na] at org.spoofax.jsglr.client.imploder.TreeBuilder.buildTreeNode(TreeBuilder.java:292) ~[na:na] at org.spoofax.jsglr.client.ParseNode.toTreeTopdown(ParseNode.java:338) ~[na:na] at org.spoofax.jsglr.client.imploder.TreeBuilder.buildTreeNode(TreeBuilder.java:317) ~[na:na] at org.spoofax.jsglr.client.ParseNode.toTreeTopdown(ParseNode.java:338) ~[na:na] at org.spoofax.jsglr.client.imploder.TreeBuilder.buildTreeNode(TreeBuilder.java:292) ~[na:na] at org.spoofax.jsglr.client.ParseNode.toTreeTopdown(ParseNode.java:338) ~[na:na] at org.spoofax.jsglr.client.imploder.TreeBuilder.buildTreeNode(TreeBuilder.java:317) ~[na:na] at org.spoofax.jsglr.client.ParseNode.toTreeTopdown(ParseNode.java:338) ~[na:na] at org.spoofax.jsglr.client.imploder.TreeBuilder.buildTreeNode(TreeBuilder.java:317) ~[na:na] at org.spoofax.jsglr.client.ParseNode.toTreeTopdown(ParseNode.java:338) ~[na:na] at org.spoofax.jsglr.client.imploder.TreeBuilder.buildTreeNode(TreeBuilder.java:317) ~[na:na] at org.spoofax.jsglr.client.imploder.TopdownTreeBuilder.buildTree(TopdownTreeBuilder.java:28) ~[na:na] at org.spoofax.jsglr.client.imploder.TreeBuilder.buildTree(TreeBuilder.java:169) ~[na:na] at org.spoofax.jsglr.client.Disambiguator.yieldTree(Disambiguator.java:347) ~[na:na] at org.spoofax.jsglr.client.Disambiguator.yieldTreeTop(Disambiguator.java:360) ~[na:na] at org.spoofax.jsglr.client.Disambiguator.applyFilters(Disambiguator.java:300) ~[na:na] at org.spoofax.jsglr.client.Disambiguator.applyFilters(Disambiguator.java:261) ~[na:na] at org.spoofax.jsglr.client.SGLR.sglrParse(SGLR.java:595) ~[na:na] at org.spoofax.jsglr.client.SGLR.parse(SGLR.java:499) ~[na:na] at org.metaborg.spoofax.core.syntax.JSGLR1I.actuallyParse(JSGLR1I.java:118) ~[org.metaborg.spoofax.core_2.4.1.jar:na] at org.metaborg.spoofax.core.syntax.JSGLR1I.parse(JSGLR1I.java:58) ~[org.metaborg.spoofax.core_2.4.1.jar:na] at org.metaborg.spoofax.core.syntax.JSGLRParseService.parse(JSGLRParseService.java:125) ~[org.metaborg.spoofax.core_2.4.1.jar:na] at org.metaborg.spoofax.core.syntax.JSGLRParseService.parse(JSGLRParseService.java:1) ~[org.metaborg.spoofax.core_2.4.1.jar:na] at org.metaborg.core.syntax.SyntaxService.parse(SyntaxService.java:38) ~[org.metaborg.core_2.4.1.jar:na] at org.metaborg.spoofax.eclipse.editor.EditorUpdateJob.parse(EditorUpdateJob.java:307) ~[org.metaborg.spoofax.eclipse_2.4.1.jar:na] at org.metaborg.spoofax.eclipse.editor.EditorUpdateJob.update(EditorUpdateJob.java:222) ~[org.metaborg.spoofax.eclipse_2.4.1.jar:na] at org.metaborg.spoofax.eclipse.editor.EditorUpdateJob.run(EditorUpdateJob.java:144) ~[org.metaborg.spoofax.eclipse_2.4.1.jar:na] at org.eclipse.core.internal.jobs.Worker.run(Worker.java:56) [org.eclipse.core.jobs_3.9.2.v20171030-1027.jar:na]
the problem seems to be with the parameter declarations. Admittedly, the syntax for parameter declarations is a bit weird (we support old-style “name: type” and new-style “type name” syntax) and this is a very contrived example (where we combine the two styles). However, as contrived as this may be, it should never trigger a NPE in the parser.
Submitted by Martijn on 1 April 2018 at 16:15
Log in to post comments