Presentation is loading. Please wait.

Presentation is loading. Please wait.

CPSC 388 – Compiler Design and Construction

Similar presentations


Presentation on theme: "CPSC 388 – Compiler Design and Construction"— Presentation transcript:

1 CPSC 388 – Compiler Design and Construction
Midterm Review

2 History and Basics of Programming Languages
Advances in Programming languages Imperative and Declarative Languages Static/Dynamic Distinction Environments and States Static Scope and Block Structure Explicit Access Control Dynamic Scope Parameter Passing Aliasing

3 Software Make JLex Java_cup Java Javac

4 Structure of Compiler Compilers Translate Source Language to Target Language Compilers have several steps Scanner Parser Semantic Analyzer Intermediate Code Generator Optimizer Code Generator Symbol Table Used To Keep Track of Names Used in Program Front End and Back End Simplify Compiler Design Introduction of new languages Introduction of new hardware

5 Scanning General: what does a scanner do; how does it fit into the design of a compiler? Underlying Model: Finite-State Machines Implementing a Scanner using a transition table Specification of a scanner: Regular Expressions JLex Specifications

6 Finite State Machines Deterministic Finite State Machine
Non-deterministic Finite State Machine Conversion from NFA to DFA

7 Regular Expressions, Regular Definitions, and JLex
Syntax and semantics of RE Base operators and extended operators Character Classes Conversion from RE to NFA JLex specification Use of RE Associated Action Macros Matching rules

8 Context-Free Grammars
Leftmost, Rightmost derivations Parse Trees Expression Grammars Precedence Associativity List Grammars Ambiguous Grammars Recursive Grammars (left recursive, right recursive)

9 Syntax-Directed Translation
“plain” translations Writing rules of the form S1.trans=… Java_cup translations Using “:xx” to name the translation associated with a symbol defining translations by assigning to RESULT

10 Parsing, LL(1) and LALR(1) grammars
General: what does a parser do; how does it fit into the design of a compiler? Top-Down Parsing predictive parsing (using a stack and a parse table) left factoring removing left recursion First and Follow sets (how to compute and why they are important) building the parse table

11 Textbook Sections Covered
Chapter 1 Introduction Chapter 3 Lexical Analysis 3.1, 3.3, 3.6, 3.7.1, 3.7.4 Chapter 4 Syntax Analysis 4.1, 4.2, 4.3, 4.4, 4.8, Chapter 5 Syntax-Directed Translation 5.1, 5.2, 5.3


Download ppt "CPSC 388 – Compiler Design and Construction"

Similar presentations


Ads by Google