SECTION A (Any 2 Questions Explained Briefly)
What is YACC?
YACC stands for Yet Another Compiler Compiler. It is a parser generator tool used to produce syntax analyzers for compilers. YACC takes a grammar specification as input and generates a parser that checks whether the source program follows the given grammar rules. It is commonly used along with LEX.
What do you understand by shift-reduce parsing?
Shift-reduce parsing is a bottom-up parsing technique used in syntax analysis. In this method, symbols are shifted onto a stack and then reduced using grammar rules to derive the start symbol. It is mainly used in LR parsers and is efficient for handling programming language grammars.
SECTION B (Any 2 Questions Explained)
Explain lexical, syntax and semantic phase errors.
Lexical errors occur during token formation, such as invalid identifiers or symbols. Syntax errors occur when the structure of the program does not follow grammar rules, like missing semicolons or brackets. Semantic errors arise when the meaning of the statement is incorrect, such as type mismatch or undeclared variables. These errors are detected in different phases of compilation.
Explain loop optimization.
Loop optimization is a code optimization technique used to improve program performance by reducing execution time. It involves techniques such as loop unrolling, loop invariant code motion and strength reduction. Since loops execute repeatedly, optimizing them significantly enhances overall program efficiency.
SECTION C (Any 2 Questions Explained)
Explain cross compiler.
A cross compiler is a compiler that runs on one machine but generates executable code for another machine with a different architecture. It is commonly used in embedded systems development where the target system does not have enough resources to run a compiler.
Explain ambiguity in grammar.
A grammar is said to be ambiguous if a single string can be derived in more than one parse tree. Ambiguous grammars create confusion in syntax analysis and must be converted into unambiguous grammars to ensure correct parsing and code generation.
Most Questions in This PDF Are Related To
Most questions in the Compiler Design (KCS-502) paper are related to phases of compiler, lexical analysis, syntax analysis, parsing techniques, grammar and automata, intermediate code generation, symbol tables, error handling, optimization techniques, and code generation. The paper mainly focuses on theoretical concepts and problem-solving related to compiler construction.