Taming Context-Sensitive Languages with Principled Stateful Parsing

Nicolas Laurent, Kim Mens
9/17/2016
10 citations
cs.PL

Official code: ncellar/sle2016 (3 stars, Kotlin, last commit 2016-09-21).

Abstract

Historically, true context-sensitive parsing has seldom been applied to programming languages, due to its inherent complexity. However, many mainstream programming and markup languages (C, Haskell, Python, XML, and more) possess context-sensitive features.

Show full abstract

These features are traditionally handled with ad-hoc code (e.g., custom lexers), outside of the scope of parsing theory. Current grammar formalisms struggle to express context-sensitive features. Most solutions lack context transparency: they make grammars hard to write, maintain and compose by hardwiring context through the entire grammar. Instead, we approach context-sensitive parsing through the idea that parsers may recall previously matched input (or data derived therefrom) in order to make parsing decisions. We make use of mutable parse state to enable this form of recall. We introduce principled stateful parsing as a new transactional discipline that makes state changes transparent to parsing mechanisms such as backtracking and memoization. To enforce this discipline, users specify parsers using formally specified primitive state manipulation operations. Our solution is available as a parsing library named Autumn. We illustrate our solution by implementing some practical context-sensitive grammar features such as significant whitespace handling and namespace classification.

View on arXivView PDF

Code Implementations(1)

ncellar/sle2016Official100%

Artifacts related to the SLE 2016 paper "Taming Context-Sensitive Languages with Principled Stateful Parsing"

31Kotlin, MakefileSep 12, 201610 years ago

Similar Papers

Cite this paper

@article{laurent2016taming,
  title  = {Taming Context-Sensitive Languages with Principled Stateful Parsing},
  author = {Nicolas Laurent and Kim Mens},
  year   = {2016},
  eprint = {1609.05365},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/1609.05365}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/1609.05365.svg)](https://codeofpaper.com/paper/1609.05365)

Discussion