~subsetpark/pantagruel-web

ref: 730d2e3f3a58dc0232af35609680b3cf9a3a30d1 pantagruel-web/index.pant -rw-r--r-- 1.2 KiB
730d2e3f — Zach Smith Add blog post 4 months ago
                                                                                
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
Thought.
Specification <= [String].

// Pantagruel is a language for writing *system specifications*.

pantagruel thoughts: [Thought] => Specification.
---

// It's a computer language, but not as you might think of it.

// The effects of evaluating a specification are *nil*---Pantagruel has no semantics.

eval spec = Nil.

;

eval spec: Specification.
check spec: Specification => Bool.
---

// However, Pantagruel specifications can be checked to ensure that certain conditions have been met.

// For instance, that you've defined all your terms by the end of your document.
check spec = all symbol: invoked_symbols spec =>
        symbol in (head spec) -> bound_as_of? symbol (first_appearance symbol)
        symbol in (body spec) -> bound_as_of? symbol (next_chapter (first_appearance symbol)).

;

(Head, Body) <= [String].
Chapter <= [Head, Body].
Specification <= [Chapter].

// This allows a structured form of description where terms can be explained in gradually greater detail.

invoked_symbols <= {String}.
chapter head: Head, body: Body => Chapter.
first_appearance symbol: String => Nat.
bound_as_of? symbol: String, Nat => Bool.

next_chapter n: Nat => Nat.
---

invoked_symbols spec = {all s: String => s in spec}.