Question: How do I implement the SLR _ parse _ table in the following section of code? / / Generate the SLR Parsing Table ( Action

How do I implement the SLR_parse_table in the following section of code?
// Generate the SLR Parsing Table (Action and Goto tables)
void SLR_parse_tables(const vector& grammar){
cout "
SLR Parsing Table (Action and Goto):
";
// Pseudo-code for table construction
// For each state in canonicalCollection:
// For each item in the state:
// if item is [A -> . a ] where 'a' is terminal:
// actionTable[state][a]="s"+ nextState
// if item is [A -> .]:
// for each symbol in Follow(A):
// actionTable[state][symbol]="r"+ rule number
// if item is [S'-> S .]:
// actionTable[state]["$"]= "acc"
// For each non-terminal A:
// if Goto(state, A) is non-empty:
// gotoTable[state][A]= nextState
}
Follow-up for In C++Programming,I am attempting to implement the following grammar:
Basic Grammar
(1)E->E+T
(2)E'->T
(3)T->T*F
(4)T->F
(5)F->(E)
(6)F->id
Into the following algorithms:
Please implement the following algorithms
(i)Closure(I)
(ii)Follow(S)
(iii)Goto(State,X)
(iv)CanonicalSet(I)
(v)SLR_parse_tables(grammar)
Please test your algorithm(v)using the basic grammar and output the following Action_and_Goto Table.
\begin{tabular}{|c|c|c|c|c|c|c|c|c|c|}
\hline \multirow[t]{2}{*}{State} & \multicolumn{6}{|c|}{action} & \multicolumn{3}{|c|}{goto}\\
\hline & id & \(+\) & * & ( & ) & \$ & E & T & F \\
\hline 0 & s5 & & & s4 & & & 1 & 2 & 3\\
\hline 1 & & s6 & & & & acc & & & \\
\hline 2 & & r2 & s7 & & r2 & r2 & & & \\
\hline 3 & & r4 & r4 & & r4 & r4 & & & \\
\hline 4 & s5 & & & s4 & & & 8 & 2 & 3\\
\hline 5 & & r6 & r6 & & r6 & r6 & & & \\
\hline 6 & s5 & & & s4 & & & & 9 & 3\\
\hline 7 & s5 & & & s4 & & & & & 10\\
\hline 8 & & s6 & & & s11 & & & & \\
\hline 9 & & r1 & s7 & & r1 & r1 & & & \\
\hline 10 & & r3 & r3 & & r3 & r3 & & & \\
\hline 11 & & r5 & r5 & & r5 & r5 & & & \\
\hline
\end{tabular}
How do I implement the SLR _ parse _ table in the

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!