Agenda Preliminaries Motivation and Research questions Exploring GLL

Slides:



Advertisements
Similar presentations
Compiler Construction
Advertisements

Semantics Static semantics Dynamic semantics attribute grammars
A question from last class: construct the predictive parsing table for this grammar: S->i E t S e S | i E t S | a E -> B.
Bottom up Parsing Bottom up parsing trys to transform the input string into the start symbol. Moves through a sequence of sentential forms (sequence of.
May 2006CLINT-LN Parsing1 Computational Linguistics Introduction Approaches to Parsing.
CSE 425: Semantic Analysis Semantic Analysis Allows rigorous specification of a program’s meaning –Lets (parts of) programming languages be proven correct.
Predictive Parsing l Find derivation for an input string, l Build a abstract syntax tree (AST) –a representation of the parsed program l Build a symbol.
CS 330 Programming Languages 09 / 13 / 2007 Instructor: Michael Eckmann.
ISBN Chapter 4 Lexical and Syntax Analysis The Parsing Problem Recursive-Descent Parsing.
Syntax Analysis Mooly Sagiv html:// Textbook:Modern Compiler Design Chapter 2.2 (Partial) Hashlama 11:00-14:00.
Parsing SLP Chapter 13. 7/2/2015 Speech and Language Processing - Jurafsky and Martin 2 Outline  Parsing with CFGs  Bottom-up, top-down  CKY parsing.
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.
Lexical and syntax analysis
EECS 6083 Intro to Parsing Context Free Grammars
Parsing IV Bottom-up Parsing Copyright 2003, Keith D. Cooper, Ken Kennedy & Linda Torczon, all rights reserved. Students enrolled in Comp 412 at Rice University.
ITEC 380 Organization of programming languages Lecture 2 – Grammar / Language capabilities.
Parsing. Goals of Parsing Check the input for syntactic accuracy Return appropriate error messages Recover if possible Produce, or at least traverse,
Top-Down Parsing - recursive descent - predictive parsing
LANGUAGE TRANSLATORS: WEEK 3 LECTURE: Grammar Theory Introduction to Parsing Parser - Generators TUTORIAL: Questions on grammar theory WEEKLY WORK: Read.
10/13/2015IT 3271 Tow kinds of predictive parsers: Bottom-Up: The syntax tree is built up from the leaves Example: LR(1) parser Top-Down The syntax tree.
May 2006CLINT-LN Parsing1 Computational Linguistics Introduction Parsing with Context Free Grammars.
ISBN Chapter 3 Describing Semantics -Attribute Grammars -Dynamic Semantics.
Review 1.Lexical Analysis 2.Syntax Analysis 3.Semantic Analysis 4.Code Generation 5.Code Optimization.
Chapter 4 Top-Down Parsing Recursive-Descent Gang S. Liu College of Computer Science & Technology Harbin Engineering University.
1Computer Sciences Department. Book: INTRODUCTION TO THE THEORY OF COMPUTATION, SECOND EDITION, by: MICHAEL SIPSER Reference 3Computer Sciences Department.
Bottom-Up Parsing David Woolbright. The Parsing Problem Produce a parse tree starting at the leaves The order will be that of a rightmost derivation The.
1 Compiler Construction (CS-636) Muhammad Bilal Bashir UIIT, Rawalpindi.
Programming Languages and Design Lecture 2 Syntax Specifications of Programming Languages Instructor: Li Ma Department of Computer Science Texas Southern.
COMP 3438 – Part II-Lecture 5 Syntax Analysis II Dr. Zili Shao Department of Computing The Hong Kong Polytechnic Univ.
Syntax and Semantics Structure of programming languages.
LECTURE 10 Semantic Analysis. REVIEW So far, we’ve covered the following: Compilation methods: compilation vs. interpretation. The overall compilation.
Introduction to Parsing
Comp 411 Principles of Programming Languages Lecture 3 Parsing
Chapter 3 – Describing Syntax
Describing Syntax and Semantics
Chapter 4 - Parsing CSCE 343.
G. Pullaiah College of Engineering and Technology
Programming Languages Translator
Bottom-up parsing Goal of parser : build a derivation
CS510 Compiler Lecture 4.
Chapter 4 Lexical and Syntax Analysis.
Compiler design Bottom-up parsing Concepts
Bottom-Up Parsing.
Lexical and Syntax Analysis
Compiler Baojian Hua LR Parsing Compiler Baojian Hua
Unit-3 Bottom-Up-Parsing.
Introduction to Parsing (adapted from CS 164 at Berkeley)
Textbook:Modern Compiler Design
Parsing IV Bottom-up Parsing
Table-driven parsing Parsing performed by a finite state machine.
Syntax Analysis Chapter 4.
CS 404 Introduction to Compiler Design
4 (c) parsing.
Syntax Analysis Sections :.
Subject Name:COMPILER DESIGN Subject Code:10CS63
Programming Language Syntax 7
Lexical and Syntax Analysis
COP4020 Programming Languages
Compilers Principles, Techniques, & Tools Taught by Jing Zhang
Bottom Up Parsing.
Programming Language Syntax 5
Parsing IV Bottom-up Parsing
Introduction to Parsing
Introduction to Parsing
Design Patterns for Recursive Descent Parsing
Teori Bahasa dan Automata Lecture 9: Contex-Free Grammars
Kanat Bolazar February 16, 2010
Compilers Principles, Techniques, & Tools Taught by Jing Zhang
COP 4620 / 5625 Programming Language Translation / Compiler Writing Fall 2003 Lecture 2, 09/04/2003 Prof. Roy Levow.
Parsing CSCI 432 Computer Science Theory
Presentation transcript:

Exploring and visualizing Generalized LL parsing Name: Bram Cappers “An algorithm must be seen in order to be believed” - D. Knuth

Agenda Preliminaries Motivation and Research questions Exploring GLL Visualizing GLL Concept Difficulties Conclusions / Department of Mathematics and Computer Science 05/08/2014

Parsing 05/08/2014

Parsing - notation Terminal Nonterminal Grammar Production rule Alternates Input string Parse tree 05/08/2014

Top down parsing - notation Partial Derivation Derivation / name of department 05/08/2014

Generalized Parsing Supports larger class of grammars Context-free grammars Returns multiple derivations One for every possible interpretation Why? Grammar modularity Perform disambiguation outside the grammar / name of department 05/08/2014

Motivation and Research Questions Generalized LL (GLL) parsing: Top-down parser multiple derivations Founded by E. Scott and A. Johnstone Discovers derivations in parallel GLL parsers Clear code structure Easy to generate automatically Efficient Object-Oriented GLL (OOGLL) Improves extensibility parser 05/08/2014

Motivation and Research Questions Generalized LL (GLL) parsing: Relatively new technology Several mechanisms not implemented Error reporting/recovery Support EBNF format Requires knowledge about control-flow High learning curve Abstract control-flow by means of “descriptors” Difficult to distinguish derivations Introduction of shared data structures blur relationship with LL parsing 05/08/2014

Motivation and Research Questions How can we obtain a GLL parser by starting from a traditional LL parser? Identify the core problems of LL parsing vs. GLL Can we explain the control-flow of a GLL parser by means of visualization techniques? How does a GLL parser work 05/08/2014

Agenda Preliminaries Motivation and Research questions Exploring GLL Visualizing GLL Concept Difficulties Conclusions / Department of Mathematics and Computer Science 05/08/2014

Introduction – LL – A recognizer S ::= • a S a S ::= • B Consider: S ::= a S a | B; B ::= b; 1 function per production rule Use the call-stack to store where parser must continue One-to-one correspondence between grammar and code S ::= a • S a S ::= a S • a S ::= B • B ::= • b B ::= b • / Departement of Mathematics and Computer Science 05/08/2014

Introduction – LL – A recognizer Consider: S ::= a S a | B; B ::= b; stack a S a aba / Departement of Mathematics and Computer Science 05/08/2014

Introduction – LL – A recognizer Consider: S ::= a S a | B; B ::= b; stack a S a aba / Departement of Mathematics and Computer Science 05/08/2014

Introduction – LL – A recognizer Consider: S ::= a S a | B; B ::= b; stack a S a aba S ::= a S • a / Departement of Mathematics and Computer Science 05/08/2014

Introduction – LL – A recognizer Consider: S ::= a S a | B; B ::= b; stack a S a aba S ::= a S • a / Departement of Mathematics and Computer Science 05/08/2014

Introduction – LL – A recognizer Consider: S ::= a S a | B; B ::= b; stack a S a aba S ::= a S • a S ::= B • B / Departement of Mathematics and Computer Science 05/08/2014

Introduction – LL – A recognizer Consider: S ::= a S a | B; B ::= b; stack a S a aba S ::= a S • a S ::= B • B b / Departement of Mathematics and Computer Science 05/08/2014

Introduction – LL – A recognizer Consider: S ::= a S a | B; B ::= b; stack a S a aba S ::= a S • a B b / Departement of Mathematics and Computer Science 05/08/2014

Introduction – LL – A recognizer Consider: S ::= a S a | B; B ::= b; stack a S a aba S ::= a S • a B b / Departement of Mathematics and Computer Science 05/08/2014

Introduction – LL – A recognizer Consider: S ::= a S a | B; B ::= b; stack a S a aba B b / Departement of Mathematics and Computer Science 05/08/2014

Introduction – LL – A recognizer Consider: S ::= a S a | B; B ::= b; stack a S a aba B b / Departement of Mathematics and Computer Science 05/08/2014

Issues LLRD parsing No support for left-recursion E ::= E “+ 1” | “1” Call-stack Does not support/detect cycles No support for non-determinism Can only return one derivation Can only store one stack . Stack: E ::= E • “+ 1” / Departement of Mathematics and Computer Science 05/08/2014

Step 1: Take explicit control Solve issue 1: Do no use call-stack to store grammarslots Manually handle control-flow Split code into one function per grammar slot S ::= • a S a S ::= a • S a S ::= a S • a 05/08/2014

Step 1: Take explicit control Solve issue 1: Replace call-stack with our own data structure Manually handle control-flow Split code into one function per grammar slot 05/08/2014

Step 2: Support multiple derivations Solve issue 2: GLL: “parallelization of LLRD parsers” Concept: Summarize every derivation as a triple (1, 2, 3) The function where parser has left The stack corresponding to derivation The position how far input string was parsed 05/08/2014

Step 2: Support multiple derivations Solve issue 2: GLL: “parallelization of LLRD parsers” Summarize every derivation as a triple (1, 2, 3) The function where parser has left The stack corresponding to derivation The position how far input string was parsed 05/08/2014

Step 2: Support multiple derivations Solve issue 2: GLL: “parallelization of LLRD parsers” Summarize every derivation as a triple (1, 2, 3) The function where parser has left The stack corresponding to derivation The position how far input string was parsed 05/08/2014

Step 2: Support multiple derivations Solve issue 2: GLL: “parallelization of LLRD parsers” Summarize every derivation as a triple (1, 2, 3) The function where parser has left The stack corresponding to derivation The position how far input string was parsed 05/08/2014

Step 2: Support multiple derivations Solve issue 2: GLL: “parallelization of LLRD parsers” Summarize every derivation as a triple (1, 2, 3) The function where parser has left The stack corresponding to derivation The position how far input string was parsed 05/08/2014

Step 2: Support multiple derivations Solve issue 2: GLL: “parallelization of LLRD parsers” Summarize every derivation as a triple (1, 2, 3) The function where parser has left The stack corresponding to derivation The position how far input string was parsed 05/08/2014

Step 2: Support multiple derivations Solve issue 2: GLL: “parallelization of LLRD parsers” Summarize every derivation as a triple (1, 2, 3) The function where parser has left The stack corresponding to derivation The position how far input string was parsed 05/08/2014

Step 2: Support multiple derivations Solve issue 2: GLL: “parallelization of LLRD parsers” Summarize every derivation as a triple (1, 2, 3) The function where parser has left The stack corresponding to derivation The position how far input string was parsed 05/08/2014

GSS Stacks have a lot in common Combine multiple stacks into one data structure Replace stack in triple with a GSS node 05/08/2014

Descriptor Descriptor: triple with GSS node “Job description” where one or more derivations are interested in. Example: (S ::= • a S a, S ::= a S • a, aba) To parse: a S of a S a starting from aba Upon success, continue with S ::= a S • a 05/08/2014

Agenda Preliminaries Motivation and Research questions Exploring GLL Visualizing GLL Concept Difficulties Conclusions / Department of Mathematics and Computer Science 05/08/2014

Why do we want to explore/visualize Generalized parsing? GLR/GLL discover derivations in parallel Difficult to distinguish derivations Manual control-flow through descriptors Descriptors generated everywhere Makes it difficult to reason why descriptors are created at certain positions Large amount of descriptors Why GLL? OOGLL suitable to realize visualization Conceptually easier to understand Top-down parsing less complex to visualize 05/08/2014

Goal visualization Step-by-step visualization of GLL Reducing the learning curve as much as possible Education purposes Explanation LL vs. GLL parsing To speed up development of GLL extensions In particular: Visualize how data structures evolve over time. Explain why/when descriptors work are created / name of department 05/08/2014

Visualizing GLL parsing S ::= A S d | a S | ɛ A ::= a Grammar “walking” Algorithm  walker Derivation  “tree” Stack  “path from walker to root” Start  Start symbol grammar Destination  Point without substitutions 05/08/2014

Visualizing GLL parsing (2) Summarize derivations in one tree Improve scalability Descriptor: “Point of continue” for 1 or more derivations Sitting walker Descriptors to be processed / name of department 05/08/2014

Visualizing sharing Walking routes in parallel Detection sharing One walker per derivation Detection sharing Same input position Same walker position Postponed sharing: Descriptor processed “too soon” Notify user using messaging / name of department 05/08/2014

Descriptors paradox Visualizing Descriptor: Visualizing Control-flow: Independent chunk of work where one or more derivations are interested in. Visualizing Control-flow: Show progress of derivations discovered so far How to properly visualize a descriptor if not all derivations have been discovered? / name of department 05/08/2014

Difficulties Reversion technology Ambiguities Level of detail Parallel changes over multiple views hard to follow Control algorithm with “tape-recording” functionality Ambiguities Visualize overlap in derivations Level of detail Many special cases in the GLL algorithm Dynamic behaviour of descriptor over time Descriptors paradox / name of department 05/08/2014

Conclusions on visualization Advantages: Simple concept to understand Clear relationship between LL and GLL Concept is applicable to top down-parsing in general Disadvantages: At runtime visualization insufficient to consistently visualize descriptors Not suitable for highly ambiguous grammars / name of department 05/08/2014