Taming Context-Sensitive Languages with Principled Stateful Parsing
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. 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.
Conference DayMon 31 OctDisplayed time zone: Amsterdam, Berlin, Bern, Rome, Stockholm, Vienna change
10:30 - 12:10
|Parsing and Reflective Printing, Bidirectionally|
Zirun ZhuNational University SOKENDAI, Japan, Yongzhe ZhangNational University SOKENDAI, Japan, Hsiang-Shang ‘Josh’ KoNational Institute of Informatics, Pedro MartinsUniversity of California at Irvine, USA, João SaraivaUniversity of Minho, Portugal, Zhenjiang HuNational University SOKENDAI, JapanDOI
|Taming Context-Sensitive Languages with Principled Stateful Parsing|
Nicolas LaurentUniversité Catholique de Louvain, Belgium, Kim MensUniversité Catholique de Louvain, BelgiumDOI Pre-print
|MetaEdit+ for Collaborative Language Engineering and Language Use (Tool Demo)|
Juha-Pekka TolvanenMetaCase, FinlandDOI Pre-print Media Attached
|Efficient Development of Consistent Projectional Editors using Grammar Cells|
Markus Völteritemis, Germany, Tamás Szabóitemis AG / TU Delft, Sascha Lissonitemis AG, Bernd Kolbitemis AG, Sebastian ErdwegDelft University of Technology, Netherlands, Thorsten BergerChalmers University of Technology, SwedenDOI Pre-print Media Attached