@hackage symantic-parser0.2.0.20210703
Parser combinators statically optimized and staged via typed meta-programming
Categories
License
AGPL-3.0-or-later
Maintainer
Julien Moutinho <julm+symantic-parser@sourcephile.fr>
Links
Versions
- 0.2.1.20210803 Tue, 31 Aug 2021
- 0.2.0.20210703 Sun, 11 Jul 2021
- 0.1.0.20210201 Mon, 1 Feb 2021
- 0.0.0.20210102 Sat, 2 Jan 2021
- 0.0.0.20210101 Fri, 1 Jan 2021
Installation
Tested Compilers
Dependencies (34)
- array
- base >=4.10 && <5
- bytestring
- containers
- deepseq >=1.4
- ghc-prim Show all…
Dependents (0)
Package Flags
dump-core
(off by default)
Dump GHC's Core in HTML
disable-ormolu-check
(off by default)
Remove ormolu from build-tool-depends. Temporary hack while Nixpkgs' haskellPackages.ormolu remains broken.
Main differences with respect to ParsleyHaskell
-
Primitive grammar combinators are extensible, including the optimization pass for which they are the current top-level combinator.
-
Error messages are based upon the farthest input position reached (not yet implemented in
ParsleyHaskell) and a there is a preliminary support for error messages based upon labeled failures. -
Minimal input length checks ("horizon" checks) required for a successful parsing are statically computed using a polyfix to see beyond calls to subroutines, which is not (yet) possible in
ParsleyHaskell. -
No dependency upon GHC plugins:
lift-plugin,idioms-pluginorparsley-garnishfor users. Those provide convenient syntaxic-sugar (by quoting an Haskell expression as itself and itsTemplateHaskellequivalent) for writing grammar productions, but are experimental, but I do not understand them that much and do not feel confortable to maintain them in case their authors abandon them. -
No dependency upon
dependent-mapby keeping observed sharing indefandrefcombinators, instead of passing by aDMap. And also when introducing the join-points optimization, where freshTemplateHaskellnames are also directly used instead of passing by aDMap. -
No support (yet?) for general purpose registers in the
Machineproducing theTemplateHaskellsplices. Hencesymantic-parsergenerates parser much slower thanParsleyHaskell, comparable toattoparsecin the Brainfuck benchmark. -
License is
AGPL-3-or-laternotBSD-3-Clause. -
Testing grammars have their generated machines and
TemplateHaskellsplices followed by golden tests.
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, butmegaparsecis not conceived for such input, and is less principled when it comes to optimizing, like merging alternatives.
Implementation techniques
Typed Tagless-Final
The syntax of grammars are term-level combinators defined in type-classes, and their semantics are data-types having instances of those type-classes. And the same technique is applied for machine instructions and grammar productions.
For automatic deriving, DefaultSignatures are supplied using automatic transformations, see Symantic.Typed.Trans.
For pattern-matching, data-families indexed by the syntaxic type-class are supplied,
see Symantic.Typed.Data.