Skip to content
Snippets Groups Projects
Verified Commit 6658e216 authored by Sankalp Gambhir's avatar Sankalp Gambhir
Browse files

Ex 3.5: Remove typo + unnecessary left factorization

parent 209af3c0
No related branches found
No related tags found
No related merge requests found
No preview for this file type
No preview for this file type
...@@ -76,24 +76,8 @@ ...@@ -76,24 +76,8 @@
generally called \emph{left recursion elimination}. generally called \emph{left recursion elimination}.
Transformed grammar steps (explanation below): Transformed grammar steps (explanation below):
Left recursion elimination (not LL(1) yet! \(\first(S') = \{(, [\;\}\)):
\begin{align*}
S &::= S' \mid ()S' \mid [\;]S' \\
S' &::= (S)S' \mid [S]S'
\end{align*}
Inline \(S'\) once in \(S ::= S'\):
\begin{align*}
S &::= (S)S' \mid [S]S' \mid ()S' \mid [\;]S' \\
S' &::= (S)S' \mid [S]S' \mid \epsilon
\end{align*}
Finally, left factorize \(S\) to get an LL(1) grammar:
\begin{align*} \begin{align*}
S &::= (T_1 \mid [T_2 \\ S &::= ()S' \mid [\;]S' \\
T_1 &::= S)S' \mid ~)S' \\
T_2 &::= S]S' \mid ~]S' \\
S' &::= (S)S' \mid [S]S' \mid \epsilon S' &::= (S)S' \mid [S]S' \mid \epsilon
\end{align*} \end{align*}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment