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;
Problem 1. Given the following Grammar G1, where is a start symbol. < stat >โ 𝐢𝐟 (< 𝑏𝑜&#
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am