Publikation

Zurück zur Übersicht

Top-Down Parsing with Parsing Contexts

Publikationsart Peer-reviewed
Publikationsform Tagungsbeitrag (peer-reviewed)
Publikationsjahr 2014
Autor/in Kurš Jan, Lungu Mircea, Nierstrasz Oscar
Projekt Agile Software Assessment
Alle Daten anzeigen

Tagungsbeitrag (peer-reviewed)

Titel der Proceedings Proceedings of International Workshop on Smalltalk Technologies (IWST 2014)
Status Publiziert

Open Access

Abstract

The domain of context-free languages has been extensively explored and there exist numerous techniques for parsing (all or a subset of) context-free languages. Unfortunately, some programming languages are not context-free. Using standard context-free parsing techniques to parse a context-sensitive programming language poses a considerable challenge. Im- plementors of programming language parsers have adopted various techniques, such as hand-written parsers, special lex- ers, or post-processing of an ambiguous parser output to deal with that challenge. In this paper we suggest a simple extension of a top-down parser with contextual information. Contrary to the tradi- tional approach that uses only the input stream as an input to a parsing function, we use a parsing context that provides ac- cess to a stream and possibly to other context-sensitive infor- mation. At a same time we keep the context-free formalism so a grammar definition stays simple without mind-blowing context-sensitive rules. We show that our approach can be used for various purposes such as indent-sensitive parsing, a high-precision island parsing or XML (with arbitrary el- ement names) parsing. We demonstrate our solution with PetitParser, a parsing-expression grammar based, top-down, parser combinator framework written in Smalltalk.