gdritter repos s-cargot / 8e9f063
Beginnings of readme Getty Ritter 9 years ago
1 changed file(s) with 40 addition(s) and 0 deletion(s). Collapse all Expand all
1 S-Cargot is a library for parsing and emitting S-expressions, designed
2 to be flexible, customizable, and extensible. Different uses of
3 S-expressions often understand subtly different variations on what an
4 S-expression is. The goal of S-Cargot is to create as many reusable
5 components that can be repurposed to nearly any S-expression variant.
6
7 Additionally, S-Cargot uses these to include out-of-the-box parsing and
8 processing for several existing variations on S-expressions, including
9 Common Lisp (**in progresss**), Scheme (**in progress**), the
10 [Rivest internet-draft](http://people.csail.mit.edu/rivest/Sexp.txt)
11 (**in progress**), and Clojure (**in progress**).
12
13 The central way of interacting with the S-Cargot library is by creating
14 and modifying a _spec_, which is a value that represents a given
15 family of S-expressions. A _spec_, which is of type `SExprSpec`,
16 contains the information necessary to implement reader macros, arbitrary
17 kinds of comments, and various processing steps. A `SExprSpec` has two
18 type parameters:
19
20 ~~~~
21 +------ the type that represents a SExpr atom
22 |
23 | +- the Haskell representation of the SExpr value
24 | |
25 someSpec :: SExprSpec atom carrier
26 ~~~~
27
28 There are three built-in representations of S-expression lists: two of them
29 are isomorphic, as one or the other might be better for processing
30 S-expression data, and the third represents only a subset of possible
31 S-expressions.
32
33 ~~~~
34 -- cons-based representation
35 data SExpr atom = SAtom atom | SCons (SExpr atom) (SExpr atom) | SNil
36
37 -- list-based representation
38 data RichSExpr atom
39 = RSList [RichSExpr atom]
40 ~~~~