User:Steamerandy/sandbox/metalanguage: Difference between revisions

Content deleted Content added
Tags: Mobile edit Mobile app edit Android app edit
Tags: Mobile edit Mobile app edit Android app edit
Line 17:
!<number>
 
pops the top <number> of parse stack objects combining them with the poped top node stack entry to create tree.
 
The need for left recursion is eliminated by the $ zero-or-more operator. An arithmetic example illistrates parsing with directed tree construction.
 
<syntaxhighlight lang="ebnf">
expr = term $(('+':ADD|`-`:sub) term!2);
</syntaxhighlight>
 
The term formula is expected to leave a term object on the parse stack. When we get to the !2 we have the term just recognized and an operator node on the node stack. The nest to the top parse stack entre is the term previously recognized or a an ADD or SUB tree created on a previous iteration of the loop. The !2 combines the top 2 parse stack entries with the top node stack entry to create an ADD or SUB tree. The term formula operates just as asdescribed above.
 
<syntaxhighlight lang="ebnf">