2016/7/9Page 1 Lecture 11: Semester Review COMP3100 Dept. Computer Science and Technology United International College.

Slides:



Advertisements
Similar presentations
Compiler Principles Fall Compiler Principles Lecture 4: Parsing part 3 Roman Manevich Ben-Gurion University.
Advertisements

CS 31003: Compilers  Difference between SLR and LR(1)  Construction of LR(1) parsing table  LALR parser Bandi Sumanth 11CS30006 Date : 9/10/2013.
Mooly Sagiv and Roman Manevich School of Computer Science
6/12/2015Prof. Hilfinger CS164 Lecture 111 Bottom-Up Parsing Lecture (From slides by G. Necula & R. Bodik)
1 Chapter 5: Bottom-Up Parsing (Shift-Reduce). 2 - attempts to construct a parse tree for an input string beginning at the leaves (the bottom) and working.
By Neng-Fa Zhou Syntax Analysis lexical analyzer syntax analyzer semantic analyzer source program tokens parse tree parser tree.
Bottom-Up Syntax Analysis Mooly Sagiv Textbook:Modern Compiler Design Chapter (modified)
Bottom-Up Syntax Analysis Mooly Sagiv html:// Textbook:Modern Compiler Design Chapter
FE.1 CSE4100 Final Exam Advice and Hints Prof. Steven A. Demurjian, Sr. Computer Science & Engineering Department The University of Connecticut 191 Auditorium.
1 COMP 144 Programming Language Concepts Felix Hernandez-Campos Lecture 5: Syntax Analysis COMP 144 Programming Language Concepts Spring 2002 Felix Hernandez-Campos.
Parsing V Introduction to LR(1) Parsers. from Cooper & Torczon2 LR(1) Parsers LR(1) parsers are table-driven, shift-reduce parsers that use a limited.
Bottom Up Parsing.
Table-driven parsing Parsing performed by a finite state machine. Parsing algorithm is language-independent. FSM driven by table (s) generated automatically.
BİL744 Derleyici Gerçekleştirimi (Compiler Design)1.
1 Bottom-up parsing Goal of parser : build a derivation –top-down parser : build a derivation by working from the start symbol towards the input. builds.
Compilation 2007 Context-Free Languages Parsers and Scanners Michael I. Schwartzbach BRICS, University of Aarhus.
1 214 review. 2 What we have learnt Generate scanner and parser –We do not program directly –Instead we write the specifications for the scanner and parser.
Parsing Chapter 4 Parsing2 Outline Top-down v.s. Bottom-up Top-down parsing Recursive-descent parsing LL(1) parsing LL(1) parsing algorithm First.
Chapter 9 Syntax Analysis Winter 2007 SEG2101 Chapter 9.
Concordia University Department of Computer Science and Software Engineering Click to edit Master title style COMPILER DESIGN Review Joey Paquet,
Joey Paquet, Lecture 12 Review. Joey Paquet, Course Review Compiler architecture –Lexical analysis, syntactic analysis, semantic.
Syntax and Semantics Structure of programming languages.
1 Lecture 5: Syntax Analysis (Section 2.2) CSCI 431 Programming Languages Fall 2002 A modification of slides developed by Felix Hernandez-Campos at UNC.
Bernd Fischer RW713: Compiler and Software Language Engineering.
Chapter 5: Bottom-Up Parsing (Shift-Reduce)
Prof. Necula CS 164 Lecture 8-91 Bottom-Up Parsing LR Parsing. Parser Generators. Lecture 6.
Introduction to Compiling
Compiler Introduction 1 Kavita Patel. Outlines 2  1.1 What Do Compilers Do?  1.2 The Structure of a Compiler  1.3 Compilation Process  1.4 Phases.
Course Revision.. Contents  Lexical Analysis  Our Compiler Structure  Tokens, Lexemes & Patterns  RE’s & Regular Definitions  Transition Diagrams.
Bernd Fischer RW713: Compiler and Software Language Engineering.
Bottom Up Parsing CS 671 January 31, CS 671 – Spring Where Are We? Finished Top-Down Parsing Starting Bottom-Up Parsing Lexical Analysis.
COMP 3438 – Part II-Lecture 6 Syntax Analysis III Dr. Zili Shao Department of Computing The Hong Kong Polytechnic Univ.
CS 404Ahmed Ezzat 1 CS 404 Introduction to Compiler Design Lecture 1 Ahmed Ezzat.
CS412/413 Introduction to Compilers and Translators Spring ’99 Lecture 6: LR grammars and automatic parser generators.
Bottom-up parsing. Bottom-up parsing builds a parse tree from the leaves (terminals) to the start symbol int E T * TE+ T (4) (2) (3) (5) (1) int*+ E 
1 Compiler Construction Vana Doufexi office CS dept.
CH4.1 CSE244 Midterm Subjects Aggelos Kiayias Computer Science & Engineering Department The University of Connecticut 371 Fairfield Road, Box U-155 Storrs,
Presented by : A best website designer company. Chapter 1 Introduction Prof Chung. 1.
Mid-Terms Exam Scope and Introduction. Format Grades: 100 points -> 20% in the final grade Multiple Choice Questions –8 questions, 7 points each Short.
COMP 3438 – Part II - Lecture 4 Syntax Analysis I Dr. Zili Shao Department of Computing The Hong Kong Polytechnic Univ.
CS416 Compiler Design1. 2 Course Information Instructor : Dr. Ilyas Cicekli –Office: EA504, –Phone: , – Course Web.
CS510 Compiler Lecture 1. Sources Lecture Notes Book 1 : “Compiler construction principles and practice”, Kenneth C. Louden. Book 2 : “Compilers Principles,
Review 1.Structure of the course Lexical Analysis Syntax Analysis Grammar & Language RG & DFA Top-down LL(1) Parsing Bottom-Up LR Layered Automation Semantic.
CS 404Ahmed Ezzat 1 CS 404 Introduction to Compiler Design Lecture Ahmed Ezzat.
COMPILER CONSTRUCTION
Syntax and Semantics Structure of programming languages.
Announcements/Reading
Chapter 1 Introduction.
CS 3304 Comparative Languages
Programming Languages Translator
50/50 rule You need to get 50% from tests, AND
Unit-3 Bottom-Up-Parsing.
Table-driven parsing Parsing performed by a finite state machine.
Chapter 1 Introduction.
Fall Compiler Principles Lecture 4: Parsing part 3
Compiler Lecture 1 CS510.
Bottom-Up Syntax Analysis
CPSC 388 – Compiler Design and Construction
LR(1) grammars The Chinese University of Hong Kong Fall 2010
Compilers Principles, Techniques, & Tools Taught by Jing Zhang
LALR Parsing Adapted from Notes by Profs Aiken and Necula (UCB) and
Compiler Construction
Subject: Language Processor
LR Parsing. Parser Generators.
INTRODUCTION TO COMPILERS (Pavan)
LR(1) grammars The Chinese University of Hong Kong Fall 2011
Pushdown automata The Chinese University of Hong Kong Fall 2011
Lec00-outline May 18, 2019 Compiler Design CS416 Compiler Design.
Review for the Midterm. Overview (Chapter 1):
Compiler design Review COMP 442/6421 – Compiler Design
Presentation transcript:

2016/7/9Page 1 Lecture 11: Semester Review COMP3100 Dept. Computer Science and Technology United International College

2016/7/92 Introduction  Compilation vs. Interpretation  Compilation stages

2016/7/93 DFA and its equivalents  DFA&NFA Definition Accepted string  Regular expression Notation Accepted string Convert to NFA and DFA  Regular grammar Definition  DFA=NFA=Regular expression=Regular grammar

2016/7/94 Regular expression->DFA Start with a regular expression. Construct an NFA from it. Use a set of subsets construction to obtain an equivalent DFA. Construct the minimal equivalent DFA.

2016/7/95 Convert the following regular expression to a DFA  1(0|1)*101

2016/7/96 Construct an NFA from it.

2016/7/97 Obtain an equivalent DFA

2016/7/98

9 Minimization

2016/7/910 PDA and its relevant  Context free languages Definition  PDA Definition Difference between PDA and DFA How does it work?  A language is context-free iff a pushdown automata recognizes it  Non-deterministic PDA are more powerful than deterministic ones

2016/7/911 Parser-Top down parsing  Predicts a derivation Matches non-terminal against token observed in input  How to parse given a parse table?  First set, follow set  Parse table construction  LL(1) grammar  Convert non-LL(1) grammar to LL(1) grammar

2016/7/912 Exercise  Given the following grammar S->a|^|(T) T->T,S|S (1) Eliminate the left-recursion in the grammar. (2) Build the LL(1) parsing table

2016/7/913 Left-recursion Elimination

2016/7/914 Parsing table construction

2016/7/915 Parser-Bottom up parsing  Right-most derivation – Backward Start with the tokens End with the start symbol Match substring on RHS of production, replace by LHS  Parsing given parsing table for LR(0)  Parsing table construction for LR(0)  Right-associative is not LR(0)

2016/7/916 Parser-Bottom up parsing (2)  SLR Apply reduction only if C is in FOLLOW(X)  LR(1) LR(1) parsing table construction  LALR Constructs LR(1) DFA and then merge any 2 LR(1) states whose items are identical except lookahead  Classification of grammar

2016/7/917  Given the following grammar S->AS|b A->SA|a (1) Build the full LR(0) DFA (2) Is it an SLR(1) grammar?

2016/7/918

2016/7/919  For state I1, note that Follow(S ’ )={$}. Hence, the shift-reduce conflict in state I1 can be solved in SLR(1).  For state I6, note that Follow(A)={a,b}. Hence, there is a shift-reduce conflict in state I6 which cannot solved in SLR(1).  For state I7, note that Follow(S)={a,b,$}. Hence, there is a shift-reduce conflict in state I7 which cannot solved in SLR(1).

2016/7/920 Semantic Analysis  Syntax-directed definition Semantic actions Synthesized attribute Inherited attribute  lexical, syntax, semantic errors  Symbol table construction  Type derivation

2016/7/921 Intermediate Code Generation  Translate high-level to low-level sentences  4 Distinct Regions of Memory  Execution Stack  Activation record/frame

2016/7/922 Running time organization  Parameter passing modes Value Reference Value/result Name

2016/7/923 Parameter Passing Modes  int i;  int A[3];  void Q(int B) {  A[1] = 3;  i = 2;  write(B);  B = 5;  }  int main() {  i = 1;  A[1] = 2;  A[2] = 4;  Q(A[i]);  }

2016/7/924 Mark Distribution DFA, Regular language and Scanner24 CFG and Parser40 Semantic Analysis19 Intermediate Code Generation5 Runtime Organization12

2016/7/925 Good Luck!