I have this small example of an ambiguous grammar that doesn’t return the result I’m expecting:


module Test

exports
context-free start-symbols
Exp

context-free syntax
Id -> Exp {cons(“Exp2Id”)}

Exp "+" Exp -> Exp {left, cons("Plus")}
ID			-> Id {cons("Id")}

lexical syntax
[A-Z][a-zA-Z0-9]* -> VarId
[a-zA-Z][a-zA-Z0-9_]* -> ID

context-free syntax
VarId -> Id {cons(“Id2Var”)}
VarId -> Exp {cons(“Exp2Var”)}

This is the returned AST for “A+B”:


amb(
[ amb(
[Exp2Var(“A”), Exp2Id(amb([Id2Var(“A”), Id(“A”)]))]
)
, amb(
[Exp2Var(""), Exp2Id(amb([Id2Var(““), Id(””)]))]
)
]
)

“A” is parsed correctly, but “B” is missing.
Am I doing something wrong, or is this a JSGLR error? I really need the correct parsing, with all of the ambiguities.

Submitted by Radu Mereuta on 18 May 2011 at 14:56
AB.af22 May 2011 at 13:01

On 22 May 2011 at 13:11 Lennart Kats commented:

This seems to be a problem with the new ambiguity handling approach, not the imploder. Maartje, could you take a look? The internal representation shows the following ambiguity:


[amb([regular(aprod(278),[regular(aprod(285),[regular(aprod(286),[65, regular(aprod(270),[])])])]), regular(aprod(282),[amb([regular(aprod(279),[regular(aprod(285),[regular(aprod(286),[65, regular(aprod(270),[])])])]), regular(aprod(280),[regular(aprod(283),[regular(aprod(284),[65, regular(aprod(261),[])])])])])])]), regular(aprod(259),[]), regular(aprod(257),[43]), regular(aprod(259),[]), amb([regular(aprod(278),[regular(aprod(285),[regular(aprod(286),[66, regular(aprod(270),[])])])]), regular(aprod(282),[amb([regular(aprod(279),[regular(aprod(285),[regular(aprod(286),[66, regular(aprod(270),[])])])]), regular(aprod(280),[regular(aprod(283),[regular(aprod(284),[66, regular(aprod(261),[])])])])])])])]

(Note the different ParseProductionNode characters in the branches!)


On 22 May 2011 at 13:12 Lennart Kats tagged @maartje

On 22 May 2011 at 13:13 Lennart Kats tagged parser

On 22 May 2011 at 19:06 Maartje closed this issue.

On 22 May 2011 at 19:07 Maartje commented:

bug in left associativity filter fixed


On 22 May 2011 at 21:44 Lennart Kats tagged 1.0

Log in to post comments