Eliminating Left Recursion without the Epsilon

08/28/2019
by   James Smith, et al.
0

The standard algorithm to eliminate indirect left recursion takes a preventative approach, reorganising a grammar in such a way that indirect left recursion is no longer possible, rather than eliminating it only as and when it occurs. This approach results in many of the grammar's rules being lost, however, so that the resulting parse trees are often devoid of the detail that the grammar was supposed to pick out in the first place. To avoid this pitfall, we extend a revised version of the standard algorithm to eliminate immediate left recursion to a recursive algorithm to explicitly eliminate indirect left recursion. By taking this approach, all of the grammar's original rules are retained, resulting in parse trees that are still useful in practice. A novel quirk of this approach is that the usual empty definitions with ϵ parts are eschewed in favour of optional parts in the right recursive rules that the algorithm generates.

READ FULL TEXT

page 1

page 2

page 3

page 4

research
05/13/2020

Pika parsing: reformulating packrat parsing as a dynamic programming algorithm solves the left recursion and error recovery problems

A recursive descent parser is built from a set of mutually-recursive fun...
research
05/13/2020

Pika parsing: parsing in reverse solves the left recursion and error recovery problems

A recursive descent parser is built from a set of mutually-recursive fun...
research
04/30/2023

How to enumerate trees from a context-free grammar

I present a simple algorithm for enumerating the trees generated by a Co...
research
10/23/2022

A Stack-Free Traversal Algorithm for Left-Balanced k-d Trees

We present an algorithm that allows for find-closest-point and kNN-style...
research
07/13/2020

Gradient Descent over Metagrammars for Syntax-Guided Synthesis

The performance of a syntax-guided synthesis algorithm is highly depende...
research
08/30/2021

Learning Highly Recursive Input Grammars

This paper presents Arvada, an algorithm for learning context-free gramm...
research
11/20/2018

A right-to-left type system for mutually-recursive value definitions

In call-by-value languages, some mutually-recursive value definitions ca...

Please sign up or login with your details

Forgot password? Click here to reset