


















































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Notes on compiler fundamentals, including the role of projects, new tools like javacc, managing large scale projects, and advanced programming techniques. It covers the basics of what a compiler is, its components such as parser, lexical analyzer, linker, and code generator, and the importance of decomposition in software engineering. The document also discusses lexical analysis, deterministic finite automata (dfas), and regular expressions in the context of compiler design.
Typology: Study notes
1 / 58
This page cannot be seen from the preview
Don't miss anything!



















































David Galles
Department of Computer Science University of San Francisco
01-0:
Teams of up to 2 Grading Policies Questions?
01-2:
Using new tools (JavaCC) Managing a large scale project Lots of complex classes & advancedprogramming techniques.
01-3:
Using new tools (JavaCC) Managing a large scale project Lots of complex classes & advancedprogramming techniques. START EARLY!
Projects will take longer than you think(especially starting with the semantic analyzerproject) ASK QUESTIONS!
01-5:
Parser
Lexical Analyzer
Linker
SourceFile
TokenStream
Semantic Analyzer^ Assembly TreeGenerator
AbstractAssemblyTree
AbstractSyntax Tree
Code Generator
Assembly Assembler
RelocatableObjectCode
Libraries
Machine code
More Accurate View
01-6:
Parser
Lexical Analyzer
Linker
SourceFile
TokenStream
Semantic
Analyzer Assembly
Tree Generator
AbstractAssemblyTree
AbstractSyntax
Tree
Code Generator
Assembly Assembler
RelocatableObjectCode
Libraries
Machine
code
Front
end Back
End
01-8:
01-9:
Software Engineering!
Smaller units are easier to write, test and debug Code Reuse
Writing a suite of compilers (C, Fortran, C++,etc) for a new architecture Create a new language โ want compilersavailable for several platforms
01-11:
01-12:
Brute-Force Approach
Lots of nested if statements if (c = nextchar() == โPโ) { if (c = nextchar() == โRโ) { if (c = nextchar() == โ0โ) {
if (c = nextchar() == โGโ) {/*
Code to handle the rest of eitherPROGRAM or any identifier that startswith PROG/ } else if (c == โCโ) {/
Code to handle the rest of eitherPROCEDURE or any identifier that startswith PROC*/ ...
01-14:
DFA for else, end, identifiersCombine DFA
01-15:
01-17:
: Set of all possible symbols
(characters) in the input file
Think of
as the set of symbols on the
keyboard
: Sequence of symbols from an alphabet
string:
: Set of strings over an
alphabet Formal Language
Programming language โ Formal
Language is only a set of strings.
01-18:
Example formal languages:
Integers
Floating Point Numbers
Identifiers {foo, bar,