1,079
edits
(→Parser grammar example: fixed example formulas) |
(→Semantics: Fixed some pseudo code) |
||
Line 301: | Line 301: | ||
Where S is the set of possible semantic values, and V is the set of non-terminals as defined in the grammar. We will also use the sequence <i>γ<sub>0</sub>,&gamma<sub>1</sub>,&gamma<sub>2</sub> … &gamma<sub>k-1</sub></i> which will represent the word groups the input tokens belonged to (in the exact order they were accepted), and the sequence <i>r<sub>0</sub>,r<sub>1</sub>,r<sub>2</sub> … r<sub>l-1</sub></i> , which will be the list of rules used to create the left derivation tree as described in the previous section. | Where S is the set of possible semantic values, and V is the set of non-terminals as defined in the grammar. We will also use the sequence <i>γ<sub>0</sub>,&gamma<sub>1</sub>,&gamma<sub>2</sub> … &gamma<sub>k-1</sub></i> which will represent the word groups the input tokens belonged to (in the exact order they were accepted), and the sequence <i>r<sub>0</sub>,r<sub>1</sub>,r<sub>2</sub> … r<sub>l-1</sub></i> , which will be the list of rules used to create the left derivation tree as described in the previous section. | ||
<pre> | |||
< | Helper function sci_said_recursive: S × V × (V ∪ Σ)* → NODE | ||
Parameters: s ∈ S, Rule r ∈ V × (V ∪ Σ): v0 → v1 v2 ... vi | |||
cnmr = cnr | |||
NODE n := s, v0 | |||
FOR j := 1 TO i | |||
IF (vj ∈ Σ) THEN | |||
n := n, γcnγ | |||
cnγ := cnγ + 1 | |||
ELSE | |||
cnoldr := cnr | |||
cnr := cnr + 1 | |||
n := n, sci_said_recursive(Σrmr,j, rcnoldr) | |||
FI | |||
ROF | |||
RETURN (n) | |||
Helper function get_children: NODE → NODE* | |||
get_children((s, v, n0, n1 ... nm)) := n0, n1 ... nm | |||
Algorithm SCI-SAID-TREE | |||
cnγ := 0; | |||
cnr := 1; | |||
ntemp := ntemp, SCI-SAID-RECURSIVE(0, r0) | |||
root(TΠ) := (141, 13f, get_children(ntemp)) | |||
</pre> | |||
</ | |||
Here is an example, based on the previous one: | Here is an example, based on the previous one: |
edits