0% found this document useful (0 votes)
43 views13 pages

Introduction To Compiler Construction

This document provides an introduction to the objectives and topics covered in a compiler construction course. The course will cover the design and implementation of compilers, including lexical analysis, syntax analysis, semantic analysis, code generation, and optimization techniques. Students will learn how to build a compiler for a programming language from the analysis of source code to the generation of executable target code. The course will use tools like lex/flex for scanners and yacc/bison for parsers to implement various phases of a compiler.

Uploaded by

SurendraSurender
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
43 views13 pages

Introduction To Compiler Construction

This document provides an introduction to the objectives and topics covered in a compiler construction course. The course will cover the design and implementation of compilers, including lexical analysis, syntax analysis, semantic analysis, code generation, and optimization techniques. Students will learn how to build a compiler for a programming language from the analysis of source code to the generation of executable target code. The course will use tools like lex/flex for scanners and yacc/bison for parsers to implement various phases of a compiler.

Uploaded by

SurendraSurender
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 13

IntroductiontoCompiler

Construction

http://www.cs.fsu.edu/~engelen/courses/COP5621

Syllabus
Textbook:Compilers:Principles,
Techniques,andToolsbyAho,Sethi,and
Ullman
Formoreuptodateinfo:
http://www.cs.fsu.edu/~engelen/courses/
COP5621

AssignmentsandSchedule

http://www.cs.fsu.edu/~engelen/courses/COP5621/assign.html

Objectives
Knowhowtobuildacompilerfora(simplified)
(programming)language
Knowhowtousecompilerconstructiontools,suchas
generatorsforscannersandparsers
Befamiliarwithvirtualmachines,suchastheJVMand
Javabytecode
BeabletowriteLL(1),LR(1),andLALR(1)grammars(for
newlanguages)
Befamiliarwithcompileranalysisandoptimization
techniques
learnhowtoworkonalargersoftwareproject!

CompilersandInterpreters
Compilation
Translationofaprogramwritteninasource
languageintoasemanticallyequivalent
programwritteninatargetlanguage

Input

Source
Program

Target
Program

Compiler

Errormessages

Output

CompilersandInterpreters
(contd)
Interpretation
Performingtheoperationsimpliedbythe
sourceprogram

Source
Program

Interpreter

Output

Input

Errormessages

TheAnalysisSynthesisModelof
Compilation
Therearetwopartstocompilation:
Analysisdeterminestheoperationsimpliedby
thesourceprogramwhicharerecordedinatree
structure
Synthesistakesthetreestructureandtranslates
theoperationsthereinintothetargetprogram

OtherToolsthatUsethe
AnalysisSynthesisModel

Editors(syntaxhighlighting)
Prettyprinters(e.g.doxygen)
Staticcheckers(e.g.lintandsplint)
Interpreters
Textformatters(e.g.TeXandLaTeX)
Siliconcompilers(e.g.VHDL)
Queryinterpreters/compilers(Databases)

Preprocessors,Compilers,
Assemblers,andLinkers
SkeletalSourceProgram
Preprocessor
SourceProgram
Compiler
TargetAssemblyProgram
Assembler
RelocatableObjectCode
Linker

AbsoluteMachineCode

Tryforexample:
gcc -v myprog.c

Librariesand
RelocatableObjectFiles

ThePhasesofaCompiler
Phase

Output

Sample

Programmer

Sourcestring

A=B+C;

Scanner(performslexical
analysis)

Tokenstring

A, =, B, +, C, ;
Andsymboltableforidentifiers

Parser(performssyntaxanalysis Parsetreeorabstractsyntaxtree
basedonthegrammarofthe
programminglanguage)

;
|
=
/ \
A

+
/ \
B

Semanticanalyzer(type
checking,etc)

Parsetreeorabstractsyntaxtree

Intermediatecodegenerator

Threeaddresscode,quads,or
RTL

int2fp B
+
t1
:=
t2

Optimizer

Threeaddresscode,quads,or
RTL

int2fp B
+
t1

Codegenerator

Assemblycode

MOVF #2.3,r1
ADDF2 r1,r2
MOVF r2,A

Peepholeoptimizer

Assemblycode

#2.3

ADDF2 #2.3,r2
MOVF r2,A

t1
t2
A
t1
A

TheGroupingofPhases
Compilerfrontandbackends:
Analysis(machineindependentfrontend)
Synthesis(machinedependentbackend)

Passes
Acollectionofphasesmayberepeatedonlyonce
(singlepass)ormultipletimes(multipass)
Singlepass:usuallyrequireseverythingtobedefined
beforebeingusedinsourceprogram
Multipass:compilermayhavetokeepentireprogram
representationinmemory

CompilerConstructionTools
Softwaredevelopmenttoolsareavailableto
implementoneormorecompilerphases

Scannergenerators
Parsergenerators
Syntaxdirectedtranslationengines
Automaticcodegenerators
Dataflowengines

Outline

Ch.1:Introduction
Ch.2:AsimpleOnePassCompilerfortheJVM
Ch.3:LexicalAnalysisandLex/Flex
Ch.4:SyntaxAnalysisandYacc/Bison
Ch.5:SyntaxDirectedTranslation
Ch.6:TypeChecking
Ch.7:RunTimeEnvironments
Ch.8:IntermediateCodeGeneration
Ch.9:CodeGeneration
Ch.10:CodeOptimization

You might also like