Layout Sensitive Parsing in Petit Parser Framework

Attieh Sadeghi Givi. Layout Sensitive Parsing in Petit Parser Framework. Bachelor’s thesis, University of Bern, October 2012. Details.


Most parser frameworks can parse a context-free language generated by different context-free grammars. However, many languages are not context-free. One important class of such languages is layout-sensitive languages (eg Python, Haskell), in which the structure of code depends on indentation and whitespace. The parsers (and lexers) of this kind of languages are not declaratively specified but hand-tuned to account for layout-sensitivity. To support parsing of layout-sensitive languages, we propose an extension of parsing expression grammars in which a user is able to declare layout-sensitive specifications. For example, a user can declare a consisting block of statements to be aligned and arbitrary positioned. We have implemented our extension in a Petit Parser framework. We evaluate the correctness and performance of our parser by parsing Python- and Haskell-like grammars.

Posted by scg at 30 October 2013, 6:58 pm link


Exciting work. Where can we find the code?

Posted by StephaneDucasse at 1 November 2013, 10:49 pm link
Last changed by admin on 21 April 2009