{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

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

Info icon This 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 (Fall 2005) Implementation, Syntax, and Semantics 2 Organization of Programming Languages-Cheng (Fall 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 (Fall 2005) Compilation Process Compiler
Image of page 1

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

View Full Document Right Arrow Icon
2 4 Organization of Programming Languages-Cheng (Fall 2005) Implementation Methods Pure interpretation No translation Slow execution Becoming rare Interpreter Source Program Output Input 5 Organization of Programming Languages-Cheng (Fall 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 (Fall 2005) Hybrid Implementation System Translator
Image of page 2
3 7 Organization of Programming Languages-Cheng (Fall 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 (Fall 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 (Fall 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
Image of page 3

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

View Full Document Right Arrow Icon
4 10 Organization of Programming Languages-Cheng (Fall 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 (Fall 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 A = B - C end 12 Organization of Programming Languages-Cheng (Fall 2005) BNF Leftmost derivation: the replaced non-terminal is always the leftmost non-terminal Rightmost derivation the replaced non-terminal is always the
Image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern