parsing - Can a table-based LL parser handle repetition without right-recursion? -
I understand how an LL recurring root parser can handle the rules of this form:
A = B *;
With a simple loop that checks whether looping is to continue, depending on whether the letterhead matches the terminal in the first set of token B. However, I am curious about table based LL Parser: How can the rules of this form work? As far as I know, the only way to handle repetition in one way in this way is through correct-reaction, but in that case the partners are disturbed where a right-associative parse tree is not desired. is.
Because I am currently trying to write an LL (1) table-based parser generator and I am not sure how to deal with such a case without changing the intending parse tree size Be controlled.
Let's expand your ENNF grammar into simple BNF and assume that b
< Div class = "text" is a terminal and & lt; E & gt;
is an empty string:
A -> X-X - & gt; Bx x - & gt; & Lt; E & gt; B - & gt; B
This grammar generates the string of the term b
of any length.
To create a table of LL (1) table
, we will need to set the first and set ().
The first set
The first (α)
is the string of the terminals starting with the symbols of any string grammar α < / Code>.
Prior (A): B, & lt; E & gt; First (X): B, & lt; E & gt; Follow the first (B): b
set
< P>
Comments
Post a Comment