D

DHParser

DHParser - Toolchain for Domain Specific Languages in the Digital Humanities.

DHParser

A parser-combinator-based parsing and compiling infrastructure for domain specific languages (DSL) in Digital Humanities projects.

Author: Eckhart Arnold, Bavarian Academy of Sciences Email: arnold@badw.de

License

DHParser is open source software under the MIT License

Purpose

Domain specific languages are widespread in computer sciences, but seem to be underused in the Digital Humanities. While DSLs are sometimes introduced to Digital-Humanities-projects as practical adhoc-solution, these solutions are often somewhat "quick and dirty". In other words they are more of a hack than a technology. The purpose of DHParser is to introduce DSLs as a technology to the Digital Humanities. It is based on the well known technology of EBNF-based parser generators, but employs the more modern form called "parsing expression grammar" and parser combinators as a variant of the classical recursive descent parser.

Why another parser generator? There are plenty of good parser generators out there, e.g. Añez's grako parser generator, Eclipse XText. However, DHParser is intended as a tool that is specifically geared towards digital humanities applications, while most existing parser generators come from compiler construction toolkits for programming languages. Also, DHParser shall (in the future) serve as a teching tool, which influences some of its design decisions such as, for example, clearly separating the parsing, syntax-tree-transformation and compilation stages. Also, DHParser is intended as a tool to experiment with. One possible research area is, how non context-free grammars such as the grammars of TeX or CommonMark can be described with declarative langauges in the spirit of but beyond EBNF, and what extensions of the parsing technology are necessary to capture such languages.

Primary use case at the Bavarian Academy of Sciences and Humanities (for the time being): A DSL for the "Mittellateinische Wörterbuch"!

Further (intended) use cases are:

  • LaTeX -> XML/HTML conversion. See this discussion on why an EBNF-parser for the complete TeX/LaTeX-grammar is not possible.
  • CommonMark and other DSLs for cross media publishing of scientific literature, e.g. journal articles. (Common Mark and Markdown also go beyond what is feasible with pure EBNF-based-parsers.)
  • EBNF itself. DHParser is already self-hosting ;-)
  • Digital and cross-media editions
  • Digital dictionaries

Description

... comming soon ;-)

For a simple self-test run dhparser.py from the command line. This compiles the EBNF-Grammer in examples/EBNF/EBNF.ebnf and outputs the Python-based parser class representing that grammar. The concrete and abstract syntax tree as well as a full and abbreviated log of the parsing process will be stored in a sub-directory named "DEBUG".

References

Juancarlo Añez: grako, a PEG parser generator in Python, 2017. URL: bitbucket.org/apalala/grako

Eckhart Arnold: Domänenspezifische Notationen. Eine (noch) unterschätzte Technologie in den Digitalen Geisteswissenschaften, Präsentation auf dem dhmuc-Workshop: Digitale Editionen und Auszeichnungssprachen, München 2016. Short-URL: tiny.badw.de/2JVT

Brian Ford: Parsing Expression Grammars: A Recognition-Based Syntactic Foundation, Cambridge Massachusetts, 2004. Short-URL:http://t1p.de/jihs

Richard A. Frost, Rahmatullah Hafiz and Paul Callaghan: Parser Combinators for Ambiguous Left-Recursive Grammars, in: P. Hudak and D.S. Warren (Eds.): PADL 2008, LNCS 4902, pp. 167–181, Springer-Verlag Berlin Heidelberg 2008.

Dominikus Herzberg: Objekt-orientierte Parser-Kombinatoren in Python, Blog-Post, September, 18th 2008 on denkspuren. gedanken, ideen, anregungen und links rund um informatik-themen, short-URL: http://t1p.de/bm3k

Dominikus Herzberg: Eine einfache Grammatik für LaTeX, Blog-Post, September, 18th 2008 on denkspuren. gedanken, ideen, anregungen und links rund um informatik-themen, short-URL: http://t1p.de/7jzh

Dominikus Herzberg: Uniform Syntax, Blog-Post, February, 27th 2007 on denkspuren. gedanken, ideen, anregungen und links rund um informatik-themen, short-URL: http://t1p.de/s0zk

John MacFarlane, David Greenspan, Vicent Marti, Neil Williams, Benjamin Dumke-von der Ehe, Jeff Atwood: CommonMark. A strongly defined, highly compatible specification of Markdown, 2017. commonmark.org

Stefan Müller: DSLs in den digitalen Geisteswissenschaften, Präsentation auf dem dhmuc-Workshop: Digitale Editionen und Auszeichnungssprachen, München 2016. Short-URL: tiny.badw.de/2JVy