Compiler Construction: Mohamed Zahran (Aka Z) Mzahran@cs - Nyu.edu
Compiler Construction: Mohamed Zahran (Aka Z) Mzahran@cs - Nyu.edu
Compiler Construction: Mohamed Zahran (Aka Z) Mzahran@cs - Nyu.edu
2130-001
Compiler Construction
Mohamed Zahran (aka Z)
[email protected]
Who Am I?
• Mohamed Zahran (aka Z)
• Computer architecture/OS/Compilers
Interaction
• http://www.mzahran.com
• Office hours: Thursdays 5:00-7:00 pm
• Room: CIWW 328
• Course web page:
http://www.cs.nyu.edu/courses/spring11/G22.2130-001/
Formal Goals of This Course
• What exactly is this thing called
compiler?
• How does the compiler interact with the
hardware and programming languages?
• Different phases of a compiler
• Develop a simple compiler
Informal Goals of This Course
• To get more than an A
• To learn compilers and enjoy it
• To use what you have learned in MANY
different contexts
Grading
• The project (labs): 60%
– Due several lectures later
– Several parts
– Mostly programming and dealing with tools
– Can do on your own machine or NYU machines
– Must be sure that they work on NYU machines
– Getting help: office hours, mailing list, and FAQ
Compiler writers
Compiler writers have to track
must take advantage
new language features
of new hardware features
Compilers
Interpretation
Problem Algorithm Development Programmer
Compiler (translator)
Assembly Language
Assembler (translator)
Machine Language
Microarchitecture
Microsequencer (Interpreter)
Logic Level
Front-end
(Analysis Phase)
Back-End
(Synthesis Phase)
Lexical Analysis
• Reads stream of characters: your program
• Groups the characters into meaningful
sequences: lexemes
• For each lexeme, it produces a token
<token-name, attribute value>
• Blanks are just separators and are
discarded
• Filters comments
• Recognizes: keywords, identifier,
numbers, …
Token stream
• Procedures vs Functions
• Scope
Roadmap
• Today we have mostly discussed chap 1
• Chapter 2 gives an overview of the
different phases of a compiler by
building the front-end of a simple
compiler
• Chapters 3-8 fill the gaps