Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
skip to main content
10.1145/2635648.2635650acmotherconferencesArticle/Chapter ViewAbstractPublication PagessplashConference Proceedingsconference-collections
research-article

PaGe: Portable LALR(1) Parser Generator

Published: 14 August 2014 Publication History

Abstract

PaGe is a portable, compact and reliable LALR(1) parser generator with more general disambiguation method compared to that of traditional parser generator such as Bison.
From the past to the present, very many parser generators are implemented in various programming languages. In particular, Bison in C language is a notable one due to its high efficiency and reliability. It is surely the de fact standard parser generator in C.
We have recently faced with a requirement of making some parsers for relatively large languages in Common Lisp. We prefer commercial products due to its reliability and user supports. Especially, problems with such complex tool should only be solved by someone who has deep knowledge about the tool. Thus, we chose ACL (Allegro Common Lisp) which is one of the most widely used Lisp programming environment. Unfortunately, ACL does not provide official parser generator. As for free software, as far as we know, there is no such tool comparable to Bison in the above sense.
Since Lisp has powerful and universal syntactic expression, namely S-expression, it is sufficient for Lispers to express and handle any syntactic objects. We suspect that that is why parser generators are not so important to Lispers. Nevertheless reliable parser generator in Lisp is needed when we develop tools dealing with anther languages, such as compilers and program analizers.
This is the motivation for developing original parser generator in Lisp.
One of PaGe's concept is to give a legible implementation of DeRemer's method for Look-Ahead Set. This method makes us enable to generate LALR(1)-parsing-table dircetly from LR(0)-parsing-table by computing Look-Ahead Set based on formal definitions of them. For example, DeRemer's method has used in Bison, but there is few other implementation, particularly on Lisp. Therefore we decided to give a legible implementation for who would like to understand it.
Other concept is to simplify PaGe's core program for efficiency and readability as possible. As a result, PaGe is composed of parser generator engine PaGEn and its wrapper. PaGEn is a pared parser-generator engine. PaGEn's input is a grammar whose "symbols" are restricted to non-negative integer. By this restriction, we were able to establish both program efficiency and algorithm readablity, for instance we can naturally use array as function.
Consequently, the role of wrapper are mainly two of translation and interpreting. A wrapper translates symbolic input such as grammar or sequence of token into numeric input for PaGEn. PaGEn get this as input and return parsing-table or result of parse, for instance. Then the wrapper interprets this result for an user or other system. Now, we have defined only the wrapper for using PaGEn in the same way for traditional parser generator. If you wish to use PaGEn for other purpose, you need only to define the wrapper.
Furthermore, PaGEn can deal with ambiguous grammar i.e. it supports disambiguation. PaGEn's disambiguation method is so simple. First we give two priority to each rule for reduce-time and shift-time. If some conflict has occurred, then, we try to solve each conflicts by comparing priorities. For Reduce/Reduce-conflicts, we solve it by Reduce using the rule which has the greatest reduce-time-priority in conflicted rules. For Shift/Reduce-conflicts, 2 pattern exists. If the propagation-priority, computed from several shift-time-priorities, is greater than the reduce-time-priority of the rule, we solve by shift. If the reduce-time-priority is greater than the propagation-priority we solve by reduce.
This method is more general than the method which specifies the associativity of an operator directly, in translatability sense. And, dangling-else probrem can be solved uniformly in this method.

Index Terms

  1. PaGe: Portable LALR(1) Parser Generator

    Recommendations

    Comments

    Information & Contributors

    Information

    Published In

    cover image ACM Other conferences
    ILC '14: Proceedings of ILC 2014 on 8th International Lisp Conference
    August 2014
    108 pages
    ISBN:9781450329316
    DOI:10.1145/2635648
    • General Chair:
    • Marc Feeley,
    • Program Chair:
    • Didier Verna
    Permission to make digital or hard copies of part or all of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for third-party components of this work must be honored. For all other uses, contact the Owner/Author.

    In-Cooperation

    Publisher

    Association for Computing Machinery

    New York, NY, United States

    Publication History

    Published: 14 August 2014

    Check for updates

    Author Tags

    1. disambiguation
    2. modular design
    3. parser generator

    Qualifiers

    • Research-article
    • Research
    • Refereed limited

    Conference

    ILC '14
    ILC '14: 2014 International Lisp Conference
    August 14 - 17, 2014
    QC, Montreal, Canada

    Acceptance Rates

    ILC '14 Paper Acceptance Rate 18 of 26 submissions, 69%;
    Overall Acceptance Rate 18 of 26 submissions, 69%

    Contributors

    Other Metrics

    Bibliometrics & Citations

    Bibliometrics

    Article Metrics

    • 0
      Total Citations
    • 166
      Total Downloads
    • Downloads (Last 12 months)0
    • Downloads (Last 6 weeks)0
    Reflects downloads up to 09 Nov 2024

    Other Metrics

    Citations

    View Options

    Get Access

    Login options

    View options

    PDF

    View or Download as a PDF file.

    PDF

    eReader

    View online with eReader.

    eReader

    Media

    Figures

    Other

    Tables

    Share

    Share

    Share this Publication link

    Share on social media