LR(1) Parsers Part III Last Parser Lecture. Copyright 2010, Keith D. Cooper & Linda Torczon, all rights reserved.

Similar documents
Natural Language Processing. Dependency Parsing

Rational Parsing. John Hale

A Methodology for Integrated Conceptual Design of Aircraft Configuration and Operation to Reduce Environmental Impact

= Coordination with Direct Communication

DART. Duty & Recreation Travel STAFF TRAVEL SIMPLIFIED. Straightforward, easy to use staff travel management system for the airline industry

STANDARDS MAP Basic Programs 1 and 2 English Language Arts Content Standards Grade Five

Activity Template. Drexel-SDP GK-12 ACTIVITY. Subject Area(s): Sound Associated Unit: Associated Lesson: None

CHAPTER 5 SIMULATION MODEL TO DETERMINE FREQUENCY OF A SINGLE BUS ROUTE WITH SINGLE AND MULTIPLE HEADWAYS

Corrected his comment about training the drivers for different types of wheel chairs, not just one type.

TIMS & PowerSchool 2/3/2016. TIMS and PowerSchool. Session Overview

Airspace Management Decision Tool

ASSEMBLY 39TH SESSION

New Enhanced Service Buletin. qtr_04. a quarterly publication boeing.com/commercial/ aeromagazine

Minimum Travel Times between European Regions. An assessment of the ACARE 4h-Goal

1. Please tell us about new features, functions or information that you made available on the new website for the first time?

ENAIRE DEVELOPMENTS NM B2B WEB SERVICES TECHNICAL FORUM. enaire.es. Network Manager nominated by the European Commission

ARETE THROWS NATION - HOW POSTURE DICTATES THE THROW

Implementing an Air Taxi System

Don t Sit on the Fence

Integrated Optimization of Arrival, Departure, and Surface Operations

Module description: Traffic Sample. Pim van Leeuwen, NLR Second Demonstration Workshop Braunschweig, Germany June 25 th, 2013

EE382V: Embedded System Design and Modeling

From AIS to AIM. COMSOFT AIS to AIM Lima, Peru Context and Overview Isabel Zambrano Rodriguez

RULES AND REGULATIONS

INTERNATIONAL CIVIL AVIATION ORGANIZATION WESTERN AND CENTRAL AFRICA OFFICE. Thirteenth Meeting of the FANS I/A Interoperability Team (SAT/FIT/13)

WORLDWIDE SYMPOSIUM ON ENABLING THE NET-CENTRIC INFORMATION ENVIRONMENT:

NextGen AeroSciences, LLC Seattle, Washington Williamsburg, Virginia Palo Alto, Santa Cruz, California

Flight Dynamics Analysis of a Medium Range Box Wing Aircraft

Regional air navigation planning and implementation performance framework: Review of programmes and projects

Logic Control Summer Semester Assignment: Modeling and Logic Controller Design 1

PORT MORESBY POWER PROJECT - UPDATE PNG Mining & Petroleum Investment Conference. 4 th December 2018

NOISE ABATEMENT PROCEDURES

Twisted Frobenius extensions

ADVANTAGES OF SIMULATION

E-RECORDS. Heading towards a Paperless operation SWARAN SIDHU - HEAD OF FLEET TECHNICAL MANAGEMENT

Transportation Timetabling

4 REPORTS. The Reports Tab. Nav Log

2012 Performance Framework AFI

ATTEND Analytical Tools To Evaluate Negotiation Difficulty

RE: Draft AC , titled Determining the Classification of a Change to Type Design

Runway 1C/19C Reconstruction

Clustering radar tracks to evaluate efficiency indicators Roland Winkler Annette Temme, Christoph Bösel, Rudolf Kruse

WHAT S NEW in 7.9 RELEASE NOTES

HOLDING STACK MANAGEMENT

American Airlines Next Top Model

Furthermore, both our Flight API and our WebFare Engine have improved largely and have been supplemented with new features.

Future Network Manager Methods

Project Deliverable 4.1.3d Individual City Report - City of La Verne

MPL Global Progress Report

Crew Resource Management

Flight Efficiency Initiative

Operator and Solver. Matt Ardrey, Kent Young & Roei Ganzarski

Schedule Compression by Fair Allocation Methods

Sustainable Tourism for Development

A TRANSPORT SYSTEM CONNECTING PEOPLE TO PLACES

Transit Fare Review Phase 2 Discussion Guide

Quantile Regression Based Estimation of Statistical Contingency Fuel. Lei Kang, Mark Hansen June 29, 2017

SYLLABUS INTRODUCTION TO ROTARY WING FLYING QUALITIES AND PERFORMANCE

NATIONAL AIRSPACE POLICY OF NEW ZEALAND

Draft Concept Alternatives Analysis for the Inaugural Airport Program September 2005

Setup and Configure the Siteminder Policy Store with Dxmanager

2 Purpose and Need. 2.1 The Need for the Proposed Action Description of the Problem

Saint Petersburg-Clearwater International Airport. Airspace & Instrument Approach Analysis

Real-time route planning streamlines onboard operations, reduces fuel burn and delays, and improves on-time performance.

Study Overview and Context

THE AREA CONTROL CENTRE (CTR) POSITION

An Architecture for Combinator Graph Reduction Philip J. Koopman Jr.

Airport IT Are you ready for the future

SAFE COORDINATIONS IN THE PROVISION OF CAPSCA - AIRLINES CAPT. AHMED HASHIM HUSSEIN SAFETY MANAGER - BADR AIRLINES

TWELFTH AIR NAVIGATION CONFERENCE

Air Carrier Tariff Signage and Public Inspection of Tariffs

ATC automation: facts and steps ahead

Aeronautical METeorology in Europe

Dave Allanby GM Operations SOUTH AFRICAN EXPRESS

Analysis of Aircraft Separations and Collision Risk Modeling

An Analytical Approach to the BFS vs. DFS Algorithm Selection Problem 1

How big can my carry-on bag be?

Department of Defense. Federal Aviation Administration. NOTAM Realignment. Gary Prock Date: September 19, 2007

Aeronautical Information Management

ICAO PBN CONCEPTS, BENEFITS, AND OBJECTIVES

IN THE COURT OF APPEALS TWELFTH APPELLATE DISTRICT OF OHIO MADISON COUNTY. : O P I N I O N - vs - 6/22/2015 :

CSCI 5832 Natural Language Processing

Workbook Unit 11: Natural Deduction Proofs (II)

in-depth ACH EFFI [ IN-DEPTH ] 38 Twentyfour

AIRBUS Generic Flight Test Installation

Global Action on International Aviation and Climate Change

System Oriented Runway Management: A Research Update

BILATERAL TEMPLATE AIR SERVICES AGREEMENT

Time Benefits of Free-Flight for a Commercial Aircraft

New issues raised on collision avoidance by the introduction of remotely piloted aircraft (RPA) in the ATM system

Economic Impact for Airlines from Air Traffic Control Tower Modernization at LaGuardia Airport

Multi Profile Training Areas. Col Azmi Al Abaddi Royal Jordanian Air Force

Quiz 2 - Solution. Problem #1 (50 points) CEE 5614 Fall Date Due: Wednesday November 20, 2013 Instructor: Trani

SUPPLEMENTARY CONDITIONS APPLICABLE TO TOWER CRANES 2012

Airport Safety Management Systems: Integrating Planning Into the Process

Analysis of Air Transportation Systems. Airport Capacity

Fair Allocation Concepts in Air Traffic Management

Modeling Visitor Movement in Theme Parks

A350 XWB Flight Crew Training Concept

SERVICE LETTER REVISION

Transcription:

LR(1) Parsers Part III Last Parser Lecture Copyright 2010, Keith D. Cooper & Linda Torczon, all rights reserved.

LR(1) Parser Recap Bottom-up conceptual algorithm LR(1) Skeleton Parser Construct Control DFA Closure and goto functions Today Construct ACTION AND GOTO tables

Example from SheepNoise S 0 : { [Goal SheepNoise, EOF], [SheepNoise SheepNoise baa, EOF], [SheepNoise baa, EOF], [SheepNoise SheepNoise baa, baa], [SheepNoise baa, baa] } S 1 = Goto(S 0, SheepNoise) = { [Goal SheepNoise, EOF], [SheepNoise SheepNoise baa, EOF], [SheepNoise SheepNoise baa, baa] } S 2 = Goto(S 0, baa) = { [SheepNoise baa, EOF], [SheepNoise baa, baa] } S 3 = Goto(S 1, baa) = { [SheepNoise SheepNoise baa, EOF], [SheepNoise SheepNoise baa, baa] } 0 Goal SheepNoise 1 SheepNoise SheepNoise baa 2 baa

Example from SheepNoise S 0 : { [Goal SheepNoise, EOF], [SheepNoise SheepNoise baa, EOF], [SheepNoise baa, EOF], [SheepNoise SheepNoise baa, baa], [SheepNoise baa, baa] } S 1 = Goto(S 0, SheepNoise) = { [Goal SheepNoise, EOF], [SheepNoise SheepNoise baa, EOF], [SheepNoise SheepNoise baa, baa] } S 2 = Goto(S 0, baa) = { [SheepNoise baa, EOF], [SheepNoise baa, baa] } S 3 = Goto(S 1, baa) = { [SheepNoise SheepNoise baa, EOF], [SheepNoise SheepNoise baa, baa] } 0 Goal SheepNoise 1 SheepNoise SheepNoise baa 2 baa

Example from SheepNoise S 0 : { [Goal SheepNoise, EOF], [SheepNoise SheepNoise baa, EOF], [SheepNoise baa, EOF], [SheepNoise SheepNoise baa, baa], [SheepNoise baa, baa] } S 1 = Goto(S 0, SheepNoise) = { [Goal SheepNoise, EOF], [SheepNoise SheepNoise baa, EOF], [SheepNoise SheepNoise baa, baa] } S 2 = Goto(S 0, baa) = { [SheepNoise baa, EOF], [SheepNoise baa, baa] } S 3 = Goto(S 1, baa) = { [SheepNoise SheepNoise baa, EOF], [SheepNoise SheepNoise baa, baa] } 0 Goal SheepNoise 1 SheepNoise SheepNoise baa 2 baa

Example from SheepNoise S 0 : { [Goal SheepNoise, EOF], [SheepNoise SheepNoise baa, EOF], [SheepNoise baa, EOF], [SheepNoise SheepNoise baa, baa], [SheepNoise baa, baa] } S 1 = Goto(S 0, SheepNoise) = { [Goal SheepNoise, EOF], [SheepNoise SheepNoise baa, EOF], [SheepNoise SheepNoise baa, baa] } S 2 = Goto(S 0, baa) = { [SheepNoise baa, EOF], [SheepNoise baa, baa] } S 3 = Goto(S 1, baa) = { [SheepNoise SheepNoise baa, EOF], [SheepNoise SheepNoise baa, baa] } 0 Goal SheepNoise 1 SheepNoise SheepNoise baa 2 baa

Example from SheepNoise S 0 : { [Goal SheepNoise, EOF], [SheepNoise SheepNoise baa, EOF], [SheepNoise baa, EOF], [SheepNoise SheepNoise baa, baa], [SheepNoise baa, baa] } S 1 = Goto(S 0, SheepNoise) = { [Goal SheepNoise, EOF], [SheepNoise SheepNoise baa, EOF], [SheepNoise SheepNoise baa, baa] } S 2 = Goto(S 0, baa) = { [SheepNoise baa, EOF], [SheepNoise baa, baa] } S 3 = Goto(S 1, baa) = { [SheepNoise SheepNoise baa, EOF], [SheepNoise SheepNoise baa, baa] } 0 Goal SheepNoise 1 SheepNoise SheepNoise baa 2 baa

Filling in the ACTION and GOTO Tables The algorithm x is the state number set S x CC item i S x if i is [A β aδ,b] and goto(s x,a) = S k, a T then ACTION[x,a] shift k else if i is [S S,EOF] then ACTION[x,EOF] accept else if i is [A β,a] then ACTION[x,a] reduce A β n NT if goto(s x,n) = S k then GOTO[x,n] k

Filling in the ACTION and GOTO Tables The algorithm set S x CC before T shift item i S x if i is [A β aδ,b] and goto(s x,a) = S k, a T then ACTION[x,a] shift k else if i is [S S,EOF] then ACTION[x,EOF] accept else if i is [A β,a] then ACTION[x,a] reduce A β n NT if goto(s x,n) = S k then GOTO[x,n] k

Filling in the ACTION and GOTO Tables The algorithm set S x CC item i S x if i is [A β aδ,b] and goto(s x,a) = S k, a T then ACTION[x,a] shift k else if i is [S S,EOF] then ACTION[x,EOF] accept else if i is [A β,a] then ACTION[x,a] reduce A β n NT if goto(s x,n) = S k then GOTO[x,n] k have Goal accept

Filling in the ACTION and GOTO Tables The algorithm set S x CC item i S x if i is [A β aδ,b] and goto(s x,a) = S k, a T then ACTION[x,a] shift k else if i is [S S,EOF] then ACTION[x,EOF] accept else if i is [A β,a] then ACTION[x,a] reduce A β n NT if goto(s x,n) = S k then GOTO[x,n] k at end reduce

Filling in the ACTION and GOTO Tables The algorithm set S x CC item i S x if i is [A β aδ,b] and goto(s x,a) = S k, a T then ACTION[x,a] shift k else if i is [S S,EOF] then ACTION[x,EOF] accept else if i is [A β,a] then ACTION[x,a] reduce A β n NT if goto(s x,n) = S k then GOTO[x,n] k Fill GOTO table

Example from SheepNoise S 0 : { [Goal SheepNoise, EOF], [SheepNoise SheepNoise baa, EOF], [SheepNoise baa, EOF], [SheepNoise SheepNoise baa, baa], [SheepNoise baa, baa] } S 1 = Goto(S 0, SheepNoise) = { [Goal SheepNoise, EOF], [SheepNoise SheepNoise baa, EOF], [SheepNoise SheepNoise baa, baa] } S 2 = Goto(S 0, baa) = { [SheepNoise baa, EOF], before T shift k [SheepNoise baa, baa] } S 3 = Goto(S 1, baa) = { [SheepNoise SheepNoise baa, EOF], 0 Goal SheepNoise 1 SheepNoise SheepNoise baa 2 baa if i is [A β aδ,b] and goto(s x,a) = S k, a T [SheepNoise SheepNoise baa, baa] } then ACTION[x,a] shift k

Example from SheepNoise S 0 : { [Goal SheepNoise, EOF], [SheepNoise SheepNoise baa, EOF], [SheepNoise baa, EOF], [SheepNoise SheepNoise baa, baa], [SheepNoise baa, baa] } S 1 = Goto(S 0, SheepNoise) = before T shift k { [Goal SheepNoise, EOF], [SheepNoise SheepNoise baa, EOF], [SheepNoise SheepNoise baa, baa] } S 2 = Goto(S 0, baa) = { [SheepNoise baa, EOF], [SheepNoise baa, baa] } so, ACTION[s 0,baa] is shift S 2 (clause 1) (items define same entry) S 3 = Goto(S 1, baa) = { [SheepNoise SheepNoise baa, EOF], [SheepNoise SheepNoise baa, baa] } 0 Goal SheepNoise 1 SheepNoise SheepNoise baa 2 baa

Example from SheepNoise S 0 : { [Goal SheepNoise, EOF], [SheepNoise SheepNoise baa, EOF], [SheepNoise baa, EOF], [SheepNoise SheepNoise baa, baa], [SheepNoise baa, baa] } S 1 = Goto(S 0, SheepNoise) = { [Goal SheepNoise, EOF], [SheepNoise SheepNoise baa, EOF], [SheepNoise SheepNoise baa, baa] } S 2 = Goto(S 0, baa) = { [SheepNoise baa, EOF], [SheepNoise baa, baa] } so, ACTION[S 1,baa] is shift S 3 (clause 1) S 3 = Goto(S 1, baa) = { [SheepNoise SheepNoise baa, EOF], [SheepNoise SheepNoise baa, baa] } 0 Goal SheepNoise 1 SheepNoise SheepNoise baa 2 baa if i is [A β aδ,b] and goto(s x,a) = S k, a T then ACTION[x,a] shift k

Example from SheepNoise S 0 : { [Goal SheepNoise, EOF], [SheepNoise SheepNoise baa, EOF], [SheepNoise baa, EOF], [SheepNoise SheepNoise baa, baa], [SheepNoise baa, baa] } S 1 = Goto(S 0, SheepNoise) = { [Goal SheepNoise, EOF], [SheepNoise SheepNoise baa, EOF], [SheepNoise SheepNoise baa, baa] } so, ACTION[S 1,EOF] is accept (clause 2) S 2 = Goto(S 0, baa) = { [SheepNoise baa, EOF], [SheepNoise baa, baa] } S 3 = Goto(S 1, baa) = { [SheepNoise SheepNoise baa, EOF], 0 Goal SheepNoise 1 SheepNoise SheepNoise baa 2 baa else if i is [S S,EOF] [SheepNoise SheepNoise baa, baa] } then ACTION[x,EOF] accept

Example from SheepNoise S 0 : { [Goal SheepNoise, EOF], [SheepNoise SheepNoise baa, EOF], [SheepNoise baa, EOF], [SheepNoise SheepNoise baa, baa], [SheepNoise baa, baa] } S 1 = Goto(S 0, SheepNoise) = { [Goal SheepNoise, EOF], [SheepNoise SheepNoise baa, EOF], [SheepNoise SheepNoise baa, baa] } S 2 = Goto(S 0, baa) = { [SheepNoise baa, EOF], [SheepNoise baa, baa] } ACTION[S 2,baa] is reduce 2 [SheepNoise SheepNoise baa, baa] } S 3 = Goto(S 1, baa) = { [SheepNoise SheepNoise baa, EOF], 0 Goal SheepNoise 1 SheepNoise SheepNoise baa 2 baa so, ACTION[S 2,EOF] is reduce 2 else if i is [A β,a] then ACTION[x,a] reduce A β

Example from SheepNoise S 0 : { [Goal SheepNoise, EOF], [SheepNoise SheepNoise baa, EOF], [SheepNoise baa, EOF], [SheepNoise SheepNoise baa, baa], [SheepNoise baa, baa] } S 1 = Goto(S 0, SheepNoise) = else if i is [A β,a] then ACTION[x,a] reduce A β [SheepNoise baa, baa] } { [Goal SheepNoise, EOF], [SheepNoise SheepNoise baa, EOF], [SheepNoise SheepNoise baa, baa] } S 2 = Goto(S 0, baa) = { [SheepNoise baa, EOF], S 3 = Goto(S 1, baa) = { [SheepNoise SheepNoise baa, EOF], [SheepNoise SheepNoise baa, baa] } ACTION[S 3,EOF] is reduce 1 0 Goal SheepNoise 1 SheepNoise SheepNoise baa 2 baa ACTION[S 3,baa] is reduce 1, as well

Example from SheepNoise The GOTO Table records Goto transitions on NTs s 0 : { [Goal SheepNoise, EOF], [SheepNoise SheepNoise baa, EOF], [SheepNoise baa, EOF], [SheepNoise SheepNoise baa, baa], [SheepNoise baa, baa] } s 1 = Goto(S 0, SheepNoise) = { [Goal SheepNoise, EOF], [SheepNoise SheepNoise baa, EOF], [SheepNoise SheepNoise baa, baa] } Puts s 1 in GOTO[s 0,SheepNoise] s 2 = Goto(S 0, baa) = { [SheepNoise baa, EOF], [SheepNoise baa, baa] } Based on T, not NT and written into the ACTION table s 3 = Goto(S 1, baa) = { [SheepNoise SheepNoise baa, EOF], [SheepNoise SheepNoise baa, baa] } 0 Goal SheepNoise 1 SheepNoise SheepNoise baa 2 baa Only 1 transition in the entire GOTO table Remember, we recorded these so we don t need to recompute them.

ACTION & GOTO Tables Here are the tables for the SheepNoise grammar The tables ACTION TABLE State EOF baa 0 shift 2 1 accept shift 3 2 reduce 2 reduce 2 3 reduce 1 reduce 1 GOTO TABLE State SheepNoise 0 1 1 0 2 0 3 0 The grammar 0 Goal SheepNoise 1 SheepNoise SheepNoise baa 2 baa

What can go wrong? Shift/reduce error What if set s contains [A β aγ,b] and [B β,a]? First item generates shift, second generates reduce Both set ACTION[s,a] cannot do both actions This is ambiguity, called a shift/reduce error Modify the grammar to eliminate it Shifting will often resolve it correctly (if-then-else)

What can go wrong? Reduce/reduce conflict What is set s contains [A γ, a] and [B γ, a]? Each generates reduce, but with a different production Both set ACTION[s,a] cannot do both reductions This ambiguity is called reduce/reduce conflict Modify the grammar to eliminate it (PL/I s overloading of (...)) In either case, the grammar is not LR(1)

CYK Parser Simple context-free-language parser Worse-case running time is O(n 3 ), space is O(n 2 ) Employs bottom-up parsing and dynamic programming Shunned for many years Even tabular methods [CYK, Earley] should be avoided if the language at hand has a grammar for which more efficient algorithms [LL, LALR] are available. The Theory of Parsing., Aho, Ullman, 1972 But in practice, running time is more like O(n 1.2 ) - Plus computers are now 1,000,000-times faster than in 1972 - And (more importantly) CYK parser is easily parallelizable! Source: Ras Bodik, Slides: Browsing Web 3.0 on 3.0 Watts

CYK Parser (Sequential Version)

CYK Parser (Sequential Version)

CYK Parser (Sequential Version)

CYK Parser (Sequential Version)

CYK Parser (Sequential Version)

CYK Parser (Sequential Version)

CYK Parser (Sequential Version)

CYK Parser (Sequential Version)

CYK Parser (Sequential Version)

CYK Parser (Sequential Version)

CYK Parser (Sequential Version)

CYK Parser (Sequential Version)

CYK Parser (Sequential Version)

CYK Parser (Sequential Version)

CYK Parser (Sequential Version)

CYK Parser (Sequential Version)

CYK Parser (Sequential Version)

CYK Parser (Sequential Version)

CYK Parser (Sequential Version)

CYK Parser (Sequential Version)

CYK Parser (Sequential Version)

CYK Parser (Sequential Version)

CYK Parser (Sequential Version)

The CYK Parser Algorithm (Sequential Version)

Phase IV: Semantic Checking