-
Notifications
You must be signed in to change notification settings - Fork 2
/
TotalParserCombinators.agda
115 lines (70 loc) · 3.21 KB
/
TotalParserCombinators.agda
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
------------------------------------------------------------------------
-- A total parser combinator library
--
-- Nils Anders Danielsson
------------------------------------------------------------------------
module TotalParserCombinators where
-- Check out TotalRecognisers for an introduction to the ideas used
-- below in the simplified setting of recognisers (as opposed to
-- parsers).
import TotalRecognisers
-- The parser type, and its semantics.
import TotalParserCombinators.Parser
import TotalParserCombinators.Semantics
-- Forcing of parsers (can be used for inspection/debugging purposes).
import TotalParserCombinators.Force
-- Some lemmas about initial bags.
import TotalParserCombinators.InitialBag
-- A small library of derived parser combinators.
import TotalParserCombinators.Lib
-- A Brzozowski derivative operator for parsers.
import TotalParserCombinators.Derivative
-- A breadth-first backend, based on the derivative operator.
import TotalParserCombinators.BreadthFirst
-- An alternative, coinductive definition of equality (and related
-- orderings) between parsers.
import TotalParserCombinators.CoinductiveEquality
-- Language equivalence and parser equivalence are both congruences.
-- The various orderings are compatible preorders.
import TotalParserCombinators.Congruence
import TotalParserCombinators.Congruence.Sound
-- However, it is possible to construct combinators which do not
-- preserve equality.
import TotalParserCombinators.NotACongruence
-- Proofs of various laws, for instance the monad laws.
import TotalParserCombinators.Laws
-- A proof showing that all functions of type List Bool → List R can
-- be realised using parser combinators (for any R, assuming that bag
-- equality is used for the lists of results).
import TotalParserCombinators.ExpressiveStrength
-- Definitions of asymmetric choice, and and not. Note that no
-- extension of the library is required to define these combinators,
-- which make use of a general operator which lifts initial bag
-- operations to parsers. This operator is defined using the
-- breadth-first backend's derivative operator.
import TotalParserCombinators.Pointwise
import TotalParserCombinators.AsymmetricChoice
import TotalParserCombinators.And
import TotalParserCombinators.Not
-- A lookahead operator cannot be defined.
import TotalParserCombinators.NoLookahead
-- An alternative semantics.
import TotalParserCombinators.Semantics.Continuation
-- Simplification of parsers.
import TotalParserCombinators.Simplification
-- Definition of unambiguity.
import TotalParserCombinators.Unambiguity
-- An example: a left recursive expression grammar.
import TotalParserCombinators.Examples.Expression
-- Recognisers defined on top of the parsers, and a variant of the
-- left recursive expression grammar mentioned above.
import TotalParserCombinators.Recogniser
import TotalParserCombinators.Recogniser.Expression
-- Another example: parsing PBM image files.
import TotalParserCombinators.Examples.PBM
-- An extended example: mixfix operator parsing.
import Mixfix
-- For code related to the paper "Structurally Recursive Descent
-- Parsing", developed together with Ulf Norell, see the following
-- module:
import StructurallyRecursiveDescentParsing