Beruflich Dokumente
Kultur Dokumente
COMPILER CONSTRUCTION
1. FOUNDATIONS
Mahalingam P. R, Assistant Professor, Computer Science and Engineering
Number of sessions 2
1. Lectures on automata and grammar 1. Aho A Ravi Sethi and J D Ullman, Compilers Principles
2. Tutorial on designing translator from English to Malayalam Techniques and Tools,Addison Wesley
3. Analogies between NLP and compilers 2. Kenneth C Louden, Compiler Construction Principles and
Practice, Cenage Learning Indian Edition
3. Tremblay and Sorenson, The Theory and Practice of Compiler
Writing - Tata McGraw Hill & Company
About Finite Automata
A finite automaton (FA) is a simple idealized machine used to recognize patterns within input taken from some character set (or
alphabet). The job of an FA is to accept or reject an input depending on whether the pattern defined by the FA occurs in the US
input.
A finite automaton consists of A=(Q,S,d,q0,F) IN
a finite set of N states G
a special start state
a set of final (or accepting) states TH
a set of transitions from one state to another, labeled with chars
We can represent a FA graphically, with nodes for states, and arcs for transitions.
E
PI
Executing the Automaton Modeling Finite Automata
A context-free grammar (CFG) is a set of recursive rewriting rules (or productions) used to generate patterns of strings.
A CFG consists of G=(V,T,S,P) US
a set of terminal symbols, which are the characters of the alphabet that appear in the strings generated by the grammar.
a set of nonterminal symbols, which are placeholders for patterns of terminal symbols that can be generated by the
IN
nonterminal symbols. G
a set of productions, which are rules for replacing (or rewriting) nonterminal symbols (on the left side of the production) in a
string with other nonterminal or terminal symbols (on the right side of the production). TH
a start symbol, which is a special nonterminal symbol that appears in the initial string generated by the grammar.
E
PI
Executing the Grammar Modeling Grammar as Trees
Interpreters
Compilers (& interpreters) are everywhere
o Many applications have embedded languages
A program that reads an executable program
and produces the results of executing that (XML, HTML, macros, commands, Visual Basic in Excel, )
program o Many applications have input formats that look like languages
Variety of abstractions
Python & Scheme are typically interpreted o Ranging from object orientation to hash maps to closures to ...
o Each of these abstractions has a price
o Understand the costs and make intelligent decisions about when to
replace an abstraction with a more efficient & concrete
Combination implementation. It can be the difference between a fast system & a
slow (or infeasible) one
Java is complicated
compiled to bytecode (code for the Java In many applications, performance matters.
VM ) which are then interpreted o Design at the appropriate level of abstraction
or a hybrid strategy is used Just-in-Time o Measure where the application spends time
compilation o In those places, replace the abstract implementation with a
semantically equivalent implementation that is faster and more
concrete
o Repeat until you are happy with the results
Phases of a compiler