]> Git — Sourcephile - haskell/symantic-parser.git/blob - symantic-parser.cabal
add more Nix conveniencies
[haskell/symantic-parser.git] / symantic-parser.cabal
1 cabal-version: 2.2
2 name: symantic-parser
3 version: 0.0.0.20210101
4 synopsis: Parser combinators staged using Typed Template Haskell
5 description:
6 This is a work-in-progress experimental library to generate
7 parsers, leveraging Tagless-Final combinators and Typed
8 Template Haskell.
9 .
10 This is an alternative but less powerful/reviewed
11 implementation of [ParsleyHaskell](https://github.com/J-mie6/ParsleyHaskell).
12 See the paper by Jamie Willis, Nicolas Wu, and Matthew
13 Pickering, admirably well presented at ICFP-2020: [Staged
14 Selective Parser
15 Combinators](https://icfp20.sigplan.org/details/icfp-2020-papers/20/Staged-Selective-Parser-Combinators).
16 .
17 Main differences are:
18 .
19 * Tagless-final and DefaultSignatures are used
20 instead of tagfull-final to handle recursion schemes,
21 this avoids constructing and deconstructing as much tags when transforming
22 combinators or instructions.
23 And structures/simplifies the code by avoiding to define
24 custom traversals (traverseCombinator)
25 or custom fix-point data-types (Fix4)
26 and associated utilities (cata4) when introducing new index-types.
27 Note that the extensibility of combinators, a great feature of tagless-final,
28 is not really achievable when using the optimizing pass
29 which requires a comprehensive initial encoding.
30 * No dependency on dependant-map by keeping observed sharing
31 inside 'def' and 'ref' combinators, instead of passing by a DependantMap.
32 * No dependency on GHC plugins: lift-plugin and idioms-plugin,
33 because those are plugins hence introduce a bit of complexity
34 in the build process, but most importantly they are experimental
35 and only cosmetic, since they only enable a cleaner usage
36 of the parsing combinators, by lifting Haskell code in 'pure'
37 to integrate the TemplateHaskell needed.
38 I do not understand them (yet) and do not feel confortable
39 to maintain them in case their authors abandon them.
40 * Error messages based upon the farthest input position reached (not yet implemented in Parsley).
41 * License is GPL-3.0-or-later not BSD-3-Clause.
42 .
43 Goals are:
44 .
45 * For me to understand ParsleyHaskell, and find a manageable balance
46 between simplicity of the codebase and features of the parser.
47 * To support parsing tree-like data structures (like XML or HTTP routes)
48 instead of just string-like data structures,
49 which is doable with megaparsec, but is hard and less principled
50 when it comes to optimizing, like merging alternatives.
51 .
52 TODO:
53 .
54 * Factorize input size checks (like Parsley's piggy bank).
55 * Error messages also based upon: [A Parsing Machine for Parsing Expression Grammars with Labeled Failures](https://dl.acm.org/doi/10.1145/2851613.2851750)
56 * Registers?
57 license: GPL-3.0-or-later
58 author: Julien Moutinho <julm+symantic-parser@sourcephile.fr>
59 maintainer: Julien Moutinho <julm+symantic-parser@sourcephile.fr>
60 bug-reports: Julien Moutinho <julm+symantic-parser@sourcephile.fr>
61 copyright: Julien Moutinho <julm+symantic-parser@sourcephile.fr>
62 stability: experimental
63 category: Parsing
64 extra-source-files:
65 .envrc
66 Makefile
67 cabal.project
68 default.nix
69 flake.nix
70 shell.nix
71 extra-tmp-files:
72 build-type: Simple
73 tested-with: GHC==9.0.0
74
75 source-repository head
76 type: git
77 location: git://git.sourcephile.fr/haskell/symantic-parser
78
79 flag dump-core
80 description: Dump GHC's Core in HTML
81 manual: True
82 default: False
83
84 flag dump-splice
85 description: Dump code generated by Template Haskell
86 manual: True
87 default: False
88
89 common boilerplate
90 default-language: Haskell2010
91 default-extensions:
92 BangPatterns,
93 DataKinds,
94 FlexibleContexts,
95 FlexibleInstances,
96 GADTs,
97 GeneralizedNewtypeDeriving,
98 LambdaCase,
99 MultiParamTypeClasses,
100 NamedFieldPuns,
101 NoImplicitPrelude,
102 RankNTypes,
103 RecordWildCards,
104 ScopedTypeVariables,
105 TypeApplications,
106 TypeFamilies,
107 TypeOperators
108 ghc-options:
109 -Wall
110 -Wincomplete-uni-patterns
111 -Wincomplete-record-updates
112 -fhide-source-paths
113 -freverse-errors
114
115 library
116 import: boilerplate
117 hs-source-dirs: src
118 exposed-modules:
119 Symantic.Univariant.Letable
120 Symantic.Univariant.Trans
121 Symantic.Parser
122 Symantic.Parser.Grammar
123 Symantic.Parser.Grammar.Combinators
124 Symantic.Parser.Grammar.Dump
125 Symantic.Parser.Grammar.Fixity
126 Symantic.Parser.Grammar.ObserveSharing
127 Symantic.Parser.Grammar.Optimize
128 Symantic.Parser.Grammar.Write
129 Symantic.Parser.Haskell
130 Symantic.Parser.Machine
131 Symantic.Parser.Machine.Dump
132 Symantic.Parser.Machine.Generate
133 Symantic.Parser.Machine.Input
134 Symantic.Parser.Machine.Instructions
135 build-depends:
136 base >=4.10 && <5,
137 array,
138 bytestring,
139 containers,
140 ghc-prim,
141 hashable,
142 template-haskell >= 2.16,
143 text,
144 transformers,
145 unordered-containers
146
147 test-suite symantic-parser-test
148 import: boilerplate
149 type: exitcode-stdio-1.0
150 hs-source-dirs: test
151 main-is: Main.hs
152 other-modules:
153 Golden
154 Golden.Grammar
155 -- Golden.Utils
156 -- Golden.Parsers
157 -- HUnit
158 -- QuickCheck
159 default-extensions:
160 ViewPatterns
161 ghc-options:
162 build-depends:
163 symantic-parser,
164 base >= 4.10 && < 5,
165 bytestring >= 0.10,
166 containers >= 0.5,
167 deepseq >= 1.4,
168 directory >= 1.3,
169 filepath >= 1.4,
170 hashable >= 1.2.6,
171 process >= 1.6,
172 strict >= 0.4,
173 tasty >= 0.11,
174 tasty-golden >= 2.3,
175 -- tasty-hunit,
176 template-haskell >= 2.16,
177 -- temporary >= 1.3,
178 text >= 1.2,
179 -- time >= 1.9,
180 transformers >= 0.4,
181 -- QuickCheck >= 2.0,
182 -- tasty-quickcheck,
183 unix >= 2.7,
184 unordered-containers
185 if flag(dump-core)
186 build-depends: dump-core
187 ghc-options: -fplugin=DumpCore
188 if flag(dump-splice)
189 ghc-options:
190 -ddump-splices
191 -ddump-to-file