21 cards · Public · Shuffle

Compiler Design - Lexical Analysis, Parsing & Intermediate Code Generation

Master the core phases of compiler design, including lexical tokenization, finite automata, context-free grammars, parsing algorithms, and intermediate representation generation.

Cards in this deck

(21 cards)

Preview terms and definitions before starting your study session.

#1
Term
Compiler Architecture: Front-End vs. Back-End
Definition
A compiler is split into two main sections:
  • Front-End: Source-language dependent. Consists of Lexical Analysis, Syntax Analysis, Semantic Analysis, and Intermediate Code Generation.
  • Back-End: Target-machine dependent. Consists of Intermediate Code Optimization and Target Code Generation.
#2
Term
Lexical Analyzer (Scanner)
Definition
The first phase of a compiler. It reads the raw stream of source characters, strips whitespace/comments, and groups characters into meaningful sequences called lexemes, producing a stream of tokens for the parser.
#3
Term
Token vs. Lexeme vs. Pattern
Definition
  • Token: An abstract category returned by the scanner (e.g., id, num, if).
  • Lexeme: The actual character string in the source code matching a token (e.g., total, 42).
  • Pattern: The formal rule (usually a Regular Expression) describing how a lexeme is formed.
#4
Term
NFA vs. DFA
Definition
  • Nondeterministic Finite Automata (NFA): Can have -transitions (spontaneous state changes) and multiple outgoing transitions for a single input character from a given state.
  • Deterministic Finite Automata (DFA): Has no -transitions and exactly one deterministic transition per input character for each state. Preferred for fast run-time lexical analysis.
#5
Term
Thompson's Construction & Subset Construction
Definition
  • Thompson's Construction: Converts a Regular Expression into an equivalent NFA.
  • Subset Construction (Powerset Construction): Converts an NFA into an equivalent DFA by mapping NFA state sets to individual DFA states.
#6
Term
Context-Free Grammar (CFG)
Definition
A formal grammar used to specify the syntactic structure of a programming language, where:
  • : Non-terminals
  • : Terminals
  • : Production rules of the form ()
  • : Start symbol
#7
Term
Ambiguous Grammar
Definition
A grammar is ambiguous if there exists at least one string that yields more than one distinct parse tree (or left-most / right-most derivation). Ambiguity must be eliminated by enforcing operator precedence and associativity rules.
#8
Term
Left Recursion & Its Elimination
Definition
A grammar has immediate left recursion if it contains a rule . Left recursion causes top-down parsers to loop infinitely. It is eliminated by replacing the rule with:
Showing 8 of 21 cards in this deck.
Study All Now