(zettel (meta (back "00001012051200 00001012051400 00001012053200 00001012053300 00001012053400 00001012054200 00001012921000 00001012930000 00001012931800") (backward "00001012051200 00001012051400 00001012053200 00001012053300 00001012053400 00001012054200 00001012921000 00001012930000 00001012931800") (box-number "1") (created "20230403151127") (modified "20240413160345") (published "20240413160345") (role "manual") (syntax "zmk") (tags "#manual #reference #zettelstore") (title "Syntax of Symbolic Expressions")) (rights 4) (encoding "") (content "=== Syntax of lists\nA list always starts with the left parenthesis (\"\"''(''\"\", U+0028) and ends with a right parenthesis (\"\"'')''\"\", U+0029).\nA list may contain a possibly empty sequence of elements, i.e. lists and / or atoms.\n\nInternally, lists are composed of __cells__.\nA cell allows to store two values.\nThe first value references the first element of a list.\nThe second value references the rest of the list, or is the special value __nil__ if there is no rest of the list.\n\nHowever, it is possible to store an atom as the second value of the last cell.\nIn this case, before the last element of a list of at least two elements, a full stop character (\"\"''.''\"\", U+002E) signals such a cell as the last two elements.\nThis allows a more space economic storage of data.\n\nA __proper__ list, which contains __nil__ as the second value of the last element might be pictured as follows:\n\n~~~draw\n+---+---+ +---+---+ +---+---+\n| V | N +-->| V | N +--> -->| V | |\n+-+-+---+ +-+-+---+ +-+-+---+\n | | |\n v v v\n+-------+ +-------+ +-------+\n| Elem1 | | Elem2 | | ElemN |\n+-------+ +-------+ +-------+\n~~~\n\n''V'' is a placeholder for a value, ''N'' is the reference to the next cell (also known as the rest / tail of the list).\nAbove list will be represented as an symbolic expression as ''(Elem1 Elem2 ... ElemN)''\n\nAn improper list will have a non-__nil__ reference to an atom as the very last element\n\n~~~draw\n+---+---+ +---+---+ +---+---+\n| V | N +-->| V | N +--> -->| V | V |\n+-+-+---+ +-+-+---+ +-+-+-+-+\n | | | |\n v v v v\n+-------+ +-------+ +-------+ +------+\n| Elem1 | | Elem2 | | ElemN | | Atom |\n+-------+ +-------+ +-------+ +------+\n~~~\n\nAbove improper list will be represented as an symbolic expression as ''(Elem1 Elem2 ... ElemN . Atom)''\n\n\n=== Syntax of numbers (atom)\nA number is a non-empty sequence of digits (\"\"0\"\" ... \"\"9\"\").\nThe smallest number is ``0``, there are no negative numbers.\n\n=== Syntax of symbols (atom)\nA symbol is a non-empty sequence of printable characters, except left or right parenthesis.\nUnicode characters of the following categories contains printable characters in the above sense: letter (L), number (N), punctuation (P), symbol (S).\nSymbols are case-sensitive, i.e. \"\"''ZETTEL''\"\" and \"\"''zettel''\"\" denote different symbols.\n\n=== Syntax of string (atom)\n\nA string starts with a quotation mark (\"\"''\"''\"\", U+0022), contains a possibly empty sequence of Unicode characters, and ends with a quotation mark.\nTo allow a string to contain a quotations mark, it must be prefixed by one backslash (\"\"''\\\\''\"\", U+005C).\nTo allow a string to contain a backslash, it also must be prefixed by one backslash.\nUnicode characters with a code less than U+FF are encoded by by the sequence \"\"''\\\\xNM''\"\", where ''NM'' is the hex encoding of the character.\nUnicode characters with a code less than U+FFFF are encoded by by the sequence \"\"''\\\\uNMOP''\"\", where ''NMOP'' is the hex encoding of the character.\nUnicode characters with a code less than U+FFFFFF are encoded by by the sequence \"\"''\\\\UNMOPQR''\"\", where ''NMOPQR'' is the hex encoding of the character.\nIn addition, the sequence \"\"''\\\\t''\"\" encodes a horizontal tab (U+0009), the sequence \"\"''\\\\n''\"\" encodes a line feed (U+000A).\n\n=== See also\n* Currently, Zettelstore uses [[Sx|https://t73f.de/r/sx]] (\"\"Symbolic eXpression framework\"\") to implement symbolic expressions.\n The project page might contain additional information about the full syntax.\n\n Zettelstore only uses lists, numbers, string, and symbols to represent zettel."))