aboutsummaryrefslogtreecommitdiff
path: root/README.md
blob: 0f030a8eeadffd63136bf2ee58fd426f8b737413 (plain)
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
# About chains

Chains is a Lisp inspired programming language designed to serve as a
preprocessor replacement. Just as Lisp stands for List Processing, Chains is in
a sense Tree Processing. It was originaly designed with the generation of HTML
in mind, but it does not restrict itself to this task.

The result of evaluating a program is a tree, which may then be used to generate
other markup languages. However, chains is not a macro language like the
C preprocessor or m4.

One of the issues of generating markup text from within a conventional
programming language is how cumbersome this is. Due to the syntax rules of the
language, the markup must be in a way escaped e.g. by writing a string between
quotes. Meanwhile unquoted items are syntactic elements of the language. This
way writing code is "easy" while writing markup is "cumbersome".

In Chains, text is a first class citizen and all other syntactic elements have
to be escaped. Because of this, you probably won't want to write Chains code
directly but instead define it inside of the interpreter. On the other hand,
writing markup is as easy as writing markdown or TeX.

The language also has a built-in notion of paragraph

At the moment, chains is more a proof of concept rather than a complete
language. Many features are still undecided.

# Syntax

| Character | Description                                                             |
|-----------|-------------------------------------------------------------------------|
| %         |                                                                         |
| \\        |                                                                         |
| { }       |                                                                         |
| \[ \]     |                                                                         |
| #         | Raw function. All special characters in the arguments are taken literal |
| @         |                                                                         |
| $         |                                                                         |

## Primitives
Chains is built on 3 type of objects: text, chains and atoms.

## Evaluation rules

Unless a chain is escaped, the following rules apply. The chain to be evaluated
may only have a single object inside the first link. The function is value of
evaluating this first element.

Text evaluates to itself.

Atoms consists of symbols or numbers. Symbols evaluate to the bound value in the
environment. Numbers evaluate to themselves.

# How to contribute

If you would like to contibute to the development of chains please send a mail
with your patch to the following address: thomas _at_ thomaslabs _dot_ org

# Misc

;; next-token : cache raw block for further reads. avoid creating list (1 pass)
;; build link directly instead of returning block start tokens

;; read link
;; {} link := list of objects
;; { }{ }{ } chain := list of links
;;

;; special form : does not get its arguments pre-evaluated

;; after eval, unevaluated links are spliced into tree
;; {@if}{{@=}{2}{2}}{1}{2} -> {1} ;; needs to return link, in case text is also inside
;; @if{@={@2}{@2}}{1}{2} ;; alias syntax


;; use chains as library for static website generator, define-syntax and define
;; to define "callbacks" from library and read/eval file

;; tree from file may be discarded ;; writing libraries

;; a chain is evaluated by first evaluating the first link and applying the
;; other links as arguments for the function

;; a link with one element is evaluated to that element

;; inside the evaluation of a lambda, the argument is spliced into the link of
;; the body

;; {{@lambda}{@x @y}{@x}}{Hello}{World} -> {{Hello}} -> {Hello} -> Hello

;; Metaprogramming is hard :(

;; make closure return links instead of plain lists? dont use flatten?

;; type 1 - {{@lambda}{{@x}{@y}}{@x}}{Hello}{World}
;; type 2 - {{@lambda}{@x @y}{@x}}{Hello}{World}

;; semantically. What exactly is a chain?