Styled Compiler Design Notes
Styled Compiler Design Notes
Compiler
A compiler is a program that translates high-level programming language into machine code. It
Interpreter
An interpreter translates high-level programming language into machine code line-by-line, whereas
Assembler
Phases of Compilation
The phases of a compiler include lexical analysis, syntax analysis, semantic analysis, optimization,
Passes
A pass refers to a single scan through the source code by the compiler, often used in multi-pass
Bootstrapping
Bootstrapping is the process of writing a compiler in the source programming language that it is
intended to compile.
A parser checks the syntax of the code. Classifications include LL parsers, LR parsers, and
predictive parsers.
Parse Tree
A parse tree is a tree representation of the syntactic structure of source code.
T Diagrams
T diagrams are used to show the relationship between a grammar's production rules.
A recursive descent parser is a top-down parser that uses a set of recursive procedures to process
a grammar.
Left Recursion
Left recursion in a grammar occurs when a non-terminal symbol appears as the leftmost symbol in
Left Factoring
rules.
First and Follow are used in predictive parsers to determine which production rule to apply based on
input symbols.
Chomsky's classification divides formal grammars into 4 types: Type 0, Type 1, Type 2, and Type 3.
NFA (Non-deterministic Finite Automaton) can be converted into a DFA (Deterministic Finite
FSA
Finite State Automaton (FSA) is a mathematical model used to recognize patterns in input strings.
Mealy and Moore Machines
A Mealy machine's output depends on the current state and input, whereas a Moore machine's
RE to FSA Conversion
Regular Expressions (RE) can be converted to FSAs using Thomson's construction method.
FSA Minimization
Minimization of an FSA reduces the number of states while maintaining the language it recognizes.
CFG, CFL
Context-Free Grammar (CFG) is used to define context-free languages (CFL). These languages are
Grammar Simplification
Simplification techniques like unit production elimination and null production elimination reduce the
complexity of a grammar.
Ambiguity in CFG
A CFG is ambiguous if there are multiple derivations for a single string, making it difficult to