03-implementation-new

03-implementation-new - Implementation, Syntax, and...

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

View Full Document Right Arrow Icon
1 1 Organization of Programming Languages-Cheng (Fal 2005) Implementation, Syntax, and Semantics 2 Organization of Programming Languages-Cheng (Fal 2005) Implementation Methods Compilation Translate high-level program to machine code Slow translation Fast execution Compiler Source Program Target Program Target Program Input Output 3 Organization of Programming Languages-Cheng (Fal 2005) Compilation Process Compiler
Background image of page 1

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

View Full DocumentRight Arrow Icon
2 4 Organization of Programming Languages-Cheng (Fal 2005) Implementation Methods Pure interpretation No translation Slow execution Becoming rare Interpreter Source Program Output Input 5 Organization of Programming Languages-Cheng (Fal 2005) Implementation Methods Hybrid implementation systems Small translation cost Medium execution speed Virtual Machine Intermediate Program Output Input Translator Source Program Intermediate Program 6 Organization of Programming Languages-Cheng (Fal 2005) Hybrid Implementation System Translator
Background image of page 2
3 7 Organization of Programming Languages-Cheng (Fal 2005) Programming Environments The collection of tools used in software development UNIX An older operating system and tool collection Borland JBuilder An integrated development environment for Java Microsoft Visual Studio.NET A large, complex visual environment Used to program in C#, Visual BASIC.NET, Jscript, J#, or C++ 8 Organization of Programming Languages-Cheng (Fal 2005) Describing Syntax Lexemes: lowest-level syntactic units Tokens: categories of lexemes sum = x + 2 – 3 Lexemes: sum, =, x, +, 2, -, 3 Tokens: identifier, equal_sign, plus_op, integer_literal, minus_op 9 Organization of Programming Languages-Cheng (Fal 2005) Formal Method for Describing Syntax Backus-Naur form (BNF) Also equivalent to context-free grammars, developed by Noam Choamsky (a linguist) BNF is a meta-language a language used to describe another language Consists of a collection of rules (or productions) Example of a rule: <assign> < var > = < expression > LHS: the abstraction being defined RHS: contains a mixture of tokens, lexemes, and references to other abstractions Abstractions are called non-terminal symbols Lexemes and tokens are called terminal symbols Also contains a special non-terminal symbol called the start symbol
Background image of page 3

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

View Full DocumentRight Arrow Icon
4 10 Organization of Programming Languages-Cheng (Fal 2005) Example of a grammar in BNF <program> begin <stmt_list> end <stmt_list> <stmt> | <stmt>; <stmt_list> <stmt> <var> = <expression> <var> A | B | C | D <expression> <var> + <var> | <var> - <var> | <var> 11 Organization of Programming Languages-Cheng (Fal 2005) Derivation The process of generating a sentence begin A = B – C end Derivation: <program> (start symbol) => begin <stmt_list> end => begin <stmt> end => begin <var> = <expression> end => begin A = <expression> end => begin A = <var> - <var> end => begin A = B - <var> end => begin
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 07/25/2008 for the course CSE 452 taught by Professor Cheng during the Fall '05 term at Michigan State University.

Page1 / 27

03-implementation-new - Implementation, Syntax, and...

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