KIT | KIT-Bibliothek | Impressum | Datenschutz

Layout-sensitive Generalized Parsing

Erdweg, Sebastian ORCID iD icon 1; Rendel, Tillmann; Kästner, Christian; Ostermann, Klaus
1 Institut für Programmstrukturen und Datenorganisation (IPD), Karlsruher Institut für Technologie (KIT)

Abstract (englisch):

The theory of context-free languages is well-understood and context-free parsers can be used as off-the-shelf tools in practice. In particular, to use a context-free parser framework, a user does not need to understand its internals but can specify a language declaratively as a grammar. However, many languages in practice are not context-free. One particularly important class of such languages is layout-sensitive languages, in which the structure of code depends on indentation and whitespace. For example, Python, Haskell, F#, and Markdown use indentation instead of curly braces to determine the block structure of code. Their parsers (and lexers) are not declaratively specified but hand-tuned to account for layout-sensitivity. To support declarative specifications of layout-sensitive languages, we propose a parsing framework in which a user can annotate layout in a grammar. Annotations take the form of constraints on the relative positioning of tokens in the parsed subtrees. For example, a user can declare that a block consists of statements that all start on the same column. We have integrated layout constraints into SDF and implemented a layout-sensitive generalized parser as an extension of generalized LR parsing. ... mehr


Originalveröffentlichung
DOI: 10.1007/978-3-642-36089-3_14
Zugehörige Institution(en) am KIT Institut für Programmstrukturen und Datenorganisation (IPD)
Publikationstyp Proceedingsbeitrag
Publikationsjahr 2012
Sprache Englisch
Identifikator ISSN: 1611-3349
KITopen-ID: 1000188535
Erschienen in Lecture Notes in Computer Science (SLE); Dresden, Deutschland, 26.-28.09.2012
Veranstaltung 5th International Conference on Software Language Engineering, SLE 2012 (2012), Dresden, Deutschland, 26.09.2012 – 28.09.2012
Verlag Springer
Seiten 244–263
Serie Lecture Notes in Computer Science (LNSC) ; 7745
Nachgewiesen in Scopus
KIT – Die Universität in der Helmholtz-Gemeinschaft
KITopen Landing Page