ln007 - program, how does the compiler know how to...

Info iconThis preview shows pages 1–5. Sign up to view the full content.

View Full Document Right Arrow Icon
The Anatomy of a Compiler Source Program Syntax Analysis Semantic Analysis Optimization Code Generation Translated Program Parse Trees (ASTs) Recognize the structure of a source program, generate parse tree Recognize/validate the meaning of a source program Reorganize the parse tree/AST to make computations more efficient Translate parse tree/AST into low-level language Recognition Phases Code Generation Phases Observations: -Language definitions have two parts: syntax and semantics -Compilers have two phases which deal with each of these language definition components: syntax analysis, semantic analysis.
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Compilation Example int i; void main () { for (i = 1; i <= 100; i++) fred(i); } ... i: data word 0 main: move 1 to i L1: compare i with 100 jump to L2 if greater push i call fred add 1 to i goto L1 L2: return fred: ... Translating a C-like language to assembly language
Background image of page 2
Compilation Example Given the previous
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 4
Background image of page 5
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: program, how does the compiler know how to interpret the various names in the program, such as int, i, void, main, etc . Names are bound to properties (characteristics the compiler can use to interpret the name) at various times during the life-time of a program. Compilation Example Language-definition Time void, for or any other keyword Language-implementation Time int 16, 32, 64 bit entity anything else that is hardware specific Compile Time the type of i is bound at compile time Link Time the name fred is bound to a function at link time Load Time the names main, fred, and i are determined at load time Runtime the values stored in i are determined at runtime Assignments Read chap 4 HW #3 4.4 Quiz Chapters 1-4...
View Full Document

This note was uploaded on 10/03/2011 for the course CSC 301 taught by Professor Hamel during the Spring '08 term at Rhode Island.

Page1 / 5

ln007 - program, how does the compiler know how to...

This preview shows document pages 1 - 5. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online