Professional Documents
Culture Documents
Final Exam / Fall 2020 (Paper Duration 24 Hours) (Online Short Questions Based Paper)
Final Exam / Fall 2020 (Paper Duration 24 Hours) (Online Short Questions Based Paper)
To be filled by Student
(THEORETICAL EXAMINATION)
A practical technique for computing look ahead for an LR(0) parser, that progressively attempts single-
symbol, multi-symbol, and arbitrary look ahead . The technique determines the amount of look ahead
required, and the user is spared the task of guessing it.
The class of context-free grammars defined by our technique is a subset of the LR-regular grammars; we
show that unlike LR-regular, the problem of determining whether an arbitrary grammar is in the class, is
decidable. When restricted to k-symbol look ahead, the technique
has the power of LALR(k) parsers. It has been successfully used to resolve multi-symbol look ahead
conflicts in grammars for FORTRAN, Ada, C, COBOL, and PL/I, and its performance compares favorably with
that of two well-known, commercially available parser generators.
Q. 2: Handle played a vital role to Reduce the production? Discuss with example. (02)
Answer:
A bottom-up parser operates by repeatedly locating handles on the frontier of the partial parse tree and
performing reductions that they specify.
Handle operates by repeatedly locating handles on the frontier of the partial parse tree and performing
reductions that they specify.
Example:
A → β
b is the right-hand side of some production A → b, and 2. A → b is one step in right-most derivation
of input stream.
Q. No. 3: Why Bottom-up Parser is called Shift-Reduce Parser? You are required to explain the use of
Shift and Reduce action with example. (02)
ANSWER:
Shift-reduce parsing uses two unique steps for bottom-up parsing. These steps are known as shift-step and
reduce-step. Shift step: The shift step refers to the advancement of the input pointer to the next input
symbol, which is called the shifted symbol. This symbol is pushed onto the stack.
Answer:
A file named as expr.y , contained Grammar, worked as an inputof YACC, an automated tool.
YACC produces two files named as y.tab.c and y.tab.h. Y.tab.c is a C file and Y.lab.h is a header
File. Y.tab.h works as an input filefo LEX, second tool. Second input file of LEX named as expr.l
Is also present. After input LEX generates output file named as lex.yy.c which is a C file. At the
end both output files such as y.tab.c and lex.yy.c of the LEX are given to compiler, and compiler
generates the executable file named as expr.exe. Which is basically the intermediate form of
the process.
Q.No.5: What is wrong with this Program? Perform Syntactic and Semantic Analysis of this code. (05)
3: f is an array:
Used without index.
Answer:
Draw on Page and paste its snapshot here