1 / 12

CSC 415: Translators and Compilers Spring 2009

CSC 415: Translators and Compilers Spring 2009. Chapters 8, 9 & Wrap-Up Interpretation & Design Principles. Chapter 8: Interpretation. Interactive Interpretation Interactive Interpretations of Machine Code Interactive Interpretation of Command Languages

alec-travis
Download Presentation

CSC 415: Translators and Compilers Spring 2009

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CSC 415: Translators and CompilersSpring 2009 Chapters 8, 9 & Wrap-Up Interpretation & Design Principles

  2. Chapter 8: Interpretation • Interactive Interpretation • Interactive Interpretations of Machine Code • Interactive Interpretation of Command Languages • Interactive Interpretation of Simple Programming Languages • Recursive Interpretation • Case Study: The TAM Interpreter

  3. Chapter 9: Conclusion • The Programming Language Life Cycle • Design • Specification • Prototype • Compilers • Error Reporting • Compile-time Error Reporting • Run-time Error Reporting • Efficiency • Compile-time Efficiency • Run-time Efficiency

  4. Semantic Analyzer Identification Type checking Structure of a Compiler Lexical Analyzer Source code Symbol Table tokens Semantic Analyzer Parser parse tree Intermediate Code Generation intermediate representation Optimization intermediate representation Assembly Code Generation Assembly code

  5. Programming Language Lifecycle:Concepts • Values • Types • Storage • Bindings • Abstractions • Encapsulation • Polymorphism • Exceptions • Concurrency Concepts Advanced Concepts

  6. Programming Language Lifecycle:Simplicity & Regularity • Strive for simplicity and regularity • Simplicity: support only the concepts essential to the applications for which language is intended • Regularity: should combine those concepts in a systematic way, avoiding restrictions that might surprise programmers or make their task more difficult

  7. Design Principles • Type completeness: no operation should be arbitrarily restricted in the types of its operands • Operations like assignment and parameter passing should, ideally, be applied to all types • Abstraction: for phrase that specifies some kind of computation, should be a way to abstract that phrase and parameterize it • Should be possible to abstract any expression and make it a function • Correspondence: for each form of declaration there should be corresponding parameter mechanism • Take a block with a constant definition and transform it into as procedure (or function) with a constant parameter

  8. Design Specification Prototype Compilers Manuals, textbooks Programming Language Lifecycle

  9. Specification • Precise specification for language’s syntax and semantics must be written • Informal or formal or hybrid Informal Formal BNF, EBNF Syntax English phrases Axiomatic method (based on mathematical logic) English phrases Semantics

  10. Prototypes • Cheap, low quality implementation • Highlights features of language that are hard to implement • Try out language • Interpreter might be a ghood prototype • Interpretive compiler • From source to abstract machine code

  11. Compile-Time Error Reporting • Rejecting ill-formed programs • Report location of each error with some explanation • Distinguish between the major categories of compile-time errors: • Syntactic error: missing or unexpected characters or tokens • Indicate what characters or tokens were expected • Scope error: a violation of the language’s scope rules • Indicate which identifier was used twice, or used with declaration • Type error: a violation of the language’s type rule • Indicate which type rule was violated and/or what type was expected

  12. Run-Time Error Reporting • Common run-time errors • Arithmetic overflow • Division by zero • Out-of-range array indexing • Can be detected only at run-time, because they depend on values computed at run-time

More Related