diff options
Diffstat (limited to 'doc/0/1-parse.md')
| -rw-r--r-- | doc/0/1-parse.md | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/doc/0/1-parse.md b/doc/0/1-parse.md index 4943f1a..15b016c 100644 --- a/doc/0/1-parse.md +++ b/doc/0/1-parse.md @@ -2,7 +2,7 @@ <!--TOC--> -Zisp s-expressions represent an extremely minimal set of data types; only that +Xisp s-expressions represent an extremely minimal set of data types; only that which is necessary to strategically construct more complex values: +--------+---------+--------+ @@ -13,7 +13,7 @@ which is necessary to strategically construct more complex values: The parser recognizes various *syntax sugar* which abbreviates verbose syntax, and may result in special data structures (typically, a list with a rune in its -first position) which another Zisp component called the *decoder* can transform +first position) which another Xisp component called the *decoder* can transform into a rich set of value types. More details about syntax sugar, and the decoder, are explained later. @@ -32,11 +32,11 @@ valid UTF-8 text. This way, quoted strings and comments may contain Unicode text encoded in UTF-8, but the parser does not check these for validity. Since comments and quoted strings may contain arbitrary byte sequences, a text -editor or other program displaying Zisp s-expressions may need to use a special +editor or other program displaying Xisp s-expressions may need to use a special visual representation for bytes that don't represent valid text. The parser working on bytes rather than Unicode characters is not a limitation, -but rather a feature: It allows Zisp s-expressions to be used as a structured +but rather a feature: It allows Xisp s-expressions to be used as a structured data exchange format, which may contain binary data elements, without the need to encode these in Base64 or other such text representations of binary data. Consider the example: @@ -56,9 +56,9 @@ within. This does not require "unreading" or back-seeking within the stream; the parser always reads a full datum, and stops after some byte which cleanly terminates the currently parsed datum. -This means Zisp s-expressions can be safely intermixed with other data within +This means Xisp s-expressions can be safely intermixed with other data within the same byte stream. So long as the other data is consumed by some parser -which similarly stops reading at a clear boundary, the Zisp parser can then +which similarly stops reading at a clear boundary, the Xisp parser can then continue operating on the same stream. Consider the example: ("image.webp" 8273) @@ -69,7 +69,7 @@ continue operating on the same stream. Consider the example: << 736 bytes >> -The "header" for each file in this stream is a Zisp s-expression containing +The "header" for each file in this stream is a Xisp s-expression containing information about how many bytes should be read after the header, before the next file header appears. (The header data need to be terminated with a blank ASCII character such as a newline; the closing parenthesis does not act as a @@ -98,7 +98,7 @@ Two types of comment are supported: datum comments and line comments. ## Value vs. Datum -A Zisp *value* that has an *external representation* in the form of a sequence +A Xisp *value* that has an *external representation* in the form of a sequence of bytes is called a *datum*. Every datum is a value, but not every value is a datum. In other words, a datum is a value that can be printed out as a byte sequence which the parser can turn back into an equivalent datum. @@ -132,14 +132,14 @@ it contains a space character. Those familiar with Lisp and Scheme may expect bare strings to be parsed into a separate type called *symbol* while quoted strings are parsed directly into a -string type, but this is not the case in Zisp. +string type, but this is not the case in Xisp. ### Decoder -The *decoder* transforms Zisp data into values of more complex types, including +The *decoder* transforms Xisp data into values of more complex types, including values that are not of a datum type. -Combined with syntax sugar, this allows Zisp to offer familiar syntax elements. +Combined with syntax sugar, this allows Xisp to offer familiar syntax elements. For example, the expression `#(x y z)` which parses into `(#HASH x y z)` can be decoded into an array, so the result is similar to the vector syntax of Scheme. @@ -153,10 +153,10 @@ See the dedicated documentation of the [decoder](2-decode.html) for more. ## Data types Following is a more in-depth explanation of each data type constructed by the -Zisp s-expression parser. +Xisp s-expression parser. These are in fact value types, though the term "data type" is often used due to -familiarity. A Zisp value that is a member of one of the following value types +familiarity. A Xisp value that is a member of one of the following value types is only a *datum* if it adheres to additional constraints as explained below. ### List @@ -204,7 +204,7 @@ see the [grammar](grammar/). | @<S>bytes<S> | (#ATSTR <S> <STRING>) | +---------------+------------------------+ -The visual token `<STRING>` denotes the actual string, as a Zisp value. The +The visual token `<STRING>` denotes the actual string, as a Xisp value. The meaning of the visual tokens `<N>` and `<S>` will be explained later, in the section about at-quoted strings. Other details, including backslash escapes allowed in pipe-quoted and double-quoted strings, are also explained later. @@ -226,13 +226,13 @@ begin with a letter, and may only contain letters and digits. This character sequence of letters and digits is called the *name* of the rune. A rune that follows this constraint is valid as a datum. -Zisp code may explicitly construct values of the rune type that violate the +Xisp code may explicitly construct values of the rune type that violate the above constraints. Such runes are not valid data and cannot be printed or parsed. Runes are case-sensitive, and the parser always emits runes using upper-case letters when expressing syntax sugar. Uppercase rune names are reserved for -Zisp's internal use and standard library; users can use lowercase runes with +Xisp's internal use and standard library; users can use lowercase runes with custom meaning without worrying about clashes, with the exception of a small number of lowercase runes such as `#true` and `#false` that are part of the default decoder settings and documented explicitly as such. @@ -242,7 +242,7 @@ Runes are always stored directly in a CPU word; never by memory address. ## String interning -Departing from Lisp tradition, Zisp doesn't use a separate *symbol* data type. +Departing from Lisp tradition, Xisp doesn't use a separate *symbol* data type. Instead, when the parser is configured for code input, it enables *interning* for all strings up to 255 bytes in length. @@ -332,7 +332,7 @@ Example sequence of bytes, represented as a mixture of ASCII and raw integers: '@' 255 0 0 0 0 2 100 <612 bytes> -> (#ATSTR <STRING>) One may ask why the length is not included in the list. This is unnecessary, -since strings in Zisp carry their own length information anyway. +since strings in Xisp carry their own length information anyway. ### Backslash escapes @@ -464,7 +464,7 @@ Thus, we can do the following: (Dots represent whitespace that is deleted. The initial newline is, as well.) -The only feature Zisp does not offer is a way to fence off multi-line strings +The only feature Xisp does not offer is a way to fence off multi-line strings with a longer token such as `"""` as seen in Python and Java, or an arbitrary word as seen in Bourne shell and PHP "here doc" syntax. @@ -573,7 +573,7 @@ For clarity, concrete examples follow: | #%1234abcd% | (#LABEL <0x1234abcd>) | +-------------------+------------------------------+ -Here, the visual token `<0x1234abcd>` stands for a Zisp value of a numeric type +Here, the visual token `<0x1234abcd>` stands for a Xisp value of a numeric type with an integer value. ### Shebang @@ -585,7 +585,7 @@ hold the string values found within: #!interpreter argline -> (#SHBANG interpreter argline) -When executing a script file, Zisp simply stores this into a global value that +When executing a script file, Xisp simply stores this into a global value that may be inspected if desired. |
