Presentation is loading. Please wait.

Presentation is loading. Please wait.

COP 4620 / 5625 Programming Language Translation / Compiler Writing Fall 2003 Lecture 1, 08/28/03 Prof. Roy Levow.

Similar presentations


Presentation on theme: "COP 4620 / 5625 Programming Language Translation / Compiler Writing Fall 2003 Lecture 1, 08/28/03 Prof. Roy Levow."— Presentation transcript:

1 COP 4620 / 5625 Programming Language Translation / Compiler Writing Fall 2003 Lecture 1, 08/28/03 Prof. Roy Levow

2 Introduction Compiler is a program that translates –Source Language into –Traget Language – and is written in an Implementation Language

3 Compiler Organization Compiler is divided into 3 main stages –Front-end for Analysis –Semantic Representation & Processing –Back-end for Synthesis (see fig. 1.2 & 1.4)

4 Compiler vs Interpereter (1) Compiler produces “machine” code –Extensive processing of source code –Target machine specific target code –Fast execution (see fig. 1.3)

5 Compiler vs Interpereter (2) Interpreter executes source code –Generates intermediate representation –Software interpretation of code –Slower execution (see fig. 1.3)

6 Why Study Compilers 1.Analysis-Synthesis Paradigm 2.Application of Formalism 3.Use of Program Generating Tools 4.Techniques applicable to other programs 5.Useful algorithms 6.Develop programming skills

7 Abstract Syntax Tree Syntax Tree –Tree representation of syntax of program –Also called Parse Tree (see fig. 1.5)

8 Abstract Syntax Tree (2) Abstract Syntax Tree (AST) –Simplification that preserves key elements (see fig. 1.6) Annotated AST –Adds Attributes to nodes for Context handling (see fig. 1.7)

9 Demo Compiler Grammar for Sample Language Fully parenthesized experssions Operands one digit only Operators: + * (see fig. 1.9)

10 Structure of Demo Compiler Dual target (back end) –Machine language –Interpreter (see fig. 1.8) Main program calls –Parser (Front-end) –Process (Back-end) (see fig. 1.10)

11 Demo Lexical Analysis Classify input character as –Self, Digit, EOF Create Token struct (see fig. 1.11) get_next_token() –Skip white space –Classify character (see fig. 1.12)


Download ppt "COP 4620 / 5625 Programming Language Translation / Compiler Writing Fall 2003 Lecture 1, 08/28/03 Prof. Roy Levow."

Similar presentations


Ads by Google