@hackage symantic-parser0.1.0.20210201

Parser combinators statically optimized and staged via typed meta-programming

Main differences with respect to ParsleyHaskell

  • Extensible primitive grammar combinators, including their underlying optimization passes, by leveraging reciprocal injections between a tagless-final encoding of syntaxes (aka. type-classes) and a corresponding tagful-initial encoding to pattern-match syntaxes (aka. data-instances). This enable a very principled, yet flexible source code. Moreover DefaultSignatures are supplied to succinctly derive new semantics (aka. type-class-instances) using automatic transformations.

  • Error messages based upon the farthest input position reached (not yet implemented in ParsleyHaskell).

  • Minimal input length checks ("horizon" checks) required for a successful parsing are factorized using a different static analysis than ParsleyHaskell's "piggy bank" which I've not understood well. This analyis can see beyond calls to subroutines, but maybe ParsleyHaskell's analysis can also be adjusted to do the same. Both analysis are not well documented and studied.

  • No dependency upon GHC plugins: lift-plugin and idioms-plugin, because those are plugins hence introduce a bit of complexity in the build processes using this parser, but most importantly they are experimental and mostly cosmetics, since they only enable a cleaner usage of the parsing combinators, by lifting Haskell code in pure to integrate the TemplateHaskell needed. I do not understand them that much and do not feel confortable to maintain them come the day that their authors abandon them.

  • No dependency upon dependent-map by keeping observed sharing inside def and ref combinators, instead of passing by a DMap. And also when introducing the join-points optimization, where fresh TemplateHaskell names are also directly used instead of passing by a DMap.

  • No support for general purpose registers in the Machine producing the TemplateHaskell splices (maybe it will come if I need and understand what's done in ParsleyHaskell).

  • License is GPL-3.0-or-later not BSD-3-Clause.

Main goals

  • For me to better understand ParsleyHaskell, and find a manageable balance between simplicity of the codebase and features of the parser. And by doing so, challenging and showcasing symantic techniques.

  • To support the parsing of tree-like data structures instead of only string-like data structures. Eg. to validate XML using RelaxNG in symantic-xml or to perform routing of HTTP requests in symantic-http-server. This is currently done in those packages using megaparsec, but megaparsec is not conceived for such input, and is less principled when it comes to optimizing, like merging alternatives.