Fork 0
Little S-Expression Framework
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2.2 KiB

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.


  • ; 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


  • Cyclic structures are currently not supported. Creating them will likely lead to a stack overflow when working with them.


  • 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.