06-06-2012, 02:08 PM
Compiler design
![Microsoft PowerPoint Document .ppt](https://studentbank.in/images/attachtypes/ppt.gif)
What is a Compiler?
Example of tasks of compiler
1. Add two numbers
2. Move numbers from one location to another
3. Move information between CPU and memory
Lexical Analysis
First phase of compiler
isolate words/tokens
Example of tokens:
key words – while, procedure, var, for,..
identifier – declared by the programmer
Operators – +, -, *, /, <>, …
Numeric – numbers such as 124, 12.35, 0.09E-23, etc.
Character constants
Special characters
Comments
Syntax Analysis
What is Syntax Analysis?
Second phase of the compiler
Also called Parser
What is the Parsing Problem?
How is the Parsing problem solved?
Example
Process to construct a Pushdown Machine
Build a table with each column labeled by a terminal symbol (and endmarker ) and each row labeled by a nonterminal or terminal symbol (and bottom marker )
For each grammar rule of the form A a, fill in the cell in row A and column a with with: REP(ra), retain, where r represents reversed
Fill in the cell in row a and column a with pop, advance, for each terminal symbol a.
Fill in the cell in row and column with Accept.
Fill in all other cells with Reject.
Initialize the stack with and the starting terminal.