CS603(C) Compiler Design Unit 2 study material for RGPV CSE 6th Semester. Learn Syntax Analysis, Context Free Grammar, Top Down Parsing, Recursive Descent Parsing, Predictive Parsing, Bottom Up Parsing, LR Parsers, SLR, LALR, Syntax Directed Definitions and Syntax Trees.
Unit 2 explains how a compiler checks whether the token stream follows grammar rules. Syntax analysis is one of the most important compiler phases because it creates the structure of the program using parse trees or syntax trees.
Understand grammar, parse tree, syntax tree and the role of parser in compilation.
Study recursive descent parsing, predictive parsing and LL-style parsing methods.
Learn operator precedence parsing, LR parsing, SLR, LALR and parser generation.
Complete syllabus-based topics of Compiler Design Unit 2.
Syntax analysis checks the grammatical structure of token stream and generates parse tree or syntax tree.
CFG is used to describe the syntax of programming languages using terminals, non-terminals, productions and start symbol.
Top down parsing starts from the start symbol and tries to derive the input string.
A top down parsing technique where each non-terminal is implemented using a recursive procedure.
Predictive parsing is a non-backtracking top down parsing technique that uses lookahead symbols.
Bottom up parsing starts from input string and reduces it to the start symbol of grammar.
A bottom up parsing technique based on precedence relations between operators.
LR parsers scan input from left to right and produce rightmost derivation in reverse.
Simple LR parser is easier to construct and uses LR(0) items with FOLLOW sets.
Look Ahead LR parser is commonly used in compiler tools because it is powerful and table size is manageable.
Parser generators automatically generate parser code from grammar specifications.
SDD associates semantic rules with grammar productions for computing attributes.
Syntax directed translation translates source constructs using grammar rules and semantic actions.
S-attributed definition uses only synthesized attributes and is suitable for bottom up evaluation.
L-attributed definition uses synthesized and restricted inherited attributes for top down evaluation.
Syntax tree is a compact representation of parse tree that shows essential program structure.
Parser: Parser is the syntax analyzer of compiler. It takes tokens from lexical analyzer
and checks whether they follow the grammar of the programming language.
Input: Tokens
Output: Parse tree or syntax tree
Main work: Syntax checking and error reporting
Upload your PDFs in the pdfs folder with the same file names used below.
Complete Compiler Design Unit 2 notes for syntax analysis and parsing.
Download NotesThese questions are useful for 7 marks and 14 marks answers in RGPV exams.
High-priority topics from Unit 2 based on common RGPV exam patterns.
| Topic | Expected Frequency | Importance |
|---|---|---|
| CFG and Parse Tree | Very High | ⭐⭐⭐⭐⭐ |
| Top Down Parsing | High | ⭐⭐⭐⭐ |
| Recursive Descent Parsing | High | ⭐⭐⭐⭐ |
| Predictive Parsing | Very High | ⭐⭐⭐⭐⭐ |
| Bottom Up Parsing | High | ⭐⭐⭐⭐ |
| LR Parsers | Very High | ⭐⭐⭐⭐⭐ |
| SLR and LALR Parser | Very High | ⭐⭐⭐⭐⭐ |
| Syntax Directed Definition | High | ⭐⭐⭐⭐⭐ |
| S-Attributed and L-Attributed Definition | High | ⭐⭐⭐⭐ |
Syntax analysis checks whether tokens generated by lexical analyzer follow grammar rules.
CFG stands for Context Free Grammar. It is used to define the syntax of programming languages.
Top down parsing starts from the start symbol and tries to derive the input string.
Bottom up parsing starts from input tokens and reduces them to the start symbol.
Syntax Directed Definition attaches semantic rules to grammar productions.
CFG, predictive parsing, LR parsers, SLR, LALR and syntax directed definitions are important.
CFG, parsing, LR parsers and syntax directed definitions are frequently asked in RGPV exams.
Unit 2 builds the base for semantic analysis, type checking and code generation.
Parsing, grammar and compiler concepts are useful for GATE, interviews and programming language design.