Problem 1. Given the following Grammar G1, where is a start symbol. < stat >โ†’ &#119842;&#119839; (< &#119887;&#119900;&#

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

Problem 1. Given the following Grammar G1, where is a start symbol. < stat >โ†’ &#119842;&#119839; (< &#119887;&#119900;&#

Post by answerhappygod »

Problem 1. Given the following Grammar G1, where is
a start symbol.
< stat >โ†’ ๐ข๐Ÿ (< ๐‘๐‘œ๐‘œ๐‘™ >) < stat > ๐ž๐ฅ๐ฌ๐ž < stat
>
| ๐ฐ๐ก๐ข๐ฅ๐ž (< bool >) < stat >
|{< stats >}
| < assign >
< assign >โ†’ ๐ข๐ = ;
< stats >โ†’< stat >< stats >
| ฮต
< exp > โ†’ < exp > +< term >
| < term >
< term >โ†’ < term >โˆ— < factor >
| < Factor >
< Factor >โ†’ ๐ข๐
| num
|( < exp > )
|โˆ’ < factor >
< bool > โ†’ < bool > ๐š๐ง๐ < bterm >
| < bterm >
< bterm >โ†’ < bterm > ๐จ๐ซ < bfactor >
| < bfactor >
< bfactor >โ†’ ๐ญ๐ซ๐ฎ๐ž
| false
|( < bool > )
|๐ง๐จ๐ญ < bfactor >
Part-1: LL(1) Recursive descent parser:
1) Transform the grammar G1 into LL(1) grammar G2, then compute
First/Follow/Predict sets.
2) Construct the LL(1) top-down predictive parser. (Hint. write one
procedure for each variable.)
3) Write the procedures in one of your favorite programming
languages C++/Java or Python.
4) Parse the following input, using predictive parser
program:
Input The Output
if (not false) a=10; else while ( true ) a=-b; Sample output: input
parsed successfully,
print/ runtime stack
Part-2: LL(1) Parse Table:
1) Compute LL(1) parse table for G2.
2) Parse the following input using the LL(1) parse table;
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply