![]() |
4 weeks ago | |
---|---|---|
.gitignore | 4 months ago | |
LICENSE.txt | 4 months ago | |
README.md | 1 month ago | |
eval.go | 4 weeks ago | |
eval_test.go | 4 weeks ago | |
form.go | 1 month ago | |
go.mod | 1 month ago | |
lookup.go | 4 weeks ago | |
lookup_test.go | 1 month ago | |
number.go | 1 month ago | |
pair.go | 1 month ago | |
pair_test.go | 1 month ago | |
parser.go | 1 month ago | |
parser_test.go | 1 month ago | |
scanner.go | 1 month ago | |
scanner_test.go | 1 month ago | |
sexpr.go | 1 month ago | |
sexpr_test.go | 1 month ago | |
string.go | 1 month ago | |
symbol.go | 1 month ago |
README.md
sxpf - S-Expression Framework
This is a framework to work with s-expressions.
In contrast to some other implementations, there are three types of atoms:
numbers, symbols and strings. Symbols are case-insensitive. A string may
contain any sequence of unicode characters, using UTF-8 encoding. A number
is a sequence of digits. An expression of the form ()
, (A)
, (A B)
, ...,
is a pair list, where A and B are s-expressions. If it has the form (A . B)
it is a pair.
The framework contains types, functions, and methods to create s-expressions, to encode them as a string, and to evaluate them. Evaluation creates a third atom type, which currently cannot be encoded fully in a s-expression: forms (aka functions). Forms can be special. In this case their arguments are not evaluated before calling the form.
Syntax
;
starts a comment that lasts until end of line- String =
"CHAR*"
is a sequence of characters, delimited by quotes- CHAR = any unicode character except from category C ("control") or an escaped character (ECHAR).
- ECHAR a character sequence that starts with a backspace ```
\t
= tabulator (code 9)\n
= new line (code 10)\r
= carriage return (code 13)\xMN
= character with code MN (hex digits)\uMNOP
= character with code MNOP (hex digits)\UMNOPQR
= character with code MNOPQR (hex digits)- any other character, excapt category C = the character itself, e.g.
\\
= backslash,\"
= quote.
- Symbol = a sequence of characters, except category C and Z ("separator"),
and except
"
,(
,)
,[
,]
,;
,.
. - Number = a sequence of digits (
0
..9
). - Pair =
(
Z* (s-expression (Z* s-sexpression)* (Z*.
Z* s-expression)?)? Z*)
- Z = any unicode of category Z
Note
- Cyclic structures are currently not supported. Creating them will likely lead to a stack overflow when working with them.
Usage
- Zettelstore and its client library use this framework for transferring data and to help encoding some other data formats.
- My students will use it for various lectures / seminars.