You are on page 1of 3

Shri S’ad Vidya Mandal Institute of Technology

B.E. III (SEMESTER 5) Computer Engineering


System Programming (2150708)
Unit -6 (Scanning and Parsing )
Assignment
1. Write unambiguous production rules (grammar) for arithmetic expression containing +,
- , *, / and ^ (exponentiation).Construct parse tree and abstract syntax tree for :
<id> – <id> * <id> ^ <id> + <id>
2. Describe working of LL(1) parser and parse following string :
|- <id> * <id> * <id> + <id> -|
3. What is operator precedence parsing? Show operator precedence matrix for following
operators:
+, - , * , ( , ).
Parse following string:
|- <id> + <id> * <id> -|
4. Explain Left recursion, Left factoring and backtracking in top down parsing.
5. Given the Grammer, evaluate the string id-id*id using shift reduce parser.
E-> E – E
E -> E * E
E -> id
6. Given the grammer, perform the top-down parsing for the the string +*35*45
E = +TE|E
T = *VT|V
V= 0|1|2|3|………|9
7. Develop Regular expression and DFA for declaring a variable in ‘C’ language.
8. Parse following strings using given LL(1) parsing table (TABLE-I)
id*id + id * id (ii) id + id + id + id
9. Explain recursive decent parser with suitable example. Also state its drawbacks.
10. Compare top-down and bottom-up parser.
11. Write operator precedence table for arithmetic operators “+”, “*”, “-”, “/” .
12. Parse following expression using the table. id * id + id * id
13. When Left- factoring on a grammar is applied? Apply left- factoring on the below given
grammar and perform Predictive Parsing.
Grammar is
S =i E t S | i E t S e S | a
E =b
String is : i b t a e i b t a
14. Define Simple Phrase and Handle. Using Handle and Simple Phrase trace the bottom up
parsing algorithm.
Grammar is :
E =T+ E | T – E | T
T =T *V | T / V | V
V=a | b | c | d
String is : a - b * c + d
15. Construct LL(1) parsing table for following grammar.
E TE’
E’  +TE’ | Є
T FT’
T’  *FT’ | Є
F  (E) | id
16. Construct operator precedence parser for following grammar :
E  E+E | E*E | id
17. Write Regular expression and DFA for valid exponential number
18. Write unambiguous production rules (grammar) for arithmetic expression containing +,
- , *, / and ^ (exponentiation).Construct parse tree and abstract syntax tree for :
<id> – <id> * <id> ^ <id> + <id>
19. Consider following grammar
S -> aSbS | bSaS | epsilon
Derive the string abab. Draw corresponding parse tree. Are these rules ambiguous?
Justify
20. Write regular definitions for producing real numbers of programming language ‘C’.
21. How to avoid backtracking in top down parsing?
22. Given a grammar
S→XS | dS | ε
X→Y | Zb | aY
Y→cZ
Z→e
Develop an LL(1) parsing table and check whether the string “dace” is accepted or not?
23. Remove left recursion from following production rules:
A -> AaB | x
B -> BCb | y
C -> Cc | epsilon
24. Explain left factoring by giving example.
25. By giving suitable example, illustrate working of operator precedence parser.
26. Explain working of LL (1) parser. Parse following string:
id + id - (id * id )
27. Explain recursive descent parsing algorithm.
28. Define Handle, Grammar,Simple pharse
29. Write operator precedence table for arithmetic operators “+”, “*”, “-”, “/” ”(“, “)”. Parse
following expression using the table.
id * (id + id )/ (id *id)

Note:

1. Support your answer with appropriate figure/diagram wherever


required.

You might also like