Source code. where each α ij is a terminal or nonterminal symbol. We say that. α 1 α m 1 Bα m+1 α n α 1 α m 1 β 1 β p α m+1 α n

Similar documents
Lecture 4: Parsing. Administrivia

CS 6353 Compiler Construction, Homework #1. 1. Write regular expressions for the following informally described languages:

(1) Then we could wave our hands over this and it would become:

[ ] 1+ lim G( s) 1+ s + s G s s G s Kacc SYSTEM PERFORMANCE. Since. Lecture 10: Steady-state Errors. Steady-state Errors. Then

Strongly Connected Components

LR(0) Analysis. LR(0) Analysis

L 1 = L G 1 F-matrix: too many F ij s even at quadratic-only level

ME 321 Kinematics and Dynamics of Machines S. Lambert Winter 2002

Propositional Logic. Combinatorial Problem Solving (CPS) Albert Oliveras Enric Rodríguez-Carbonell. May 17, 2018

INTRODUCTION TO AUTOMATIC CONTROLS INDEX LAPLACE TRANSFORMS

COHORT MBA. Exponential function. MATH review (part2) by Lucian Mitroiu. The LOG and EXP functions. Properties: e e. lim.

Y 0. Standing Wave Interference between the incident & reflected waves Standing wave. A string with one end fixed on a wall

Probability and Stochastic Processes: A Friendly Introduction for Electrical and Computer Engineers Roy D. Yates and David J.

Week 3: Connected Subgraphs

The second condition says that a node α of the tree has exactly n children if the arity of its label is n.

First derivative analysis

Differentiation of Exponential Functions

UNTYPED LAMBDA CALCULUS (II)

Abstract Interpretation: concrete and abstract semantics

Basic Polyhedral theory

with Dirichlet boundary conditions on the rectangle Ω = [0, 1] [0, 2]. Here,

September 23, Honors Chem Atomic structure.notebook. Atomic Structure

Math 34A. Final Review

Syntax Analysis. Context-free grammar Top-down and bottom-up parsing. cs5363 1

Higher order derivatives

COMPSCI 230 Discrete Math Trees March 21, / 22

Economics 201b Spring 2010 Solutions to Problem Set 3 John Zhu

cycle that does not cross any edges (including its own), then it has at least

Chapter 10 Time-Domain Analysis and Design of Control Systems

First order differential equation Linear equation; Method of integrating factors

Addition of angular momentum

CS 361 Meeting 12 10/3/18

u r du = ur+1 r + 1 du = ln u + C u sin u du = cos u + C cos u du = sin u + C sec u tan u du = sec u + C e u du = e u + C

ECE602 Exam 1 April 5, You must show ALL of your work for full credit.

From Elimination to Belief Propagation

Alpha and beta decay equation practice

u 3 = u 3 (x 1, x 2, x 3 )

EEO 401 Digital Signal Processing Prof. Mark Fowler

ph People Grade Level: basic Duration: minutes Setting: classroom or field site

Motivation (Cont d) Motivation (Cont d)

The Transmission Line Wave Equation

Integration by Parts

Thus, because if either [G : H] or [H : K] is infinite, then [G : K] is infinite, then [G : K] = [G : H][H : K] for all infinite cases.

6.1 Integration by Parts and Present Value. Copyright Cengage Learning. All rights reserved.

Roadmap. XML Indexing. DataGuide example. DataGuides. Strong DataGuides. Multiple DataGuides for same data. CPS Topics in Database Systems

Dealing with quantitative data and problem solving life is a story problem! Attacking Quantitative Problems

Fourier Transforms and the Wave Equation. Key Mathematics: More Fourier transform theory, especially as applied to solving the wave equation.

CPSC 665 : An Algorithmist s Toolkit Lecture 4 : 21 Jan Linear Programming

The Matrix Exponential

10. Limits involving infinity

Deift/Zhou Steepest descent, Part I

Calculus concepts derivatives

MCE503: Modeling and Simulation of Mechatronic Systems Discussion on Bond Graph Sign Conventions for Electrical Systems

Sundials and Linear Algebra

Even/Odd Mode Analysis of the Wilkinson Divider

The Matrix Exponential

That is, we start with a general matrix: And end with a simpler matrix:

Chapter 13 GMM for Linear Factor Models in Discount Factor form. GMM on the pricing errors gives a crosssectional

1 Minimum Cut Problem

Final Exam : Solutions

ELEC 372 LECTURE NOTES, WEEK 11 Dr. Amir G. Aghdam Concordia University

The van der Waals interaction 1 D. E. Soper 2 University of Oregon 20 April 2012

A Quadratic Serendipity Plane Stress Rectangular Element

22/ Breakdown of the Born-Oppenheimer approximation. Selection rules for rotational-vibrational transitions. P, R branches.

MSLC Math 151 WI09 Exam 2 Review Solutions

Brief Introduction to Statistical Mechanics

Multiple Short Term Infusion Homework # 5 PHA 5127

Addition of angular momentum

Ma/CS 6a Class 15: Flows and Bipartite Graphs

Objective Mathematics

Construction of asymmetric orthogonal arrays of strength three via a replacement method

Transfer function and the Laplace transformation

Last time. Resistors. Circuits. Question. Quick Quiz. Quick Quiz. ( V c. Which bulb is brighter? A. A B. B. C. Both the same

ME 200 Thermodynamics I Spring 2014 Examination 3 Thu 4/10/14 6:30 7:30 PM WTHR 200, CL50 224, PHY 112 LAST NAME FIRST NAME

perm4 A cnt 0 for for if A i 1 A i cnt cnt 1 cnt i j. j k. k l. i k. j l. i l

Gradebook & Midterm & Office Hours

SECTION where P (cos θ, sin θ) and Q(cos θ, sin θ) are polynomials in cos θ and sin θ, provided Q is never equal to zero.

Homework #3. 1 x. dx. It therefore follows that a sum of the

Problem Set 6 Solutions

DISCRETE TIME FOURIER TRANSFORM (DTFT)

Engineering Differential Equations Practice Final Exam Solutions Fall 2011

Chapter 8: Electron Configurations and Periodicity

Lecture 1: Numerical Integration The Trapezoidal and Simpson s Rule

Abstract Interpretation. Lecture 5. Profs. Aiken, Barrett & Dill CS 357 Lecture 5 1

Computing and Communications -- Network Coding

In the previous two chapters, we clarified what it means for a problem to be decidable or undecidable.

Lie Groups HW7. Wang Shuai. November 2015

u x v x dx u x v x v x u x dx d u x v x u x v x dx u x v x dx Integration by Parts Formula

y = 2xe x + x 2 e x at (0, 3). solution: Since y is implicitly related to x we have to use implicit differentiation: 3 6y = 0 y = 1 2 x ln(b) ln(b)

PHA 5127 Answers Homework 2 Fall 2001

Derivation of Electron-Electron Interaction Terms in the Multi-Electron Hamiltonian

General Notes About 2007 AP Physics Scoring Guidelines

Electrochemistry L E O

3 2x. 3x 2. Prepared by Vince Zaccone For Campus Learning Assistance Services at UCSB

Lucas Test is based on Euler s theorem which states that if n is any integer and a is coprime to n, then a φ(n) 1modn.

Searching Linked Lists. Perfect Skip List. Building a Skip List. Skip List Analysis (1) Assume the list is sorted, but is stored in a linked list.

TMMI37, vt2, Lecture 8; Introductory 2-dimensional elastostatics; cont.

ME311 Machine Design

1 Isoparametric Concept

Lecture 37 (Schrödinger Equation) Physics Spring 2018 Douglas Fields

Transcription:

Adminitrivia Lctur : Paring If you do not hav a group, pla pot a rqut on Piazzza ( th Form projct tam... itm. B ur to updat your pot if you find on. W will aign orphan to group randomly in a fw day. Programming Contt coming up. Sourc cod Lxical Analyi Tokn Paring A Glanc at th Map AST W ar hr Smantic Analyi Dcoratd AST Lat modifid: Tu Sp :59:58 CS: Lctur # Lat modifid: Tu Sp :59:58 CS: Lctur # Rviw: BNF BNF i anothr pattrn-matching languag; Alphabt typically t of tokn, uch a from lxical analyi, rfrrd to a trminal ymbol or trminal. Matching rul hav form: X : α α α n, whr X i from a t of nontrminal ymbol (or nontrminal or mta-variabl), n, and ach α i i a trminal or nontrminal ymbol. For mphai, may writ X : whn n =. Rad X : α α α n, a An X may b formd from th concatnation of an α, α,..., α n. Dignat on nontrminal a th tart ymbol. St of all matching rul i a contxt-fr grammar. Rviw: Drivation String (of trminal) T i in th languag dcribd by grammar G, (T L(G)) if thr i a drivation of T from th tart ymbol of G. Drivation of T = τ τ k from nontrminal A i qunc of ntntial form: A α α... α α... τ...τ k whr ach α ij i a trminal or nontrminal ymbol. W ay that α α m Bα m+ α n α α m β β p α m+ α n if B : β β p i a production. ( m n). If Φ and Φ ar ntntial form, thn Φ = Φ man that or mor tp turn Φ into Φ. Φ + = Φ man or mor tp do it. So if S i tart ymbol of G, thn T L(G) iff S + = T. Lat modifid: Tu Sp :59:58 CS: Lctur # Lat modifid: Tu Sp :59:58 CS: Lctur #

. : ID. : ( ). : /. : 5. : +. : - Exampl of Drivation Problm: Driv - ID / ( ID / ID ) Altrnativ Notation : ID ( ) / : + - = / = ID / = - ID / = - ID / ( ) = - ID / ( ) = - ID / ( / ) = - ID / ( ID / ) = - ID / ( ID / ) = - ID / ( ID / ID ) = - ID / ( ID / ID ) Typ of Drivation Contxt fr man can rplac nontrminal in any ordr (i.., rgardl of contxt) to gt am rult (a long a you u am production). So, if w u a particular rul for lcting nontrminal to produc from, can charactriz drivation by jut liting production. Prviou xampl wa lftmot drivation: alway choo lftmot nontrminal. Compltly charactrizd by lit of production:,,,,,,,,,. Lat modifid: Tu Sp :59:58 CS: Lctur # 5 Lat modifid: Tu Sp :59:58 CS: Lctur # Drivation and Par Tr A lftmot drivation alo compltly charactrizd by par tr: Ambiguity Only on drivation for prviou xampl. What about ID / ID / ID? Claim thr ar two par tr, corrponding to two lftmot drivation. What ar thy? - ID / ( ID / ID ) What i th rightmot drivation for thi? = / = / ( ) = / ( / ) = / ( / ID ) = / ( / ID ) = / ( ID / ID ) = / ( ID / ID ) = / ( ID / ID ) = ID / ( ID / ID ) = - ID / ( ID / ID ) Lat modifid: Tu Sp :59:58 CS: Lctur # 7 If thr xit vn on tring lik ID / ID / ID in L(G), w ay G i ambiguou (vn if othr tring only hav on par tr). Lat modifid: Tu Sp :59:58 CS: Lctur # 8

Ambiguity Only on drivation for prviou xampl. What about ID / ID / ID? Claim thr ar two par tr, corrponding to two l drivation. What ar thy? - ID/ ID / ID - ID / If thr xit vn on tring lik ID / ID / ID in L(G), w i ambiguou (vn if othr tring only hav on par tr) ID / Lat modifid: Tu Sp :59:58 CS: L

Rviw: Syntax-Dirctd Tranlation Want th tructur of ntnc, not jut whthr thy ar in th languag, bcau thi driv tranlation. Aociat tranlation rul to ach production, jut a Flx aociatd action with matching pattrn. Bion notation: : / { $$ = dodivid($, $); } provid way to rfr to and t mantic valu on ach nod of a par tr. Comput th mantic valu from lav up th par tr. Sam a th ordr of a rightmot drivation in rvr (a.k.a a canonical drivation). Altrnativly, jut prform arbitrary action in th am ordr. Exampl: Conditional tatmnt Problm: if-l or if-lif-l tatmnt in Python (l optional). Aum that only(indntd) uit may b ud for thn and l clau, that nontrminal tmt dfin an individual tatmnt(on pr lin), and that nontrminal xpr dfin an xprion. Lxr uppli INDENT and DEDENT. A cond i a kind of tmt. xpr :... tmt :... cond... cond : "if" xpr : uit lif l uit: INDENT tmt DEDENT tmt: tmt tmt tmt lif: "lif" xpr : uit lif l : "l" : uit Lat modifid: Tu Sp :59:58 CS: Lctur # 9 Lat modifid: Tu Sp :59:58 CS: Lctur # Exampl: Conditional tatmnt in Java Problm: if-l in Java. Aum that nontrminal tmt dfin an individual tatmnt (including a block in {}). xpr :... tmt :... cond... cond : "if" ( xpr ) tmt l l : "l" tmt But thi don t quit work: rcogniz corrct tatmnt and rjct incorrct on, but i ambiguou. E.g., if (foo) if (bar) walk(); l chwgum(); Do w chw gum if foo i fal? That i, i thi quivalnt to if (foo) { if (bar) walk(); } l chwgum(); /*or*/ if (foo) { if (bar) walk(); l chwgum(); }? Exampl rolvd: Conditional tatmnt in Java Th rul i uppod to b ach l attach to th nart opn if on th lft, which i capturd by: xpr :... tmt :... cond... tmt_clod :... cond_clod... cond_clod : "if" ( xpr ) tmt_clod "l" tmt_clod cond : "if" ( xpr ) tmt "if" ( xpr ) tmt_clod "l" tmt Thi do not allow u to intrprt a if (foo) if (bar) walk(); l chwgum(); if (foo) { if (bar) walk(); } l chwgum(); But it not xactly clar, i it? Lat modifid: Tu Sp :59:58 CS: Lctur # Lat modifid: Tu Sp :59:58 CS: Lctur #

Puzzl: NFA to BNF Problm: What BNF grammar accpt th am tring a thi NFA? 5 7 AGnral convntional anwr anwr (adaptabl (fromto cla): any NFA), with on nontrminal pr tat: S: S: S S S S S: S: S5 S S: : S S S: S5: S S5 S: S: S S S S S S: S7 S S: S: S S S S S S7: S S7 Nontrminal Sk i th t of tring that will gt m from Sk in th NFA to a final tat in th NFA. Lat modifid: Tu Sp :59:58 CS: Lctur #