CS3501 CD Qb-Unit 2
CS3501 CD Qb-Unit 2
Error Detection
Error Reporting
Error Recovery
Contextual Analysis
Fallback Mechanisms
User-Friendly Feedback
Page 1 of 8
how the components of the sentence (such as words and phrases) are
organized according to the rules of grammar.
Elimination of Ambiguity
S→A
A → A + A |B++
B→y
Show a leftmost and rightmost derivation for the string “y + + + y + +”
[NOV/DEC 2021]
S → AB |aaB
A → a|Aa
B→b
Page 2 of 8
7. Define Recursive Descent Parsing?
Syntax tree:
A special kind of tree called a syntax tree is used, in which
each node represents an operation and the children of a node
represent the arguments of the operation.
Parse Tree:
[NOV/DEC 2012]
Page 3 of 8
A grammar is said to be left recursive if it has a non-terminal A such that
there is a derivation A=>Aα for some string α.
A → βA’
A’→ αA’ | ε
without changing the set of strings derivable from A
11.Mention the role of semantic analysis. [NOV/DEC 2012]
There is more to a front end than simply syntax. The compiler needs
semantic information, e.g., the types (integer, real, pointer to array of integers,
etc) of the objects involved. This enables checking for semantic errors and
inserting type conversion where necessary.
Page 4 of 8
.
→ E+E*E
→ E+E*id3
→ E+id2*id 3
→ id1+id2*id3
19.Define YACC.
Yacc - Yet Another Compiler-Compiler
Tool which will produce a parser for a given grammar.
YACC (Yet Another Compiler Compiler) is a program
designed to compile a LALR(1) grammar and to produce the
source code of the syntactic analyzer of the language produced
by this grammar.
Page 6 of 8
20.What is LL (1) grammar? Give the properties of LL (1) grammar.
L : Scan input from Left to Right
L : Construct a Leftmost Derivation
1 : Use “1” input symbol as lookahead in conjunction with stack to
decide on the parsing action LL(1) grammars == they have no
multiply-defined entries in the parsing
Part-B
1. Briefly discuss about design of a syntax analyzer for a sample
Language [Nov/Dec 2023]
2. Explain LR parsing algorithm with example [Nov/Dec 17,2023]
3. How context free grammar will work and compare various parser
techniques performance using various code blocks example
[Nov/Dec 2023]
4. Construct a predictive parsing table for the grammar.
S->(L)|a
L->L,S|S
and show whether the following string will be accepted or not.
(a,(a,(a, a ))) [Nov / Dec 2021]
5. Write an Algorithm and construct SLR Parsing Table for the
following context freegrammar. Check whether the string id + id*id is
a valid string [Nov / Dec 2021]
i. E→E+T | T
Page 7 of 8
ii. T→T*F | F F→F*| a| b
Page 8 of 8