lec23 - CSE 12 Parse Trees and Abstract Syntax Trees...

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

View Full Document Right Arrow Icon
23 Compilers and Interpreters Syntax Rules and Backus-Naur Form Definitions Derivations and Parse Trees Parse Trees and Abstract Syntax Trees (AST's) CSE 12 Parse Trees and Abstract Syntax Trees
Background image of page 1

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

View Full DocumentRight Arrow Icon
Using Algorithms and Data Structures Digital computers can do anything that can conceivably be done with information: they are general purpose information processing machines You get a computer to do something by programming it to run algorithms that manipulate data structures Picking what algorithms and data structures are good to use for a particular application is something every good programmer needs to know One important application area is: writing programs that understand programs
Background image of page 2
Compilers and interpreters Distinguish two kinds of program-understanding programs: Compilers take a program written in a source language as input and translate it into a machine language, for later execution Interpreters take a source language program as input, and execute ("interpret") it immediately, line by line (You can think of a computer as an interpreter of machine language instructions; the Java Virtual Machine is an interpreter of Java bytecode instructions, which are generated by the Java compiler) Let’s look at how some ideas from this course (like recursion, and trees) can be used to implement an interpreter for a language
Background image of page 3

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

View Full DocumentRight Arrow Icon
Towards an interpreter An interpreter reads a line or statement at a time of a source language text, and then does what that line or statement says to do The source language should have clearly defined syntax and semantics rules the syntax rules say what strings legally belong to the source language, and what their structure is the semantics rules say what each legal string in the language means, based on its structure Start with clearly defined syntax and semantics, and writing an interpreter becomes much easier
Background image of page 4
Tasks for an interpreter A language interpreter does two things with each line or statement in the input: syntactic analysis and semantic evaluation Syntactic analysis is done in accordance with the syntax rules
Background image of page 5

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

View Full DocumentRight Arrow Icon
Image of page 6
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 03/27/2012 for the course CSE 12 taught by Professor Gary during the Fall '08 term at UCSD.

Page1 / 19

lec23 - CSE 12 Parse Trees and Abstract Syntax Trees...

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

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