diff options
Diffstat (limited to 'docs/reference')
| -rw-r--r-- | docs/reference/01_syntax.md | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/docs/reference/01_syntax.md b/docs/reference/01_syntax.md index 445725c..4db70f9 100644 --- a/docs/reference/01_syntax.md +++ b/docs/reference/01_syntax.md @@ -71,10 +71,41 @@ immediately after the opening parenthesis. Whitespace between the opening parenthesis and the first subexpression or the closing parenthesis and the last subexpression is optional. +The first subexpression is considered the head of the cell and determines the +behaviour of the cell. + ## tags Tags consist of one or more digits (`0`-`9`) enclosed in square brackets (`[` and `]`). `[1]` and `[255]` are examples of valid tags. +## template strings +Template Strings are a different syntax for cells that allows embedding alv +expressions inside of a string literal. They can be used to perform string +substitution, especially within code of other languages. + +Template strings start with the character `$` followed by an optional tag and +a symbol that functions as the head of the cell and finally a `"`-delimited +string literal. Within the string literal, a `$` character begins an +interpolation expression unless escaped by a single preceding blackslash. + +The following are example template strings: + + $empty"" + $hello"world" + $fmt"three is $3 and four is $"four"" + $[99]fmt"five is $(+ 3 2)" + $fmt"there is \$no substitution here" + +Template strings are syntactic sugar that transforms into an array of string +pieces and the values to substitute, the following cell expressions are +semantically identical to the previous examples respectively: + + (empty [""]) + (hello ["world"]) + (fmt ["three is " " and four is " ""] 3 "four") + ([99]fmt ["five is" ""] (+ 3 2)) + (fmt ["there is $no substitution here"]) + # whitespace The space, tab, newline, and line-feed special characters constitute whitespace and may be repeated any number of times to form a chunk. A chunk of whitespace |
