I am working through (1) "GLL Parsing" (2) "GLL parse-tree generation" and (3) "Structuring the GLL parsing algorithm for performance" by Elizabeth Scott and Adrian Johnstone.
An example grammar given in (3) 2.1 is
S ::= b a c | b a a | b A c
A ::= a
When parsing bac
the following packed forest is shown as the result.
My question is with regard to the red highlighted node and its descendant. As you can see, it is a packed node with a single child, and its child node is also with a single child.
According to (2) the getNodeP()
is defined as follows
getNodeP(X ::= α · β, w, z) {
if (α is a terminal or a non-nullable nontermial and if β ̸= ε) return z
else {
if (β = ε) t := X else t := (X ::= α · β)
suppose that z has label (q, k, i)
if (w ̸= $) {
suppose that w has label (s, j, k)
if there does not exist an SPPF node y labelled (t, j, i) create one
if y does not have a child labelled (X ::= α · β, k)
create one with left child w and right child z }
else {
if there does not exist an SPPF node y labelled (t, k, i) create one
if y does not have a child labelled (X ::= α · β, k)
create one with child z }
return y } }
From what I can understand from this code, the only way for a packed node to have a single child is if w == $
where $
is the dummy value appended at the end of the input, and its corresponding SPPF node. However, that is clearly not the case here. So, my question is, how do these two nodes get produced with only a single child even though they are not from the end of the input string?
$
is also (confusingly) used also for rule termination as a dummy node. This removes the problem; Not sure what to with this question now; How do I close it? (theclose
button is only a vote to close). – Rahul Gopinath Jan 11 '23 at 23:16