SlideShare a Scribd company logo
Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 10: Compiler I: Syntax Analysis slide 1
www.nand2tetris.org
Building a Modern Computer From First Principles
Compiler I: Syntax Analysis
Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 10: Compiler I: Syntax Analysis slide 2
Course map
Assembler
Chapter 6
H.L. Language
&
Operating Sys.
abstract interface
Compiler
Chapters 10 - 11
VM Translator
Chapters 7 - 8
Computer
Architecture
Chapters 4 - 5
Gate Logic
Chapters 1 - 3 Electrical
Engineering
Physics
Virtual
Machine
abstract interface
Software
hierarchy
Assembly
Language
abstract interface
Hardware
hierarchy
Machine
Language
abstract interface
Hardware
Platform
abstract interface
Chips &
Logic Gates
abstract interface
Human
Thought
Abstract design
Chapters 9, 12
Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 10: Compiler I: Syntax Analysis slide 3
Motivation: Why study about compilers?
Because Compilers …
Are an essential part of applied computer science
Are very relevant to computational linguistics
Are implemented using classical programming techniques
Employ important software engineering principles
Train you in developing software for transforming one structure to
another (programs, files, transactions, …)
Train you to think in terms of ”description languages”.
Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 10: Compiler I: Syntax Analysis slide 4
The big picture
. . .
RISC
machine
other digital platforms, each equipped
with its VM implementation
RISC
machine
language
Hack
computer
Hack
machine
language
CISC
machine
language
CISC
machine
. . .
written in
a high-level
language
Any
computer
. . .
HW
lectures
(Projects
1-6)
Intermediate code
VM
implementation
over CISC
platforms
VM imp.
over RISC
platforms
VM imp.
over the Hack
platform
VM
emulator
VM
lectures
(Projects
7-8)
Some Other
language
Jack
language
Some
compiler Some Other
compiler
Jack
compiler
. . .Some
language
. . .
Compiler
lectures
(Projects
10,11)
Modern compilers
are two-tiered:
Front-end:
from high-level
language to some
intermediate
language
Back-end:
from the
intermediate
language to
binary code.
Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 10: Compiler I: Syntax Analysis slide 5
Compiler architecture (front end)
. . .
Intermediate code
RISC
machine
language
Hack
machine
language
CISC
machine
language
. . .
written in
a high-level
language
. . .
VM
implementation
over CISC
platforms
VM imp.
over RISC
platforms
VM imp.
over the Hack
platform
VM
emulator
Some Other
language
Jack
language
Some
compiler Some Other
compiler
Jack
compiler
. . .Some
language
. . .
Syntax analysis: understanding the semantics implied by the source code
Code generation: reconstructing the semantics using the syntax of the
target code.
Tokenizing: creating a stream of “atoms”
Parsing: matching the atom stream with the language grammar
XML output = one way to demonstrate that the syntax analyzer works
(Chapter 11)Jack
Program
Toke-
nizer
Parser
Code
Gene
-ration
Syntax Analyzer
Jack Compiler
VM
code
XML
code
(Chapter 10)
(source) (target)
Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 10: Compiler I: Syntax Analysis slide 6
Tokenizing / Lexical analysis
Remove white space
Construct a token list (language atoms)
Things to worry about:
Language specific rules:
e.g. how to treat “++”
Language-specific classifications:
keyword, symbol, identifier, integerCconstant, stringConstant,...
While we are at it, we can have the tokenizer record not only the token, but
also its lexical classification (as defined by the source language grammar).
Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 10: Compiler I: Syntax Analysis slide 7
Jack Tokenizer
if (x < 153) {let city = ”Paris”;}if (x < 153) {let city = ”Paris”;}
Source code
<tokens>
<keyword> if </keyword>
<symbol> ( </symbol>
<identifier> x </identifier>
<symbol> &lt; </symbol>
<integerConstant> 153 </integerConstant>
<symbol> ) </symbol>
<symbol> { </symbol>
<keyword> let </keyword>
<identifier> city </identifier>
<symbol> = </symbol>
<stringConstant> Paris </stringConstant>
<symbol> ; </symbol>
<symbol> } </symbol>
</tokens>
<tokens>
<keyword> if </keyword>
<symbol> ( </symbol>
<identifier> x </identifier>
<symbol> &lt; </symbol>
<integerConstant> 153 </integerConstant>
<symbol> ) </symbol>
<symbol> { </symbol>
<keyword> let </keyword>
<identifier> city </identifier>
<symbol> = </symbol>
<stringConstant> Paris </stringConstant>
<symbol> ; </symbol>
<symbol> } </symbol>
</tokens>
Tokenizer’s output
Tokenizer
Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 10: Compiler I: Syntax Analysis slide 8
Parsing
The tokenizer discussed thus far is part of a larger program called parser
Each language is characterized by a grammar.
The parser is implemented to recognize this grammar in given texts
The parsing process:
A text is given and tokenized
The parser determines weather or not the text can be generated from
the grammar
In the process, the parser performs a complete structural analysis of
the text
The text can be in an expression in a :
Natural language (English, …)
Programming language (Jack, …).
Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 10: Compiler I: Syntax Analysis slide 9
Parsing examples
(5+3)*2 – sqrt(9*4) she discussed sex with her doctor
-
5
sqrt
+
*
3
2
9 4
*
Jack English
discussed
she sex
with
her doctor
parse 1
discussed
she with
her doctor
parse 2
sex
Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 10: Compiler I: Syntax Analysis slide 10
More examples of challenging parsing
We gave the monkeys the bananas because they were hungry
We gave the monkeys the bananas because they were over-ripe
I never said she stole my money
I never said she stole my money
I never said she stole my money
I never said she stole my money
I never said she stole my money
I never said she stole my money
I never said she stole my money
I never said she stole my money
Time flies like an arrow
Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 10: Compiler I: Syntax Analysis slide 11
Simple (terminal) forms / complex (non-terminal) forms
Grammar = set of rules on how to construct complex forms from simpler forms
Highly recursive.
A typical grammar of a typical C-like language
while (expression) {
if (expression)
statement;
while (expression) {
statement;
if (expression)
statement;
}
while (expression) {
statement;
statement;
}
}
if (expression) {
statement;
while (expression)
statement;
statement;
}
if (expression)
if (expression)
statement;
}
while (expression) {
if (expression)
statement;
while (expression) {
statement;
if (expression)
statement;
}
while (expression) {
statement;
statement;
}
}
if (expression) {
statement;
while (expression)
statement;
statement;
}
if (expression)
if (expression)
statement;
}
Code sample
program: statement;
statement: whileStatement
| ifStatement
| // other statement possibilities ...
| '{' statementSequence '}'
whileStatement: 'while' '(' expression ')' statement
ifStatement: simpleIf
| ifElse
simpleIf: 'if' '(' expression ')' statement
ifElse: 'if' '(' expression ')' statement
'else' statement
statementSequence: '' // null, i.e. the empty sequence
| statement ';' statementSequence
expression: // definition of an expression comes here
// more definitions follow
program: statement;
statement: whileStatement
| ifStatement
| // other statement possibilities ...
| '{' statementSequence '}'
whileStatement: 'while' '(' expression ')' statement
ifStatement: simpleIf
| ifElse
simpleIf: 'if' '(' expression ')' statement
ifElse: 'if' '(' expression ')' statement
'else' statement
statementSequence: '' // null, i.e. the empty sequence
| statement ';' statementSequence
expression: // definition of an expression comes here
// more definitions follow
Grammar
Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 10: Compiler I: Syntax Analysis slide 12
Parse tree
while . . .( )count <= 100 { count ++
statement
whileStatement
expression
statementSequence
statement
;
statement statementSequence
Input Text:
while (count<=100) {
/** demonstration */
count++;
// ...
Tokenized:
while
(
count
<=
100
)
{
count
++
;
...
program: statement;
statement: whileStatement
| ifStatement
| // other statement possibilities ...
| '{' statementSequence '}'
whileStatement: 'while'
'(' expression ')'
statement
...
program: statement;
statement: whileStatement
| ifStatement
| // other statement possibilities ...
| '{' statementSequence '}'
whileStatement: 'while'
'(' expression ')'
statement
...
Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 10: Compiler I: Syntax Analysis slide 13
Recursive descent parsing
Parser implementation: a set of parsing
methods, one for each rule:
parseStatement()
parseWhileStatement()
parseIfStatement()
parseStatementSequence()
parseExpression().
Highly recursive
LL(0) grammars: the first token
determines in which rule we are
In other grammars you have to
look ahead 1 or more tokens
Jack is almost LL(0).
while (expression) {
statement;
statement;
while (expression) {
while (expression)
statement;
statement;
}
}
while (expression) {
statement;
statement;
while (expression) {
while (expression)
statement;
statement;
}
}
code sample
Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 10: Compiler I: Syntax Analysis slide 14
A linguist view on parsing
Parsing:
One of the mental processes involved
in sentence comprehension, in which
the listener determines the syntactic
categories of the words, joins them
up in a tree, and identifies the
subject, object, and predicate, a
prerequisite to determining who did
what to whom from the information in
the sentence.
(Steven Pinker,
The Language Instinct)
Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 10: Compiler I: Syntax Analysis slide 15
The Jack grammar
’x’: x appears verbatim
x: x is a language construct
x?: x appears 0 or 1 times
x*: x appears 0 or more times
x|y: either x or y appears
(x,y): x appears, then y.
’x’: x appears verbatim
x: x is a language construct
x?: x appears 0 or 1 times
x*: x appears 0 or more times
x|y: either x or y appears
(x,y): x appears, then y.
Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 10: Compiler I: Syntax Analysis slide 16
The Jack grammar (cont.)
’x’: x appears verbatim
x: x is a language construct
x?: x appears 0 or 1 times
x*: x appears 0 or more times
x|y: either x or y appears
(x,y): x appears, then y.
’x’: x appears verbatim
x: x is a language construct
x?: x appears 0 or 1 times
x*: x appears 0 or more times
x|y: either x or y appears
(x,y): x appears, then y.
Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 10: Compiler I: Syntax Analysis slide 17
Jack syntax analyzer in action
Class Bar {
method Fraction foo(int y) {
var int temp; // a variable
let temp = (xxx+12)*-63;
...
...
Class Bar {
method Fraction foo(int y) {
var int temp; // a variable
let temp = (xxx+12)*-63;
...
...
Syntax analyzer
Using the language grammar,
a programmer can write
a syntax analyzer program (parser)
The syntax analyzer takes a source text
file and attempts to match it on the
language grammar
If successful, it can generate a parse tree
in some structured format, e.g. XML.
<varDec>
<keyword> var </keyword>
<keyword> int </keyword>
<identifier> temp </identifier>
<symbol> ; </symbol>
</varDec>
<statements>
<letStatement>
<keyword> let </keyword>
<identifier> temp </identifier>
<symbol> = </symbol>
<expression>
<term>
<symbol> ( </symbol>
<expression>
<term>
<identifier> xxx </identifier>
</term>
<symbol> + </symbol>
<term>
<int.Const.> 12 </int.Const.>
</term>
</expression>
...
<varDec>
<keyword> var </keyword>
<keyword> int </keyword>
<identifier> temp </identifier>
<symbol> ; </symbol>
</varDec>
<statements>
<letStatement>
<keyword> let </keyword>
<identifier> temp </identifier>
<symbol> = </symbol>
<expression>
<term>
<symbol> ( </symbol>
<expression>
<term>
<identifier> xxx </identifier>
</term>
<symbol> + </symbol>
<term>
<int.Const.> 12 </int.Const.>
</term>
</expression>
...
Syntax analyzer
The syntax analyzer’s algorithm shown in this slide:
If xxx is non-terminal, output:
<xxx>
Recursive code for the body of xxx
</xxx>
If xxx is terminal (keyword, symbol, constant, or identifier) ,
output:
<xxx>
xxx value
</xxx>
Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 10: Compiler I: Syntax Analysis slide 18
JackTokenizer: a tokenizer for the Jack language (proposed implementation)
Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 10: Compiler I: Syntax Analysis slide 19
JackTokenizer (cont.)
Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 10: Compiler I: Syntax Analysis slide 20
CompilationEngine: a recursive top-down parser for Jack
The CompilationEngine effects the actual compilation output.
It gets its input from a JackTokenizer and emits its parsed structure into an
output file/stream.
The output is generated by a series of compilexxx() routines, one for every
syntactic element xxx of the Jack grammar.
The contract between these routines is that each compilexxx() routine should
read the syntactic construct xxx from the input, advance() the tokenizer
exactly beyond xxx, and output the parsing of xxx.
Thus, compilexxx()may only be called if indeed xxx is the next syntactic
element of the input.
In the first version of the compiler, which we now build, this module emits a
structured printout of the code, wrapped in XML tags (defined in the specs of
project 10). In the final version of the compiler, this module generates
executable VM code (defined in the specs of project 11).
In both cases, the parsing logic and module API are exactly the same.
Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 10: Compiler I: Syntax Analysis slide 21
CompilationEngine (cont.)
Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 10: Compiler I: Syntax Analysis slide 22
CompilationEngine (cont.)
Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 10: Compiler I: Syntax Analysis slide 23
CompilationEngine (cont.)
Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 10: Compiler I: Syntax Analysis slide 24
Summary and next step
(Chapter 11)Jack
Program
Toke-
nizer
Parser
Code
Gene
-ration
Syntax Analyzer
Jack Compiler
VM
code
XML
code
(Chapter 10)
Syntax analysis: understanding syntax
Code generation: constructing semantics
The code generation challenge:
Extend the syntax analyzer into a full-blown compiler that, instead of
generating passive XML code, generates executable VM code
Two challenges: (a) handling data, and (b) handling commands.
Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 10: Compiler I: Syntax Analysis slide 25
Perspective
The parse tree can be constructed on the fly
Syntax analyzers can be built using:
Lex tool for tokenizing
Yacc tool for parsing
Do everything from scratch (our approach ...)
The Jack language is intentionally simple:
Statement prefixes: let, do, ...
No operator priority
No error checking
Basic data types, etc.
Richer languages require more powerful compilers
The Jack compiler: designed to illustrate the key ideas that underlie modern
compilers, leaving advanced features to more advanced courses
Industrial-strength compilers:
Have good error diagnostics
Generate tight and efficient code
Support parallel (multi-core) processors.

More Related Content

What's hot

Lecture 07 virtual machine i
Lecture 07 virtual machine iLecture 07 virtual machine i
Lecture 07 virtual machine i
鍾誠 陳鍾誠
 
Sequential logic
Sequential logicSequential logic
Sequential logic
鍾誠 陳鍾誠
 
nand2tetris 舊版投影片 -- 第三章 循序邏輯
nand2tetris 舊版投影片 -- 第三章 循序邏輯nand2tetris 舊版投影片 -- 第三章 循序邏輯
nand2tetris 舊版投影片 -- 第三章 循序邏輯
鍾誠 陳鍾誠
 
nand2tetris 舊版投影片 -- 第四章 機器語言
nand2tetris 舊版投影片 -- 第四章 機器語言nand2tetris 舊版投影片 -- 第四章 機器語言
nand2tetris 舊版投影片 -- 第四章 機器語言
鍾誠 陳鍾誠
 
nand2tetris 舊版投影片 -- 第二章 布林算術
nand2tetris 舊版投影片 -- 第二章 布林算術nand2tetris 舊版投影片 -- 第二章 布林算術
nand2tetris 舊版投影片 -- 第二章 布林算術
鍾誠 陳鍾誠
 
nand2tetris 舊版投影片 -- 第一章 布林邏輯
nand2tetris 舊版投影片 -- 第一章 布林邏輯nand2tetris 舊版投影片 -- 第一章 布林邏輯
nand2tetris 舊版投影片 -- 第一章 布林邏輯
鍾誠 陳鍾誠
 
Lecture 06 assembler
Lecture 06 assemblerLecture 06 assembler
Lecture 06 assembler
鍾誠 陳鍾誠
 
Machine language
Machine languageMachine language
Machine language
鍾誠 陳鍾誠
 
Mutual Exclusion
Mutual ExclusionMutual Exclusion
Mutual Exclusion
David Evans
 
Introduction to Julia for bioinformacis
Introduction to Julia for bioinformacisIntroduction to Julia for bioinformacis
Introduction to Julia for bioinformacis
Kenta Sato
 
Julia - Easier, Better, Faster, Stronger
Julia - Easier, Better, Faster, StrongerJulia - Easier, Better, Faster, Stronger
Julia - Easier, Better, Faster, StrongerKenta Sato
 
interfacing matlab with embedded systems
interfacing matlab with embedded systemsinterfacing matlab with embedded systems
interfacing matlab with embedded systems
Raghav Shetty
 
Matlab Serial Port
Matlab Serial PortMatlab Serial Port
Matlab Serial Port
Roberto Meattini
 
Vb.net ii
Vb.net iiVb.net ii
Vb.net ii
argusacademy
 
KOLEJ KOMUNITI - Sijil Aplikasi Perisian Komputer
KOLEJ KOMUNITI - Sijil Aplikasi Perisian KomputerKOLEJ KOMUNITI - Sijil Aplikasi Perisian Komputer
KOLEJ KOMUNITI - Sijil Aplikasi Perisian Komputer
Aiman Hud
 
(6) collections algorithms
(6) collections algorithms(6) collections algorithms
(6) collections algorithms
Nico Ludwig
 
GUESS FUNDAMENTAL PAPER FOE CCAT Feb 2014
GUESS FUNDAMENTAL PAPER FOE CCAT Feb 2014GUESS FUNDAMENTAL PAPER FOE CCAT Feb 2014
GUESS FUNDAMENTAL PAPER FOE CCAT Feb 2014
prabhatjon
 
Basics of MATLAB programming
Basics of MATLAB programmingBasics of MATLAB programming
Basics of MATLAB programming
Ranjan Pal
 

What's hot (20)

Lecture 07 virtual machine i
Lecture 07 virtual machine iLecture 07 virtual machine i
Lecture 07 virtual machine i
 
Sequential logic
Sequential logicSequential logic
Sequential logic
 
nand2tetris 舊版投影片 -- 第三章 循序邏輯
nand2tetris 舊版投影片 -- 第三章 循序邏輯nand2tetris 舊版投影片 -- 第三章 循序邏輯
nand2tetris 舊版投影片 -- 第三章 循序邏輯
 
nand2tetris 舊版投影片 -- 第四章 機器語言
nand2tetris 舊版投影片 -- 第四章 機器語言nand2tetris 舊版投影片 -- 第四章 機器語言
nand2tetris 舊版投影片 -- 第四章 機器語言
 
nand2tetris 舊版投影片 -- 第二章 布林算術
nand2tetris 舊版投影片 -- 第二章 布林算術nand2tetris 舊版投影片 -- 第二章 布林算術
nand2tetris 舊版投影片 -- 第二章 布林算術
 
nand2tetris 舊版投影片 -- 第一章 布林邏輯
nand2tetris 舊版投影片 -- 第一章 布林邏輯nand2tetris 舊版投影片 -- 第一章 布林邏輯
nand2tetris 舊版投影片 -- 第一章 布林邏輯
 
Lecture 06 assembler
Lecture 06 assemblerLecture 06 assembler
Lecture 06 assembler
 
Machine language
Machine languageMachine language
Machine language
 
Mutual Exclusion
Mutual ExclusionMutual Exclusion
Mutual Exclusion
 
Introduction to Julia for bioinformacis
Introduction to Julia for bioinformacisIntroduction to Julia for bioinformacis
Introduction to Julia for bioinformacis
 
Julia - Easier, Better, Faster, Stronger
Julia - Easier, Better, Faster, StrongerJulia - Easier, Better, Faster, Stronger
Julia - Easier, Better, Faster, Stronger
 
Serial comm matlab
Serial comm matlabSerial comm matlab
Serial comm matlab
 
interfacing matlab with embedded systems
interfacing matlab with embedded systemsinterfacing matlab with embedded systems
interfacing matlab with embedded systems
 
Matlab Serial Port
Matlab Serial PortMatlab Serial Port
Matlab Serial Port
 
Vb.net ii
Vb.net iiVb.net ii
Vb.net ii
 
KOLEJ KOMUNITI - Sijil Aplikasi Perisian Komputer
KOLEJ KOMUNITI - Sijil Aplikasi Perisian KomputerKOLEJ KOMUNITI - Sijil Aplikasi Perisian Komputer
KOLEJ KOMUNITI - Sijil Aplikasi Perisian Komputer
 
(6) collections algorithms
(6) collections algorithms(6) collections algorithms
(6) collections algorithms
 
Matlab workshop
Matlab workshopMatlab workshop
Matlab workshop
 
GUESS FUNDAMENTAL PAPER FOE CCAT Feb 2014
GUESS FUNDAMENTAL PAPER FOE CCAT Feb 2014GUESS FUNDAMENTAL PAPER FOE CCAT Feb 2014
GUESS FUNDAMENTAL PAPER FOE CCAT Feb 2014
 
Basics of MATLAB programming
Basics of MATLAB programmingBasics of MATLAB programming
Basics of MATLAB programming
 

Similar to Lecture 10 compiler i

DLP_Presentation.pptx
DLP_Presentation.pptxDLP_Presentation.pptx
DLP_Presentation.pptx
20CE112YASHPATEL
 
Compiler_Project_Srikanth_Vanama
Compiler_Project_Srikanth_VanamaCompiler_Project_Srikanth_Vanama
Compiler_Project_Srikanth_VanamaSrikanth Vanama
 
Programming Languages Implementation and Design. .docx
  Programming Languages Implementation and Design. .docx  Programming Languages Implementation and Design. .docx
Programming Languages Implementation and Design. .docx
aryan532920
 
1-Information sharing 2-Computation speedup3-Modularity4-.docx
1-Information sharing 2-Computation speedup3-Modularity4-.docx1-Information sharing 2-Computation speedup3-Modularity4-.docx
1-Information sharing 2-Computation speedup3-Modularity4-.docx
SONU61709
 
Ss ui lecture 2
Ss ui lecture 2Ss ui lecture 2
Ss ui lecture 2
Avinash Kapse
 
A Project Based Lab Report On AMUZING JOKE
A Project Based Lab Report On AMUZING JOKEA Project Based Lab Report On AMUZING JOKE
A Project Based Lab Report On AMUZING JOKE
Daniel Wachtel
 
Article link httpiveybusinessjournal.compublicationmanaging-.docx
Article link httpiveybusinessjournal.compublicationmanaging-.docxArticle link httpiveybusinessjournal.compublicationmanaging-.docx
Article link httpiveybusinessjournal.compublicationmanaging-.docx
fredharris32
 
Boo Manifesto
Boo ManifestoBoo Manifesto
Boo Manifesto
hu hans
 
Pcd question bank
Pcd question bank Pcd question bank
Pcd question bank
Sumathi Gnanasekaran
 
The program reads data from two files, itemsList-0x.txt and .docx
The program reads data from two files, itemsList-0x.txt and .docxThe program reads data from two files, itemsList-0x.txt and .docx
The program reads data from two files, itemsList-0x.txt and .docx
oscars29
 
Designing A Project Using Java Programming
Designing A Project Using Java ProgrammingDesigning A Project Using Java Programming
Designing A Project Using Java Programming
Katy Allen
 
Cs6660 compiler design may june 2016 Answer Key
Cs6660 compiler design may june 2016 Answer KeyCs6660 compiler design may june 2016 Answer Key
Cs6660 compiler design may june 2016 Answer Key
appasami
 
EnScript Workshop
EnScript WorkshopEnScript Workshop
EnScript Workshop
Mark Morgan, CCE, EnCE
 
These questions will be a bit advanced level 2
These questions will be a bit advanced level 2These questions will be a bit advanced level 2
These questions will be a bit advanced level 2
sadhana312471
 
Let's us c language (sabeel Bugti)
Let's us c language (sabeel Bugti)Let's us c language (sabeel Bugti)
Let's us c language (sabeel Bugti)
Unviersity of balochistan quetta
 
Designing A Syntax Based Retrieval System03
Designing A Syntax Based Retrieval System03Designing A Syntax Based Retrieval System03
Designing A Syntax Based Retrieval System03Avelin Huo
 
Bt0082 visual basic
Bt0082 visual basicBt0082 visual basic
Bt0082 visual basic
Techglyphs
 
Lexical analyzer
Lexical analyzerLexical analyzer
Lexical analyzer
Ashwini Sonawane
 
Compiler_Lecture1.pdf
Compiler_Lecture1.pdfCompiler_Lecture1.pdf
Compiler_Lecture1.pdf
AkarTaher
 

Similar to Lecture 10 compiler i (20)

DLP_Presentation.pptx
DLP_Presentation.pptxDLP_Presentation.pptx
DLP_Presentation.pptx
 
Compiler_Project_Srikanth_Vanama
Compiler_Project_Srikanth_VanamaCompiler_Project_Srikanth_Vanama
Compiler_Project_Srikanth_Vanama
 
Programming Languages Implementation and Design. .docx
  Programming Languages Implementation and Design. .docx  Programming Languages Implementation and Design. .docx
Programming Languages Implementation and Design. .docx
 
1-Information sharing 2-Computation speedup3-Modularity4-.docx
1-Information sharing 2-Computation speedup3-Modularity4-.docx1-Information sharing 2-Computation speedup3-Modularity4-.docx
1-Information sharing 2-Computation speedup3-Modularity4-.docx
 
Ss ui lecture 2
Ss ui lecture 2Ss ui lecture 2
Ss ui lecture 2
 
A Project Based Lab Report On AMUZING JOKE
A Project Based Lab Report On AMUZING JOKEA Project Based Lab Report On AMUZING JOKE
A Project Based Lab Report On AMUZING JOKE
 
Article link httpiveybusinessjournal.compublicationmanaging-.docx
Article link httpiveybusinessjournal.compublicationmanaging-.docxArticle link httpiveybusinessjournal.compublicationmanaging-.docx
Article link httpiveybusinessjournal.compublicationmanaging-.docx
 
Boo Manifesto
Boo ManifestoBoo Manifesto
Boo Manifesto
 
Pcd question bank
Pcd question bank Pcd question bank
Pcd question bank
 
The program reads data from two files, itemsList-0x.txt and .docx
The program reads data from two files, itemsList-0x.txt and .docxThe program reads data from two files, itemsList-0x.txt and .docx
The program reads data from two files, itemsList-0x.txt and .docx
 
Designing A Project Using Java Programming
Designing A Project Using Java ProgrammingDesigning A Project Using Java Programming
Designing A Project Using Java Programming
 
Cs6660 compiler design may june 2016 Answer Key
Cs6660 compiler design may june 2016 Answer KeyCs6660 compiler design may june 2016 Answer Key
Cs6660 compiler design may june 2016 Answer Key
 
EnScript Workshop
EnScript WorkshopEnScript Workshop
EnScript Workshop
 
These questions will be a bit advanced level 2
These questions will be a bit advanced level 2These questions will be a bit advanced level 2
These questions will be a bit advanced level 2
 
Introduction to r
Introduction to rIntroduction to r
Introduction to r
 
Let's us c language (sabeel Bugti)
Let's us c language (sabeel Bugti)Let's us c language (sabeel Bugti)
Let's us c language (sabeel Bugti)
 
Designing A Syntax Based Retrieval System03
Designing A Syntax Based Retrieval System03Designing A Syntax Based Retrieval System03
Designing A Syntax Based Retrieval System03
 
Bt0082 visual basic
Bt0082 visual basicBt0082 visual basic
Bt0082 visual basic
 
Lexical analyzer
Lexical analyzerLexical analyzer
Lexical analyzer
 
Compiler_Lecture1.pdf
Compiler_Lecture1.pdfCompiler_Lecture1.pdf
Compiler_Lecture1.pdf
 

More from 鍾誠 陳鍾誠

用十分鐘瞭解 新竹科學園區的發展史
用十分鐘瞭解  新竹科學園區的發展史用十分鐘瞭解  新竹科學園區的發展史
用十分鐘瞭解 新竹科學園區的發展史
鍾誠 陳鍾誠
 
用十分鐘搞懂 λ-Calculus
用十分鐘搞懂 λ-Calculus用十分鐘搞懂 λ-Calculus
用十分鐘搞懂 λ-Calculus
鍾誠 陳鍾誠
 
交⼤資訊⼯程學系備審資料 ⾱詠祥
交⼤資訊⼯程學系備審資料 ⾱詠祥交⼤資訊⼯程學系備審資料 ⾱詠祥
交⼤資訊⼯程學系備審資料 ⾱詠祥
鍾誠 陳鍾誠
 
smallpt: Global Illumination in 99 lines of C++
smallpt:  Global Illumination in 99 lines of C++smallpt:  Global Illumination in 99 lines of C++
smallpt: Global Illumination in 99 lines of C++
鍾誠 陳鍾誠
 
西洋史 (你或許不知道但卻影響現代教育的那些事)
西洋史  (你或許不知道但卻影響現代教育的那些事)西洋史  (你或許不知道但卻影響現代教育的那些事)
西洋史 (你或許不知道但卻影響現代教育的那些事)
鍾誠 陳鍾誠
 
區塊鏈 (比特幣背後的關鍵技術) -- 十分鐘系列
區塊鏈  (比特幣背後的關鍵技術)   -- 十分鐘系列區塊鏈  (比特幣背後的關鍵技術)   -- 十分鐘系列
區塊鏈 (比特幣背後的關鍵技術) -- 十分鐘系列
鍾誠 陳鍾誠
 
區塊鏈 (比特幣背後的關鍵技術) -- 十分鐘系列
區塊鏈  (比特幣背後的關鍵技術)   -- 十分鐘系列區塊鏈  (比特幣背後的關鍵技術)   -- 十分鐘系列
區塊鏈 (比特幣背後的關鍵技術) -- 十分鐘系列
鍾誠 陳鍾誠
 
梯度下降法 (隱藏在深度學習背後的演算法) -- 十分鐘系列
梯度下降法  (隱藏在深度學習背後的演算法) -- 十分鐘系列梯度下降法  (隱藏在深度學習背後的演算法) -- 十分鐘系列
梯度下降法 (隱藏在深度學習背後的演算法) -- 十分鐘系列
鍾誠 陳鍾誠
 
用十分鐘理解 《微分方程》
用十分鐘理解  《微分方程》用十分鐘理解  《微分方程》
用十分鐘理解 《微分方程》
鍾誠 陳鍾誠
 
系統程式 -- 前言
系統程式 -- 前言系統程式 -- 前言
系統程式 -- 前言
鍾誠 陳鍾誠
 
系統程式 -- 附錄
系統程式 -- 附錄系統程式 -- 附錄
系統程式 -- 附錄
鍾誠 陳鍾誠
 
系統程式 -- 第 12 章 系統軟體實作
系統程式 -- 第 12 章 系統軟體實作系統程式 -- 第 12 章 系統軟體實作
系統程式 -- 第 12 章 系統軟體實作
鍾誠 陳鍾誠
 
系統程式 -- 第 11 章 嵌入式系統
系統程式 -- 第 11 章 嵌入式系統系統程式 -- 第 11 章 嵌入式系統
系統程式 -- 第 11 章 嵌入式系統
鍾誠 陳鍾誠
 
系統程式 -- 第 10 章 作業系統
系統程式 -- 第 10 章 作業系統系統程式 -- 第 10 章 作業系統
系統程式 -- 第 10 章 作業系統
鍾誠 陳鍾誠
 
系統程式 -- 第 9 章 虛擬機器
系統程式 -- 第 9 章 虛擬機器系統程式 -- 第 9 章 虛擬機器
系統程式 -- 第 9 章 虛擬機器
鍾誠 陳鍾誠
 
系統程式 -- 第 8 章 編譯器
系統程式 -- 第 8 章 編譯器系統程式 -- 第 8 章 編譯器
系統程式 -- 第 8 章 編譯器
鍾誠 陳鍾誠
 
系統程式 -- 第 7 章 高階語言
系統程式 -- 第 7 章 高階語言系統程式 -- 第 7 章 高階語言
系統程式 -- 第 7 章 高階語言
鍾誠 陳鍾誠
 
系統程式 -- 第 6 章 巨集處理器
系統程式 -- 第 6 章 巨集處理器系統程式 -- 第 6 章 巨集處理器
系統程式 -- 第 6 章 巨集處理器
鍾誠 陳鍾誠
 
系統程式 -- 第 5 章 連結與載入
系統程式 -- 第 5 章 連結與載入系統程式 -- 第 5 章 連結與載入
系統程式 -- 第 5 章 連結與載入
鍾誠 陳鍾誠
 
系統程式 -- 第 4 章 組譯器
系統程式 -- 第 4 章 組譯器系統程式 -- 第 4 章 組譯器
系統程式 -- 第 4 章 組譯器
鍾誠 陳鍾誠
 

More from 鍾誠 陳鍾誠 (20)

用十分鐘瞭解 新竹科學園區的發展史
用十分鐘瞭解  新竹科學園區的發展史用十分鐘瞭解  新竹科學園區的發展史
用十分鐘瞭解 新竹科學園區的發展史
 
用十分鐘搞懂 λ-Calculus
用十分鐘搞懂 λ-Calculus用十分鐘搞懂 λ-Calculus
用十分鐘搞懂 λ-Calculus
 
交⼤資訊⼯程學系備審資料 ⾱詠祥
交⼤資訊⼯程學系備審資料 ⾱詠祥交⼤資訊⼯程學系備審資料 ⾱詠祥
交⼤資訊⼯程學系備審資料 ⾱詠祥
 
smallpt: Global Illumination in 99 lines of C++
smallpt:  Global Illumination in 99 lines of C++smallpt:  Global Illumination in 99 lines of C++
smallpt: Global Illumination in 99 lines of C++
 
西洋史 (你或許不知道但卻影響現代教育的那些事)
西洋史  (你或許不知道但卻影響現代教育的那些事)西洋史  (你或許不知道但卻影響現代教育的那些事)
西洋史 (你或許不知道但卻影響現代教育的那些事)
 
區塊鏈 (比特幣背後的關鍵技術) -- 十分鐘系列
區塊鏈  (比特幣背後的關鍵技術)   -- 十分鐘系列區塊鏈  (比特幣背後的關鍵技術)   -- 十分鐘系列
區塊鏈 (比特幣背後的關鍵技術) -- 十分鐘系列
 
區塊鏈 (比特幣背後的關鍵技術) -- 十分鐘系列
區塊鏈  (比特幣背後的關鍵技術)   -- 十分鐘系列區塊鏈  (比特幣背後的關鍵技術)   -- 十分鐘系列
區塊鏈 (比特幣背後的關鍵技術) -- 十分鐘系列
 
梯度下降法 (隱藏在深度學習背後的演算法) -- 十分鐘系列
梯度下降法  (隱藏在深度學習背後的演算法) -- 十分鐘系列梯度下降法  (隱藏在深度學習背後的演算法) -- 十分鐘系列
梯度下降法 (隱藏在深度學習背後的演算法) -- 十分鐘系列
 
用十分鐘理解 《微分方程》
用十分鐘理解  《微分方程》用十分鐘理解  《微分方程》
用十分鐘理解 《微分方程》
 
系統程式 -- 前言
系統程式 -- 前言系統程式 -- 前言
系統程式 -- 前言
 
系統程式 -- 附錄
系統程式 -- 附錄系統程式 -- 附錄
系統程式 -- 附錄
 
系統程式 -- 第 12 章 系統軟體實作
系統程式 -- 第 12 章 系統軟體實作系統程式 -- 第 12 章 系統軟體實作
系統程式 -- 第 12 章 系統軟體實作
 
系統程式 -- 第 11 章 嵌入式系統
系統程式 -- 第 11 章 嵌入式系統系統程式 -- 第 11 章 嵌入式系統
系統程式 -- 第 11 章 嵌入式系統
 
系統程式 -- 第 10 章 作業系統
系統程式 -- 第 10 章 作業系統系統程式 -- 第 10 章 作業系統
系統程式 -- 第 10 章 作業系統
 
系統程式 -- 第 9 章 虛擬機器
系統程式 -- 第 9 章 虛擬機器系統程式 -- 第 9 章 虛擬機器
系統程式 -- 第 9 章 虛擬機器
 
系統程式 -- 第 8 章 編譯器
系統程式 -- 第 8 章 編譯器系統程式 -- 第 8 章 編譯器
系統程式 -- 第 8 章 編譯器
 
系統程式 -- 第 7 章 高階語言
系統程式 -- 第 7 章 高階語言系統程式 -- 第 7 章 高階語言
系統程式 -- 第 7 章 高階語言
 
系統程式 -- 第 6 章 巨集處理器
系統程式 -- 第 6 章 巨集處理器系統程式 -- 第 6 章 巨集處理器
系統程式 -- 第 6 章 巨集處理器
 
系統程式 -- 第 5 章 連結與載入
系統程式 -- 第 5 章 連結與載入系統程式 -- 第 5 章 連結與載入
系統程式 -- 第 5 章 連結與載入
 
系統程式 -- 第 4 章 組譯器
系統程式 -- 第 4 章 組譯器系統程式 -- 第 4 章 組譯器
系統程式 -- 第 4 章 組譯器
 

Recently uploaded

South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
Academy of Science of South Africa
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
Scholarhat
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
Levi Shapiro
 
The Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collectionThe Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collection
Israel Genealogy Research Association
 
Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
EduSkills OECD
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Dr. Vinod Kumar Kanvaria
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
Peter Windle
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
DhatriParmar
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
camakaiclarkmusic
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
Balvir Singh
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
EugeneSaldivar
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
David Douglas School District
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
tarandeep35
 
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat  Leveraging AI for Diversity, Equity, and InclusionExecutive Directors Chat  Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
TechSoup
 
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBCSTRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
kimdan468
 
JEE1_This_section_contains_FOUR_ questions
JEE1_This_section_contains_FOUR_ questionsJEE1_This_section_contains_FOUR_ questions
JEE1_This_section_contains_FOUR_ questions
ShivajiThube2
 
Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
chanes7
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
Jisc
 

Recently uploaded (20)

South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
 
The Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collectionThe Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collection
 
Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
 
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat  Leveraging AI for Diversity, Equity, and InclusionExecutive Directors Chat  Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
 
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBCSTRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
 
JEE1_This_section_contains_FOUR_ questions
JEE1_This_section_contains_FOUR_ questionsJEE1_This_section_contains_FOUR_ questions
JEE1_This_section_contains_FOUR_ questions
 
Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
 

Lecture 10 compiler i

  • 1. Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 10: Compiler I: Syntax Analysis slide 1 www.nand2tetris.org Building a Modern Computer From First Principles Compiler I: Syntax Analysis
  • 2. Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 10: Compiler I: Syntax Analysis slide 2 Course map Assembler Chapter 6 H.L. Language & Operating Sys. abstract interface Compiler Chapters 10 - 11 VM Translator Chapters 7 - 8 Computer Architecture Chapters 4 - 5 Gate Logic Chapters 1 - 3 Electrical Engineering Physics Virtual Machine abstract interface Software hierarchy Assembly Language abstract interface Hardware hierarchy Machine Language abstract interface Hardware Platform abstract interface Chips & Logic Gates abstract interface Human Thought Abstract design Chapters 9, 12
  • 3. Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 10: Compiler I: Syntax Analysis slide 3 Motivation: Why study about compilers? Because Compilers … Are an essential part of applied computer science Are very relevant to computational linguistics Are implemented using classical programming techniques Employ important software engineering principles Train you in developing software for transforming one structure to another (programs, files, transactions, …) Train you to think in terms of ”description languages”.
  • 4. Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 10: Compiler I: Syntax Analysis slide 4 The big picture . . . RISC machine other digital platforms, each equipped with its VM implementation RISC machine language Hack computer Hack machine language CISC machine language CISC machine . . . written in a high-level language Any computer . . . HW lectures (Projects 1-6) Intermediate code VM implementation over CISC platforms VM imp. over RISC platforms VM imp. over the Hack platform VM emulator VM lectures (Projects 7-8) Some Other language Jack language Some compiler Some Other compiler Jack compiler . . .Some language . . . Compiler lectures (Projects 10,11) Modern compilers are two-tiered: Front-end: from high-level language to some intermediate language Back-end: from the intermediate language to binary code.
  • 5. Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 10: Compiler I: Syntax Analysis slide 5 Compiler architecture (front end) . . . Intermediate code RISC machine language Hack machine language CISC machine language . . . written in a high-level language . . . VM implementation over CISC platforms VM imp. over RISC platforms VM imp. over the Hack platform VM emulator Some Other language Jack language Some compiler Some Other compiler Jack compiler . . .Some language . . . Syntax analysis: understanding the semantics implied by the source code Code generation: reconstructing the semantics using the syntax of the target code. Tokenizing: creating a stream of “atoms” Parsing: matching the atom stream with the language grammar XML output = one way to demonstrate that the syntax analyzer works (Chapter 11)Jack Program Toke- nizer Parser Code Gene -ration Syntax Analyzer Jack Compiler VM code XML code (Chapter 10) (source) (target)
  • 6. Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 10: Compiler I: Syntax Analysis slide 6 Tokenizing / Lexical analysis Remove white space Construct a token list (language atoms) Things to worry about: Language specific rules: e.g. how to treat “++” Language-specific classifications: keyword, symbol, identifier, integerCconstant, stringConstant,... While we are at it, we can have the tokenizer record not only the token, but also its lexical classification (as defined by the source language grammar).
  • 7. Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 10: Compiler I: Syntax Analysis slide 7 Jack Tokenizer if (x < 153) {let city = ”Paris”;}if (x < 153) {let city = ”Paris”;} Source code <tokens> <keyword> if </keyword> <symbol> ( </symbol> <identifier> x </identifier> <symbol> &lt; </symbol> <integerConstant> 153 </integerConstant> <symbol> ) </symbol> <symbol> { </symbol> <keyword> let </keyword> <identifier> city </identifier> <symbol> = </symbol> <stringConstant> Paris </stringConstant> <symbol> ; </symbol> <symbol> } </symbol> </tokens> <tokens> <keyword> if </keyword> <symbol> ( </symbol> <identifier> x </identifier> <symbol> &lt; </symbol> <integerConstant> 153 </integerConstant> <symbol> ) </symbol> <symbol> { </symbol> <keyword> let </keyword> <identifier> city </identifier> <symbol> = </symbol> <stringConstant> Paris </stringConstant> <symbol> ; </symbol> <symbol> } </symbol> </tokens> Tokenizer’s output Tokenizer
  • 8. Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 10: Compiler I: Syntax Analysis slide 8 Parsing The tokenizer discussed thus far is part of a larger program called parser Each language is characterized by a grammar. The parser is implemented to recognize this grammar in given texts The parsing process: A text is given and tokenized The parser determines weather or not the text can be generated from the grammar In the process, the parser performs a complete structural analysis of the text The text can be in an expression in a : Natural language (English, …) Programming language (Jack, …).
  • 9. Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 10: Compiler I: Syntax Analysis slide 9 Parsing examples (5+3)*2 – sqrt(9*4) she discussed sex with her doctor - 5 sqrt + * 3 2 9 4 * Jack English discussed she sex with her doctor parse 1 discussed she with her doctor parse 2 sex
  • 10. Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 10: Compiler I: Syntax Analysis slide 10 More examples of challenging parsing We gave the monkeys the bananas because they were hungry We gave the monkeys the bananas because they were over-ripe I never said she stole my money I never said she stole my money I never said she stole my money I never said she stole my money I never said she stole my money I never said she stole my money I never said she stole my money I never said she stole my money Time flies like an arrow
  • 11. Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 10: Compiler I: Syntax Analysis slide 11 Simple (terminal) forms / complex (non-terminal) forms Grammar = set of rules on how to construct complex forms from simpler forms Highly recursive. A typical grammar of a typical C-like language while (expression) { if (expression) statement; while (expression) { statement; if (expression) statement; } while (expression) { statement; statement; } } if (expression) { statement; while (expression) statement; statement; } if (expression) if (expression) statement; } while (expression) { if (expression) statement; while (expression) { statement; if (expression) statement; } while (expression) { statement; statement; } } if (expression) { statement; while (expression) statement; statement; } if (expression) if (expression) statement; } Code sample program: statement; statement: whileStatement | ifStatement | // other statement possibilities ... | '{' statementSequence '}' whileStatement: 'while' '(' expression ')' statement ifStatement: simpleIf | ifElse simpleIf: 'if' '(' expression ')' statement ifElse: 'if' '(' expression ')' statement 'else' statement statementSequence: '' // null, i.e. the empty sequence | statement ';' statementSequence expression: // definition of an expression comes here // more definitions follow program: statement; statement: whileStatement | ifStatement | // other statement possibilities ... | '{' statementSequence '}' whileStatement: 'while' '(' expression ')' statement ifStatement: simpleIf | ifElse simpleIf: 'if' '(' expression ')' statement ifElse: 'if' '(' expression ')' statement 'else' statement statementSequence: '' // null, i.e. the empty sequence | statement ';' statementSequence expression: // definition of an expression comes here // more definitions follow Grammar
  • 12. Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 10: Compiler I: Syntax Analysis slide 12 Parse tree while . . .( )count <= 100 { count ++ statement whileStatement expression statementSequence statement ; statement statementSequence Input Text: while (count<=100) { /** demonstration */ count++; // ... Tokenized: while ( count <= 100 ) { count ++ ; ... program: statement; statement: whileStatement | ifStatement | // other statement possibilities ... | '{' statementSequence '}' whileStatement: 'while' '(' expression ')' statement ... program: statement; statement: whileStatement | ifStatement | // other statement possibilities ... | '{' statementSequence '}' whileStatement: 'while' '(' expression ')' statement ...
  • 13. Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 10: Compiler I: Syntax Analysis slide 13 Recursive descent parsing Parser implementation: a set of parsing methods, one for each rule: parseStatement() parseWhileStatement() parseIfStatement() parseStatementSequence() parseExpression(). Highly recursive LL(0) grammars: the first token determines in which rule we are In other grammars you have to look ahead 1 or more tokens Jack is almost LL(0). while (expression) { statement; statement; while (expression) { while (expression) statement; statement; } } while (expression) { statement; statement; while (expression) { while (expression) statement; statement; } } code sample
  • 14. Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 10: Compiler I: Syntax Analysis slide 14 A linguist view on parsing Parsing: One of the mental processes involved in sentence comprehension, in which the listener determines the syntactic categories of the words, joins them up in a tree, and identifies the subject, object, and predicate, a prerequisite to determining who did what to whom from the information in the sentence. (Steven Pinker, The Language Instinct)
  • 15. Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 10: Compiler I: Syntax Analysis slide 15 The Jack grammar ’x’: x appears verbatim x: x is a language construct x?: x appears 0 or 1 times x*: x appears 0 or more times x|y: either x or y appears (x,y): x appears, then y. ’x’: x appears verbatim x: x is a language construct x?: x appears 0 or 1 times x*: x appears 0 or more times x|y: either x or y appears (x,y): x appears, then y.
  • 16. Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 10: Compiler I: Syntax Analysis slide 16 The Jack grammar (cont.) ’x’: x appears verbatim x: x is a language construct x?: x appears 0 or 1 times x*: x appears 0 or more times x|y: either x or y appears (x,y): x appears, then y. ’x’: x appears verbatim x: x is a language construct x?: x appears 0 or 1 times x*: x appears 0 or more times x|y: either x or y appears (x,y): x appears, then y.
  • 17. Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 10: Compiler I: Syntax Analysis slide 17 Jack syntax analyzer in action Class Bar { method Fraction foo(int y) { var int temp; // a variable let temp = (xxx+12)*-63; ... ... Class Bar { method Fraction foo(int y) { var int temp; // a variable let temp = (xxx+12)*-63; ... ... Syntax analyzer Using the language grammar, a programmer can write a syntax analyzer program (parser) The syntax analyzer takes a source text file and attempts to match it on the language grammar If successful, it can generate a parse tree in some structured format, e.g. XML. <varDec> <keyword> var </keyword> <keyword> int </keyword> <identifier> temp </identifier> <symbol> ; </symbol> </varDec> <statements> <letStatement> <keyword> let </keyword> <identifier> temp </identifier> <symbol> = </symbol> <expression> <term> <symbol> ( </symbol> <expression> <term> <identifier> xxx </identifier> </term> <symbol> + </symbol> <term> <int.Const.> 12 </int.Const.> </term> </expression> ... <varDec> <keyword> var </keyword> <keyword> int </keyword> <identifier> temp </identifier> <symbol> ; </symbol> </varDec> <statements> <letStatement> <keyword> let </keyword> <identifier> temp </identifier> <symbol> = </symbol> <expression> <term> <symbol> ( </symbol> <expression> <term> <identifier> xxx </identifier> </term> <symbol> + </symbol> <term> <int.Const.> 12 </int.Const.> </term> </expression> ... Syntax analyzer The syntax analyzer’s algorithm shown in this slide: If xxx is non-terminal, output: <xxx> Recursive code for the body of xxx </xxx> If xxx is terminal (keyword, symbol, constant, or identifier) , output: <xxx> xxx value </xxx>
  • 18. Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 10: Compiler I: Syntax Analysis slide 18 JackTokenizer: a tokenizer for the Jack language (proposed implementation)
  • 19. Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 10: Compiler I: Syntax Analysis slide 19 JackTokenizer (cont.)
  • 20. Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 10: Compiler I: Syntax Analysis slide 20 CompilationEngine: a recursive top-down parser for Jack The CompilationEngine effects the actual compilation output. It gets its input from a JackTokenizer and emits its parsed structure into an output file/stream. The output is generated by a series of compilexxx() routines, one for every syntactic element xxx of the Jack grammar. The contract between these routines is that each compilexxx() routine should read the syntactic construct xxx from the input, advance() the tokenizer exactly beyond xxx, and output the parsing of xxx. Thus, compilexxx()may only be called if indeed xxx is the next syntactic element of the input. In the first version of the compiler, which we now build, this module emits a structured printout of the code, wrapped in XML tags (defined in the specs of project 10). In the final version of the compiler, this module generates executable VM code (defined in the specs of project 11). In both cases, the parsing logic and module API are exactly the same.
  • 21. Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 10: Compiler I: Syntax Analysis slide 21 CompilationEngine (cont.)
  • 22. Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 10: Compiler I: Syntax Analysis slide 22 CompilationEngine (cont.)
  • 23. Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 10: Compiler I: Syntax Analysis slide 23 CompilationEngine (cont.)
  • 24. Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 10: Compiler I: Syntax Analysis slide 24 Summary and next step (Chapter 11)Jack Program Toke- nizer Parser Code Gene -ration Syntax Analyzer Jack Compiler VM code XML code (Chapter 10) Syntax analysis: understanding syntax Code generation: constructing semantics The code generation challenge: Extend the syntax analyzer into a full-blown compiler that, instead of generating passive XML code, generates executable VM code Two challenges: (a) handling data, and (b) handling commands.
  • 25. Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 10: Compiler I: Syntax Analysis slide 25 Perspective The parse tree can be constructed on the fly Syntax analyzers can be built using: Lex tool for tokenizing Yacc tool for parsing Do everything from scratch (our approach ...) The Jack language is intentionally simple: Statement prefixes: let, do, ... No operator priority No error checking Basic data types, etc. Richer languages require more powerful compilers The Jack compiler: designed to illustrate the key ideas that underlie modern compilers, leaving advanced features to more advanced courses Industrial-strength compilers: Have good error diagnostics Generate tight and efficient code Support parallel (multi-core) processors.