aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/README.md1
-rw-r--r--doc/arithmetic.md2
-rw-r--r--doc/arrayrepr.md4
-rw-r--r--doc/expression.md2
-rw-r--r--doc/glossary.md6
-rw-r--r--doc/syntax.md47
-rw-r--r--doc/token.md55
-rw-r--r--docs/doc/arithmetic.html2
-rw-r--r--docs/doc/arrayrepr.html4
-rw-r--r--docs/doc/expression.html2
-rw-r--r--docs/doc/glossary.html6
-rw-r--r--docs/doc/index.html3
-rw-r--r--docs/doc/syntax.html47
-rw-r--r--docs/doc/token.html41
-rw-r--r--docs/help/character.html2
-rw-r--r--docs/help/comment.html2
-rw-r--r--docs/help/infinity.html2
-rw-r--r--docs/help/minus.html2
-rw-r--r--docs/help/nullcharacter.html2
-rw-r--r--docs/help/pi.html2
-rw-r--r--docs/help/separator.html2
-rw-r--r--docs/help/string.html2
-rw-r--r--help/character.md2
-rw-r--r--help/comment.md2
-rw-r--r--help/infinity.md2
-rw-r--r--help/minus.md2
-rw-r--r--help/nullcharacter.md2
-rw-r--r--help/pi.md2
-rw-r--r--help/separator.md2
-rw-r--r--help/string.md2
-rw-r--r--md.bqn4
31 files changed, 166 insertions, 92 deletions
diff --git a/doc/README.md b/doc/README.md
index 7d0a1fd4..f0c5ae18 100644
--- a/doc/README.md
+++ b/doc/README.md
@@ -19,6 +19,7 @@ References:
- [BQN as combinatory logic](birds.md)
Concepts:
+- [Tokens and constants](token.md)
- [Expression syntax](expression.md)
- [Context-free grammar](context.md)
- [Arrays](array.md)
diff --git a/doc/arithmetic.md b/doc/arithmetic.md
index e51fc53e..bd61ed0e 100644
--- a/doc/arithmetic.md
+++ b/doc/arithmetic.md
@@ -49,7 +49,7 @@ Each of these functions also has a meaning with only one argument, although math
√ 0‿1‿2‿4
-Take note of the difference between the function `-`, and the "high minus" character `¯`, which is a part of [numeric notation](syntax.md#constants). Also shown is the number `∞`, which BQN supports along with `¯∞` (but depending on implementation BQN may or may not keep track of `¯0`. Integer optimization loses the distinction so it's best not to rely on it).
+Take note of the difference between the function `-`, and the "high minus" character `¯`, which is a part of [numeric notation](token.md#numbers). Also shown is the number `∞`, which BQN supports along with `¯∞` (but depending on implementation BQN may or may not keep track of `¯0`. Integer optimization loses the distinction so it's best not to rely on it).
The logarithm is written with [Undo](undo.md): `⋆⁼`. As with Power, the default base is *e*, giving a natural logarithm.
diff --git a/doc/arrayrepr.md b/doc/arrayrepr.md
index 205c4a44..63dba983 100644
--- a/doc/arrayrepr.md
+++ b/doc/arrayrepr.md
@@ -92,7 +92,7 @@ Now it's time to discuss ways to write arrays in a BQN program. There are three
### Strings
-A **string** consists of a sequence of characters surrounded by double quotes `""`. The only rule for the characters inside is that any double quote must be escaped by repeating it twice; otherwise the string ends at that point.
+A [**string** literal](token.md#characters-and-strings) consists of a sequence of characters surrounded by double quotes `""`. The only rule for the characters inside is that any double quote must be escaped by repeating it twice; otherwise the string ends at that point.
"-'×%""*"
@@ -102,7 +102,7 @@ Even special characters like a newline can appear in a string literal, so that s
### Brackets
-**List notation** uses angle brackets `⟨⟩`. The contents are structurally identical to those of a [block](block.md), that is, a list of expressions [separated](syntax.md#separators) by `,` or `⋄` or newlines. Unlike a block, a list doesn't need to have any expressions: `⟨⟩` or `⟨⋄⟩` or `⟨,,⋄,⟩` will create an empty list. Other differences are that a list doesn't introduce a new [scope](lexical.md) and all of the expressions have to result in a value, not [Nothing](expression.md#nothing) (`·`).
+**List notation** uses angle brackets `⟨⟩`. The contents are structurally identical to those of a [block](block.md), that is, a list of expressions [separated](token.md#separators) by `,` or `⋄` or newlines. Unlike a block, a list doesn't need to have any expressions: `⟨⟩` or `⟨⋄⟩` or `⟨,,⋄,⟩` will create an empty list. Other differences are that a list doesn't introduce a new [scope](lexical.md) and all of the expressions have to result in a value, not [Nothing](expression.md#nothing) (`·`).
Entries in a list are evaluated in source order, and the value will be the list of those results. The list has a subject [role](expression.md#syntactic-role), even if it contains expressions with other roles. Any value can be an element.
diff --git a/doc/expression.md b/doc/expression.md
index 5fa6cdc7..5359a672 100644
--- a/doc/expression.md
+++ b/doc/expression.md
@@ -2,7 +2,7 @@
# Expression syntax
-BQN expressions are the part of [syntax](syntax.md) that describes computations to perform. Programs are mainly made up of expressions with a little organizing material like [blocks](block.md) and [namespaces](namespace.md) around them. This page explains how functions, modifiers, and assignment combine with their inputs. It doesn't describe [constant](syntax.md#constants) and [array](arrayrepr.md#array-literals) literals, which each form a single subject for grammatical purposes.
+BQN expressions are the part of [syntax](syntax.md) that describes computations to perform. Programs are mainly made up of expressions with a little organizing material like [blocks](block.md) and [namespaces](namespace.md) around them. This page explains how functions, modifiers, and assignment combine with their inputs. It doesn't describe [constant](token.md) and [array](arrayrepr.md#array-literals) literals, which each form a single subject for grammatical purposes.
The [first tutorial](../tutorial/expression.md) also covers how to build and read BQN expressions.
diff --git a/doc/glossary.md b/doc/glossary.md
index cd68e6c9..cd5b1853 100644
--- a/doc/glossary.md
+++ b/doc/glossary.md
@@ -89,10 +89,10 @@ BQN uses standard terminology for particular sets of numbers, with natural numbe
* [**Primitive**](primitive.md): One of several fixed operations defined by the language, denoted by a single-character token.
* **Word**: A sequence of alphabetic or numeric characters.
* **Name**: A word that starts with an alphabetic character. Names are compared case-insensitively and ignoring underscores `_`.
-* [**Numeric literal**](syntax.md#constants): A word that starts with a numeric character, indicating a number.
+* [**Numeric literal**](token.md#numbers): A word that starts with a numeric character, indicating a number.
* [**String literal**](arrayrepr.md#strings): A literal written with double quotes `""`, indicating a string.
-* [**Character literal**](syntax.md#constants): A literal written with single quotes `''`, indicating a string.
-* [**Null literal**](syntax.md#constants): The literal `@`, indicating the null character (code point 0).
+* [**Character literal**](token.md#characters-and-strings): A literal written with single quotes `''`, indicating a string.
+* [**Null literal**](token.md#characters-and-strings): The literal `@`, indicating the null character (code point 0).
## Grammar
diff --git a/doc/syntax.md b/doc/syntax.md
index da334d6d..86b88d3a 100644
--- a/doc/syntax.md
+++ b/doc/syntax.md
@@ -15,11 +15,11 @@ Here's a full table of precedence for BQN's glyphs (broader than "operator prece
| | [Stranding](#list-and-array-notation) | n-ary | `‿`
| | Modifier | Left-to-right | `∘⎉¨´`… | `↩` in `Fn↩`
| | Function | Right-to-left | `+↕⊔⍉`… | `←↩⇐`
-| | [Separator](#separators) | | `⋄,` and newline | `?`
+| | [Separator](token.md#separators) | | `⋄,` and newline | `?`
| | [Header](block.md#block-headers) | | `:`
| Low | [Body](block.md#multiple-bodies) | | `;`
-While all of BQN's grammar fits into this table somehow, it's not really the whole story because subexpressions including parentheses and blocks might behave like functions or modifiers.
+While all of BQN's grammar fits into this table somehow, it's not really the whole story because subexpressions including parentheses and blocks might behave like functions or modifiers. See [expressions](#expressions) and [blocks](#blocks).
## Special glyphs
@@ -27,17 +27,17 @@ The following glyphs are used for BQN syntax. [Primitives](primitive.md) (built-
Glyph(s) | Meaning
----------------|-----------
-`#` | [Comment](#comments)
-`'"` | [Character or string literal](#constants)
-`@` | [Null character](#constants)
-`¯∞π` | [Used in numeric literals](#constants)
+`#` | [Comment](token.md#comments)
+`'"` | [Character or string literal](token.md#characters-and-strings)
+`@` | [Null character](token.md#characters-and-strings)
+`¯∞π` | [Used in numeric literals](token.md#numbers)
`·` | [Nothing](expression.md#nothing)
`()` | [Expression grouping](expression.md#parentheses)
`←` | [Define](expression.md#assignment)
`⇐` | [Export](namespace.md#exports)
`↩` | [Change](expression.md#assignment)
`.` | Namespace [field access](namespace.md#imports)
-`⋄,` or newline | Statement or element [separator](#separators)
+`⋄,` or newline | Statement or element [separator](token.md#separators)
`⟨⟩` | [List](#list-and-array-notation)
`[]` | [Array](#list-and-array-notation)
`‿` | [Strand](#list-and-array-notation) (lightweight list syntax)
@@ -52,27 +52,16 @@ Glyph(s) | Meaning
`𝕘𝔾` | [Right operand of a 2-modifier](#blocks)
`𝕣` | [Modifier self-reference](#blocks)
-## Comments
+## Tokens
-A comment starts with a `#` that isn't part of a character or string literal, and continues to the end of the line.
+*[Full documentation](token.md)*
- '#' - 1 #This is the comment
-
-## Constants
-
-BQN has single-token notation for numbers, strings, and characters.
-
-[Numbers](types.md#numbers) are written as decimals, allowing `¯` for the negative sign (because `-` is a function) and `e` or `E` for scientific notation. They must have digits before and after the decimal point (so, `0.5` instead of `.5`), and any exponent must be an integer. Two special numbers `∞` and `π` are supported, possibly with a minus sign. If complex numbers are supported (no implementation to date has them), then they can be written with the components separated by `i` or `I`.
-
- ⟨ ¯π ⋄ 0.5 ⋄ 5e¯1 ⋄ 1.5E3 ⋄ ∞ ⟩ # A list of numbers
-
-Strings—lists of characters—are written with double quotes `""`, and [characters](types.md#characters) with single quotes `''` with a single character in between. Only one character ever needs to be escaped: a double quote in a string is written twice. So `""""` is a one-character string of `"`, and if two string literals are next to each other, they have to be separated by a space. Character literals don't have even one escape, as the length is already known. Other than the double quote, character and string literals can contain anything: newlines, null characters, or any other Unicode.
-
- ≠¨ ⟨ "str" ⋄ "s't""r" ⋄ 'c' ⋄ ''' ⋄ '"' ⟩ # "" is an escape
-
- ≡¨ ⟨ "a" ⋄ 'a' ⟩ # A string is an array but a character isn't
-
-But including a null character in your source code is probably not a great idea for other reasons. The null character (code point 0) has a dedicated literal representation `@`. Null can be used with [character arithmetic](arithmetic.md#character-arithmetic) to directly convert between characters and numeric code points, which among many other uses allows tricky characters to be entered by code point: for example, a non-breaking space is `@+160`.
+BQN syntax is made up of tokens, which are mostly single characters. But there are a few exceptions:
+- [Comments](token.md#comments) start with `#` and end at the end of the line.
+- [Character literals](token.md#characters-and-strings) start and end with `'`, and have exactly one character in between.
+- [String literals](token.md#characters-and-strings) start and end with `"`. Pairs of quotes `""` in between represent one quote character, and other characters (including `'`) represent themselves.
+- [Numbers](token.md#numbers) support decimal (`.`) and scientific (`e`) notation, plus `π` and `∞`, and use `¯` for a minus sign.
+- [Variable names](token.md#names) allow letters, underscores, and numeric characters. They're matched case-insensitively, with a [spelling system](expression.md#role-spellings) that determines role.
## Expressions
@@ -95,11 +84,7 @@ The double arrow `⇐` is used for functionality relating to [namespaces](namesp
## Arrays and blocks
-Arrays and code blocks can both be represented as sequences of expressions in source code. There are paired bracket representations, using `⟨⟩` for lists, `[]` for arrays, and `{}` for blocks, as well as a shortcut "stranding" notation using `‿` for lists.
-
-### Separators
-
-The characters `⋄` and `,` and newline are completely interchangeable and are used to separate expressions. An expression might be an element in a list or a line in a block. Empty sections—those that consist only of whitespace—are ignored. This means that any number of separators can be used between expressions, and that leading and trailing separators are also allowed. The expressions are evaluated in text order: left to right and top to bottom.
+Arrays and code blocks can both be represented as sequences of expressions in source code. There are paired bracket representations, using `⟨⟩` for lists, `[]` for arrays, and `{}` for blocks, as well as a shortcut "stranding" notation using `‿` for lists. Elements within brackets are divided by [separators](token.md#separators): `,` or `⋄` or a line break.
### List and array notation
diff --git a/doc/token.md b/doc/token.md
new file mode 100644
index 00000000..bfb02746
--- /dev/null
+++ b/doc/token.md
@@ -0,0 +1,55 @@
+*View this file with results and syntax highlighting [here](https://mlochbaum.github.io/BQN/doc/token.html).*
+
+# Tokens
+
+A "token" is the smallest part of syntax, much like a word in English. BQN's rules for forming tokens are simpler than most programming languages, because most of them are single characters. There are only a few kinds of multi-character tokens: character and string literals written with `'` and `"`, and words which are numbers, names, or system values.
+
+Strings (and characters) and comments have starting and ending conditions, but can't overlap. The first one that starts first "wins": it needs to end before any other token or comment can start. These also take precedence over other token rules, that is, characters inside a string or comment don't form other tokens.
+
+## Non-tokens
+
+Comments, and the horizontal whitespace characters space and tab, don't form tokens, since they don't do anything as far as the program's concerned. However, whitespace can be used to separate adjacent words or strings. Comments can only end with a newline, which doesn't need separating, so they _really_ don't do anything, other than inform the reader about whatever you have to say. Note that newline characters (either LF or CR) are [separators](#separators), which are tokens.
+
+### Comments
+
+A comment starts with a `#` that isn't part of a character or string literal, and continues to the end of the line.
+
+ '#' - 1 #This is the comment
+
+Every line of commentary needs its own `#`; there's no multi-line comment syntax.
+
+## Characters and strings
+
+Strings—lists of characters—are written with double quotes `""`, and [characters](types.md#characters) with single quotes `''` with a single character in between. Only one character ever needs to be escaped: a double quote in a string is written twice. So `""""` is a one-character string of `"`, and if two string literals are next to each other, they have to be separated by a space. Character literals don't have even one escape, as the length is already known. Other than the double quote, character and string literals can contain any character directly: newlines, null characters, or other Unicode.
+
+ ≠¨ ⟨ "str" ⋄ "s't""r" ⋄ 'c' ⋄ ''' ⋄ '"' ⟩ # "" is an escape
+
+ ≡¨ ⟨ "a" ⋄ 'a' ⟩ # A string is an array but a character isn't
+
+But including a null character in your source code is probably not a great idea for other reasons. The null character (code point 0) has a dedicated literal representation `@`. Null can be used with [character arithmetic](arithmetic.md#character-arithmetic) to directly convert between characters and numeric code points, which among many other uses allows tricky characters to be entered by code point: for example, a non-breaking space is `@+160`.
+
+## Words
+
+Numbers and variable names share a token formation rule, and are collectively called words. A word is a number if it starts with a digit or numeric character `¯∞π`, and a name otherwise.
+
+Words are formed from digits, letters, and the characters `_.¯∞π`. All these characters stick together, so that you need to separate words with whitespace in order to write them next to each other. But `.` only counts if it's followed by a digit: otherwise it forms its own token to support [namespace syntax](namespace.md#imports) `ns.field`. A word may be preceded by `•` to form a system name.
+
+The character `𝕣` also sticks with other word-forming characters, but is only allowed form the special names `𝕣`, `_𝕣`, and `_𝕣_`.
+
+### Numbers
+
+[Numbers](types.md#numbers) are written as decimals, allowing `¯` for the negative sign (because `-` is a function) and `e` or `E` for scientific notation. They must have digits before and after the decimal point (so, `0.5` instead of `.5`), and any exponent must be an integer. Two special numbers `∞` and `π` are supported, possibly with a minus sign. If complex numbers are supported (no implementation to date has them), then they can be written with the components separated by `i` or `I`.
+
+ ⟨ ¯π ⋄ 0.5 ⋄ 5e¯1 ⋄ 1.5E3 ⋄ ∞ ⟩ # A list of numbers
+
+### Names
+
+A variable name starts with a letter but otherwise can contain anything, including characters like `∞` and `¯`. Names represent identifiers according to the rules of [lexical scoping](lexical.md). A somewhat unusual feature of BQN is that identifiers are case- and underscore-insensitive, so that `abc` is treated as the same name as `_a_B_c`. This works with the [role spelling](expression.md#role-spellings) system so that changing the case or adding underscores allows the same variable to be used in different roles.
+
+The system dot `•` can only start a word, and must be followed by a name. This accesses a system value such as the debugging display function `•Show`.
+
+## Separators
+
+The characters `⋄` and `,` and newline are completely interchangeable and are used to separate expressions. An expression might be an element in a list or a line in a block. Empty sections—those that consist only of whitespace—are ignored. This means that any number of separators can be used between expressions, and that leading and trailing separators are also allowed. The expressions are evaluated in text order: left to right and top to bottom.
+
+Both LF and CR are allowed as newline characters, and CRLF functions as a separator too because of the way multiple separators work.
diff --git a/docs/doc/arithmetic.html b/docs/doc/arithmetic.html
index 9e511044..918bd9c5 100644
--- a/docs/doc/arithmetic.html
+++ b/docs/doc/arithmetic.html
@@ -96,7 +96,7 @@
<span class='Function'>√</span> <span class='Number'>0</span><span class='Ligature'>‿</span><span class='Number'>1</span><span class='Ligature'>‿</span><span class='Number'>2</span><span class='Ligature'>‿</span><span class='Number'>4</span>
⟨ 0 1 1.414213562373095 2 ⟩
</pre>
-<p>Take note of the difference between the function <code><span class='Function'>-</span></code>, and the &quot;high minus&quot; character <code><span class='Number'>¯</span></code>, which is a part of <a href="syntax.html#constants">numeric notation</a>. Also shown is the number <code><span class='Number'>∞</span></code>, which BQN supports along with <code><span class='Number'>¯∞</span></code> (but depending on implementation BQN may or may not keep track of <code><span class='Number'>¯0</span></code>. Integer optimization loses the distinction so it's best not to rely on it).</p>
+<p>Take note of the difference between the function <code><span class='Function'>-</span></code>, and the &quot;high minus&quot; character <code><span class='Number'>¯</span></code>, which is a part of <a href="token.html#numbers">numeric notation</a>. Also shown is the number <code><span class='Number'>∞</span></code>, which BQN supports along with <code><span class='Number'>¯∞</span></code> (but depending on implementation BQN may or may not keep track of <code><span class='Number'>¯0</span></code>. Integer optimization loses the distinction so it's best not to rely on it).</p>
<p>The logarithm is written with <a href="undo.html">Undo</a>: <code><span class='Function'>⋆</span><span class='Modifier'>⁼</span></code>. As with Power, the default base is <em>e</em>, giving a natural logarithm.</p>
<a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=4ouG4oG8IDEwCgoyIOKLhuKBvCAxMDI0">↗️</a><pre> <span class='Function'>⋆</span><span class='Modifier'>⁼</span> <span class='Number'>10</span>
2.302585092994046
diff --git a/docs/doc/arrayrepr.html b/docs/doc/arrayrepr.html
index 159bb8f7..5218009e 100644
--- a/docs/doc/arrayrepr.html
+++ b/docs/doc/arrayrepr.html
@@ -162,7 +162,7 @@
<p><em>The tutorial section <a href="../tutorial/list.html#list-notation">here</a> also covers this topic.</em></p>
<p>Now it's time to discuss ways to write arrays in a BQN program. There are three kinds literal notation for lists: strings, list notation, and stranding. Strings indicate character lists (with space for the <a href="fill.html">fill</a>) and the other two can combine any sequence of elements. Additionally, there's a square bracket notation that can form higher-rank arrays.</p>
<h3 id="strings"><a class="header" href="#strings">Strings</a></h3>
-<p>A <strong>string</strong> consists of a sequence of characters surrounded by double quotes <code><span class='String'>&quot;&quot;</span></code>. The only rule for the characters inside is that any double quote must be escaped by repeating it twice; otherwise the string ends at that point.</p>
+<p>A <a href="token.html#characters-and-strings"><strong>string</strong> literal</a> consists of a sequence of characters surrounded by double quotes <code><span class='String'>&quot;&quot;</span></code>. The only rule for the characters inside is that any double quote must be escaped by repeating it twice; otherwise the string ends at that point.</p>
<a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=Ii0nw5clIiIqIgoKIi0nw5clIioiICAjIEVzY2FwaW5nIGZhaWx1cmU=">↗️</a><pre> <span class='String'>&quot;-'×%&quot;&quot;*&quot;</span>
"-'×%""*"
@@ -171,7 +171,7 @@
</pre>
<p>Even special characters like a newline can appear in a string literal, so that string literals are automatically multi-line.</p>
<h3 id="brackets"><a class="header" href="#brackets">Brackets</a></h3>
-<p><strong>List notation</strong> uses angle brackets <code><span class='Bracket'>⟨⟩</span></code>. The contents are structurally identical to those of a <a href="block.html">block</a>, that is, a list of expressions <a href="syntax.html#separators">separated</a> by <code><span class='Separator'>,</span></code> or <code><span class='Separator'>⋄</span></code> or newlines. Unlike a block, a list doesn't need to have any expressions: <code><span class='Bracket'>⟨⟩</span></code> or <code><span class='Bracket'>⟨</span><span class='Separator'>⋄</span><span class='Bracket'>⟩</span></code> or <code><span class='Bracket'>⟨</span><span class='Separator'>,,⋄,</span><span class='Bracket'>⟩</span></code> will create an empty list. Other differences are that a list doesn't introduce a new <a href="lexical.html">scope</a> and all of the expressions have to result in a value, not <a href="expression.html#nothing">Nothing</a> (<code><span class='Nothing'>·</span></code>).</p>
+<p><strong>List notation</strong> uses angle brackets <code><span class='Bracket'>⟨⟩</span></code>. The contents are structurally identical to those of a <a href="block.html">block</a>, that is, a list of expressions <a href="token.html#separators">separated</a> by <code><span class='Separator'>,</span></code> or <code><span class='Separator'>⋄</span></code> or newlines. Unlike a block, a list doesn't need to have any expressions: <code><span class='Bracket'>⟨⟩</span></code> or <code><span class='Bracket'>⟨</span><span class='Separator'>⋄</span><span class='Bracket'>⟩</span></code> or <code><span class='Bracket'>⟨</span><span class='Separator'>,,⋄,</span><span class='Bracket'>⟩</span></code> will create an empty list. Other differences are that a list doesn't introduce a new <a href="lexical.html">scope</a> and all of the expressions have to result in a value, not <a href="expression.html#nothing">Nothing</a> (<code><span class='Nothing'>·</span></code>).</p>
<p>Entries in a list are evaluated in source order, and the value will be the list of those results. The list has a subject <a href="expression.html#syntactic-role">role</a>, even if it contains expressions with other roles. Any value can be an element.</p>
<a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=4p+oQCwg4o2Jy5gsIOKJjSJhYmMi4p+p">↗️</a><pre> <span class='Bracket'>⟨</span><span class='String'>@</span><span class='Separator'>,</span> <span class='Function'>⍉</span><span class='Modifier'>˘</span><span class='Separator'>,</span> <span class='Function'>≍</span><span class='String'>&quot;abc&quot;</span><span class='Bracket'>⟩</span>
┌─
diff --git a/docs/doc/expression.html b/docs/doc/expression.html
index 81f2a048..b8f9254c 100644
--- a/docs/doc/expression.html
+++ b/docs/doc/expression.html
@@ -5,7 +5,7 @@
</head>
<div class="nav">(<a href="https://github.com/mlochbaum/BQN">github</a>) / <a href="../index.html">BQN</a> / <a href="index.html">doc</a></div>
<h1 id="expression-syntax"><a class="header" href="#expression-syntax">Expression syntax</a></h1>
-<p>BQN expressions are the part of <a href="syntax.html">syntax</a> that describes computations to perform. Programs are mainly made up of expressions with a little organizing material like <a href="block.html">blocks</a> and <a href="namespace.html">namespaces</a> around them. This page explains how functions, modifiers, and assignment combine with their inputs. It doesn't describe <a href="syntax.html#constants">constant</a> and <a href="arrayrepr.html#array-literals">array</a> literals, which each form a single subject for grammatical purposes.</p>
+<p>BQN expressions are the part of <a href="syntax.html">syntax</a> that describes computations to perform. Programs are mainly made up of expressions with a little organizing material like <a href="block.html">blocks</a> and <a href="namespace.html">namespaces</a> around them. This page explains how functions, modifiers, and assignment combine with their inputs. It doesn't describe <a href="token.html">constant</a> and <a href="arrayrepr.html#array-literals">array</a> literals, which each form a single subject for grammatical purposes.</p>
<p>The <a href="../tutorial/expression.html">first tutorial</a> also covers how to build and read BQN expressions.</p>
<h2 id="overview"><a class="header" href="#overview">Overview</a></h2>
<p>BQN expressions consist of subjects, functions, and modifiers arranged in sequence, with parentheses to group parts into subexpressions. Assignment arrows <code><span class='Gets'>←</span></code> and <code><span class='Gets'>↩</span></code> can also be present and mostly act like functions. <a href="ops.html#functions">Functions</a> can be applied to subjects or grouped into <a href="train.html">trains</a>, while <a href="ops.html#modifiers">modifiers</a> can be applied to subjects or functions. The most important kinds of application are:</p>
diff --git a/docs/doc/glossary.html b/docs/doc/glossary.html
index 3588a8d8..daf3ec43 100644
--- a/docs/doc/glossary.html
+++ b/docs/doc/glossary.html
@@ -99,10 +99,10 @@
<li><a href="primitive.html"><strong>Primitive</strong></a>: One of several fixed operations defined by the language, denoted by a single-character token.</li>
<li><strong>Word</strong>: A sequence of alphabetic or numeric characters.</li>
<li><strong>Name</strong>: A word that starts with an alphabetic character. Names are compared case-insensitively and ignoring underscores <code><span class='Modifier2'>_</span></code>.</li>
-<li><a href="syntax.html#constants"><strong>Numeric literal</strong></a>: A word that starts with a numeric character, indicating a number.</li>
+<li><a href="token.html#numbers"><strong>Numeric literal</strong></a>: A word that starts with a numeric character, indicating a number.</li>
<li><a href="arrayrepr.html#strings"><strong>String literal</strong></a>: A literal written with double quotes <code><span class='String'>&quot;&quot;</span></code>, indicating a string.</li>
-<li><a href="syntax.html#constants"><strong>Character literal</strong></a>: A literal written with single quotes <code><span class='String'>''</span></code>, indicating a string.</li>
-<li><a href="syntax.html#constants"><strong>Null literal</strong></a>: The literal <code><span class='String'>@</span></code>, indicating the null character (code point 0).</li>
+<li><a href="token.html#characters-and-strings"><strong>Character literal</strong></a>: A literal written with single quotes <code><span class='String'>''</span></code>, indicating a string.</li>
+<li><a href="token.html#characters-and-strings"><strong>Null literal</strong></a>: The literal <code><span class='String'>@</span></code>, indicating the null character (code point 0).</li>
</ul>
<h2 id="grammar"><a class="header" href="#grammar">Grammar</a></h2>
<ul>
diff --git a/docs/doc/index.html b/docs/doc/index.html
index deded4be..4edd0d0e 100644
--- a/docs/doc/index.html
+++ b/docs/doc/index.html
@@ -24,6 +24,9 @@
</ul>
<p>Concepts:</p>
<ul>
+<li><a href="token.html">Tokens and constants</a>
+
+</li>
<li><a href="expression.html">Expression syntax</a>
<ul>
<li><a href="context.html">Context-free grammar</a></li>
diff --git a/docs/doc/syntax.html b/docs/doc/syntax.html
index 94bace3c..ef6c1804 100644
--- a/docs/doc/syntax.html
+++ b/docs/doc/syntax.html
@@ -56,7 +56,7 @@
</tr>
<tr>
<td></td>
-<td><a href="#separators">Separator</a></td>
+<td><a href="token.html#separators">Separator</a></td>
<td></td>
<td><code><span class='Separator'>⋄,</span></code> and newline</td>
<td><code><span class='Head'>?</span></code></td>
@@ -77,7 +77,7 @@
</tr>
</tbody>
</table>
-<p>While all of BQN's grammar fits into this table somehow, it's not really the whole story because subexpressions including parentheses and blocks might behave like functions or modifiers.</p>
+<p>While all of BQN's grammar fits into this table somehow, it's not really the whole story because subexpressions including parentheses and blocks might behave like functions or modifiers. See <a href="#expressions">expressions</a> and <a href="#blocks">blocks</a>.</p>
<h2 id="special-glyphs"><a class="header" href="#special-glyphs">Special glyphs</a></h2>
<p>The following glyphs are used for BQN syntax. <a href="primitive.html">Primitives</a> (built-in functions and modifiers) are not listed in this table, and have their own page. Digits, characters, and the underscore <code><span class='Modifier2'>_</span></code> are used for numbers and variable names.</p>
<table>
@@ -90,19 +90,19 @@
<tbody>
<tr>
<td><code><span class='Comment'>#</span></code></td>
-<td><a href="#comments">Comment</a></td>
+<td><a href="token.html#comments">Comment</a></td>
</tr>
<tr>
<td><code><span class='String'>'&quot;</span></code></td>
-<td><a href="#constants">Character or string literal</a></td>
+<td><a href="token.html#characters-and-strings">Character or string literal</a></td>
</tr>
<tr>
<td><code><span class='String'>@</span></code></td>
-<td><a href="#constants">Null character</a></td>
+<td><a href="token.html#characters-and-strings">Null character</a></td>
</tr>
<tr>
<td><code><span class='Number'>¯∞π</span></code></td>
-<td><a href="#constants">Used in numeric literals</a></td>
+<td><a href="token.html#numbers">Used in numeric literals</a></td>
</tr>
<tr>
<td><code><span class='Nothing'>·</span></code></td>
@@ -130,7 +130,7 @@
</tr>
<tr>
<td><code><span class='Separator'>⋄,</span></code> or newline</td>
-<td>Statement or element <a href="#separators">separator</a></td>
+<td>Statement or element <a href="token.html#separators">separator</a></td>
</tr>
<tr>
<td><code><span class='Bracket'>⟨⟩</span></code></td>
@@ -186,25 +186,16 @@
</tr>
</tbody>
</table>
-<h2 id="comments"><a class="header" href="#comments">Comments</a></h2>
-<p>A comment starts with a <code><span class='Comment'>#</span></code> that isn't part of a character or string literal, and continues to the end of the line.</p>
-<a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=JyMnIC0gMSAgI1RoaXMgaXMgdGhlIGNvbW1lbnQ=">↗️</a><pre> <span class='String'>'#'</span> <span class='Function'>-</span> <span class='Number'>1</span> <span class='Comment'>#This is the comment
-</span>'"'
-</pre>
-<h2 id="constants"><a class="header" href="#constants">Constants</a></h2>
-<p>BQN has single-token notation for numbers, strings, and characters.</p>
-<p><a href="types.html#numbers">Numbers</a> are written as decimals, allowing <code><span class='Number'>¯</span></code> for the negative sign (because <code><span class='Function'>-</span></code> is a function) and <code><span class='Value'>e</span></code> or <code><span class='Function'>E</span></code> for scientific notation. They must have digits before and after the decimal point (so, <code><span class='Number'>0.5</span></code> instead of <code><span class='Number'>.5</span></code>), and any exponent must be an integer. Two special numbers <code><span class='Number'>∞</span></code> and <code><span class='Number'>π</span></code> are supported, possibly with a minus sign. If complex numbers are supported (no implementation to date has them), then they can be written with the components separated by <code><span class='Value'>i</span></code> or <code><span class='Function'>I</span></code>.</p>
-<a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=4p+oIMKvz4Ag4ouEIDAuNSDii4QgNWXCrzEg4ouEIDEuNUUzIOKLhCDiiJ4g4p+pICAgIyBBIGxpc3Qgb2YgbnVtYmVycw==">↗️</a><pre> <span class='Bracket'>⟨</span> <span class='Number'>¯π</span> <span class='Separator'>⋄</span> <span class='Number'>0.5</span> <span class='Separator'>⋄</span> <span class='Number'>5e¯1</span> <span class='Separator'>⋄</span> <span class='Number'>1.5E3</span> <span class='Separator'>⋄</span> <span class='Number'>∞</span> <span class='Bracket'>⟩</span> <span class='Comment'># A list of numbers
-</span>⟨ ¯3.141592653589793 0.5 0.5 1500 ∞ ⟩
-</pre>
-<p>Strings—lists of characters—are written with double quotes <code><span class='String'>&quot;&quot;</span></code>, and <a href="types.html#characters">characters</a> with single quotes <code><span class='String'>''</span></code> with a single character in between. Only one character ever needs to be escaped: a double quote in a string is written twice. So <code><span class='String'>&quot;&quot;&quot;&quot;</span></code> is a one-character string of <code><span class='String'>&quot;</span></code>, and if two string literals are next to each other, they have to be separated by a space. Character literals don't have even one escape, as the length is already known. Other than the double quote, character and string literals can contain anything: newlines, null characters, or any other Unicode.</p>
-<a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=4omgwqgg4p+oICJzdHIiIOKLhCAicyd0IiJyIiDii4QgJ2MnIOKLhCAnJycg4ouEICciJyDin6kgICAjICIiIGlzIGFuIGVzY2FwZQoK4omhwqgg4p+oICJhIiDii4QgJ2EnIOKfqSAgICMgQSBzdHJpbmcgaXMgYW4gYXJyYXkgYnV0IGEgY2hhcmFjdGVyIGlzbid0">↗️</a><pre> <span class='Function'>≠</span><span class='Modifier'>¨</span> <span class='Bracket'>⟨</span> <span class='String'>&quot;str&quot;</span> <span class='Separator'>⋄</span> <span class='String'>&quot;s't&quot;&quot;r&quot;</span> <span class='Separator'>⋄</span> <span class='String'>'c'</span> <span class='Separator'>⋄</span> <span class='String'>'''</span> <span class='Separator'>⋄</span> <span class='String'>'&quot;'</span> <span class='Bracket'>⟩</span> <span class='Comment'># &quot;&quot; is an escape
-</span>⟨ 3 5 1 1 1 ⟩
-
- <span class='Function'>≡</span><span class='Modifier'>¨</span> <span class='Bracket'>⟨</span> <span class='String'>&quot;a&quot;</span> <span class='Separator'>⋄</span> <span class='String'>'a'</span> <span class='Bracket'>⟩</span> <span class='Comment'># A string is an array but a character isn't
-</span>⟨ 1 0 ⟩
-</pre>
-<p>But including a null character in your source code is probably not a great idea for other reasons. The null character (code point 0) has a dedicated literal representation <code><span class='String'>@</span></code>. Null can be used with <a href="arithmetic.html#character-arithmetic">character arithmetic</a> to directly convert between characters and numeric code points, which among many other uses allows tricky characters to be entered by code point: for example, a non-breaking space is <code><span class='String'>@</span><span class='Function'>+</span><span class='Number'>160</span></code>.</p>
+<h2 id="tokens"><a class="header" href="#tokens">Tokens</a></h2>
+<p><em><a href="token.html">Full documentation</a></em></p>
+<p>BQN syntax is made up of tokens, which are mostly single characters. But there are a few exceptions:</p>
+<ul>
+<li><a href="token.html#comments">Comments</a> start with <code><span class='Comment'>#</span></code> and end at the end of the line.</li>
+<li><a href="token.html#characters-and-strings">Character literals</a> start and end with <code><span class='String'>'</span></code>, and have exactly one character in between.</li>
+<li><a href="token.html#characters-and-strings">String literals</a> start and end with <code><span class='String'>&quot;</span></code>. Pairs of quotes <code><span class='String'>&quot;&quot;</span></code> in between represent one quote character, and other characters (including <code><span class='String'>'</span></code>) represent themselves.</li>
+<li><a href="token.html#numbers">Numbers</a> support decimal (<code><span class='Value'>.</span></code>) and scientific (<code><span class='Value'>e</span></code>) notation, plus <code><span class='Number'>π</span></code> and <code><span class='Number'>∞</span></code>, and use <code><span class='Number'>¯</span></code> for a minus sign.</li>
+<li><a href="token.html#names">Variable names</a> allow letters, underscores, and numeric characters. They're matched case-insensitively, with a <a href="expression.html#role-spellings">spelling system</a> that determines role.</li>
+</ul>
<h2 id="expressions"><a class="header" href="#expressions">Expressions</a></h2>
<p><em><a href="expression.html">Full documentation</a></em></p>
<p>BQN expressions are composed of subjects, functions, and modifiers, with parentheses to group parts into subexpressions. <a href="ops.html#functions">Functions</a> can be applied to subjects or grouped into <a href="train.html">trains</a>, while <a href="ops.html#modifiers">modifiers</a> can be applied to subjects or functions. The most important kinds of application are:</p>
@@ -263,9 +254,7 @@
<p><a href="expression.html#assignment">Assignment</a> arrows <code><span class='Gets'>←</span></code>, <code><span class='Gets'>↩</span></code>, and <code><span class='Gets'>⇐</span></code> store expression results in variables: <code><span class='Gets'>←</span></code> and <code><span class='Gets'>⇐</span></code> create new variables while <code><span class='Gets'>↩</span></code> modifies existing ones. The general format is <code><span class='Function'>Name</span> <span class='Gets'>←</span> <span class='Function'>Value</span></code>, where the two sides have the same role. Additionally, <code><span class='Value'>lhs</span> <span class='Function'>F</span><span class='Gets'>↩</span> <span class='Value'>rhs</span></code> is a shortened form of <code><span class='Value'>lhs</span> <span class='Gets'>↩</span> <span class='Value'>lhs</span> <span class='Function'>F</span> <span class='Value'>rhs</span></code> and <code><span class='Value'>lhs</span> <span class='Function'>F</span><span class='Gets'>↩</span></code> expands to <code><span class='Value'>lhs</span> <span class='Gets'>↩</span> <span class='Function'>F</span> <span class='Value'>lhs</span></code>.</p>
<p>The double arrow <code><span class='Gets'>⇐</span></code> is used for functionality relating to <a href="namespace.html">namespaces</a>. It has a few purposes: exporting assignment <code><span class='Value'>name</span><span class='Gets'>⇐</span><span class='Value'>value</span></code>, plain export <code><span class='Value'>name</span><span class='Gets'>⇐</span></code>, and aliasing <code><span class='Bracket'>⟨</span><span class='Value'>alias</span><span class='Gets'>⇐</span><span class='Value'>field</span><span class='Bracket'>⟩</span><span class='Gets'>←</span><span class='Value'>namespace</span></code>. A block that uses it for export returns a namespace rather than the result of its last statement. The other namespace-related bit of syntax is field access <code><span class='Value'>ns.field</span></code>.</p>
<h2 id="arrays-and-blocks"><a class="header" href="#arrays-and-blocks">Arrays and blocks</a></h2>
-<p>Arrays and code blocks can both be represented as sequences of expressions in source code. There are paired bracket representations, using <code><span class='Bracket'>⟨⟩</span></code> for lists, <code><span class='Bracket'>[]</span></code> for arrays, and <code><span class='Brace'>{}</span></code> for blocks, as well as a shortcut &quot;stranding&quot; notation using <code><span class='Ligature'>‿</span></code> for lists.</p>
-<h3 id="separators"><a class="header" href="#separators">Separators</a></h3>
-<p>The characters <code><span class='Separator'>⋄</span></code> and <code><span class='Separator'>,</span></code> and newline are completely interchangeable and are used to separate expressions. An expression might be an element in a list or a line in a block. Empty sections—those that consist only of whitespace—are ignored. This means that any number of separators can be used between expressions, and that leading and trailing separators are also allowed. The expressions are evaluated in text order: left to right and top to bottom.</p>
+<p>Arrays and code blocks can both be represented as sequences of expressions in source code. There are paired bracket representations, using <code><span class='Bracket'>⟨⟩</span></code> for lists, <code><span class='Bracket'>[]</span></code> for arrays, and <code><span class='Brace'>{}</span></code> for blocks, as well as a shortcut &quot;stranding&quot; notation using <code><span class='Ligature'>‿</span></code> for lists. Elements within brackets are divided by <a href="token.html#separators">separators</a>: <code><span class='Separator'>,</span></code> or <code><span class='Separator'>⋄</span></code> or a line break.</p>
<h3 id="list-and-array-notation"><a class="header" href="#list-and-array-notation">List and array notation</a></h3>
<p><em><a href="arrayrepr.html#array-literals">Full documentation</a></em></p>
<p>Lists (1-dimensional arrays) are enclosed in angle brackets <code><span class='Bracket'>⟨⟩</span></code>, with the results of the expressions in between being the list's elements. Lists of two elements or more can also be written with the ligature character <code><span class='Ligature'>‿</span></code>. This character has higher binding strength than any part of an expression except <code><span class='Value'>.</span></code> for namespace field access. If one of the elements is a compound expression, then it will need to be enclosed in parentheses.</p>
diff --git a/docs/doc/token.html b/docs/doc/token.html
new file mode 100644
index 00000000..75387cde
--- /dev/null
+++ b/docs/doc/token.html
@@ -0,0 +1,41 @@
+<head>
+ <link href="../favicon.ico" rel="shortcut icon" type="image/x-icon"/>
+ <link href="../style.css" rel="stylesheet"/>
+ <title>BQN: Tokens</title>
+</head>
+<div class="nav">(<a href="https://github.com/mlochbaum/BQN">github</a>) / <a href="../index.html">BQN</a> / <a href="index.html">doc</a></div>
+<h1 id="tokens"><a class="header" href="#tokens">Tokens</a></h1>
+<p>A &quot;token&quot; is the smallest part of syntax, much like a word in English. BQN's rules for forming tokens are simpler than most programming languages, because most of them are single characters. There are only a few kinds of multi-character tokens: character and string literals written with <code><span class='String'>'</span></code> and <code><span class='String'>&quot;</span></code>, and words which are numbers, names, or system values.</p>
+<p>Strings (and characters) and comments have starting and ending conditions, but can't overlap. The first one that starts first &quot;wins&quot;: it needs to end before any other token or comment can start. These also take precedence over other token rules, that is, characters inside a string or comment don't form other tokens.</p>
+<h2 id="non-tokens"><a class="header" href="#non-tokens">Non-tokens</a></h2>
+<p>Comments, and the horizontal whitespace characters space and tab, don't form tokens, since they don't do anything as far as the program's concerned. However, whitespace can be used to separate adjacent words or strings. Comments can only end with a newline, which doesn't need separating, so they <em>really</em> don't do anything, other than inform the reader about whatever you have to say. Note that newline characters (either LF or CR) are <a href="#separators">separators</a>, which are tokens.</p>
+<h3 id="comments"><a class="header" href="#comments">Comments</a></h3>
+<p>A comment starts with a <code><span class='Comment'>#</span></code> that isn't part of a character or string literal, and continues to the end of the line.</p>
+<a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=JyMnIC0gMSAgI1RoaXMgaXMgdGhlIGNvbW1lbnQ=">↗️</a><pre> <span class='String'>'#'</span> <span class='Function'>-</span> <span class='Number'>1</span> <span class='Comment'>#This is the comment
+</span>'"'
+</pre>
+<p>Every line of commentary needs its own <code><span class='Comment'>#</span></code>; there's no multi-line comment syntax.</p>
+<h2 id="characters-and-strings"><a class="header" href="#characters-and-strings">Characters and strings</a></h2>
+<p>Strings—lists of characters—are written with double quotes <code><span class='String'>&quot;&quot;</span></code>, and <a href="types.html#characters">characters</a> with single quotes <code><span class='String'>''</span></code> with a single character in between. Only one character ever needs to be escaped: a double quote in a string is written twice. So <code><span class='String'>&quot;&quot;&quot;&quot;</span></code> is a one-character string of <code><span class='String'>&quot;</span></code>, and if two string literals are next to each other, they have to be separated by a space. Character literals don't have even one escape, as the length is already known. Other than the double quote, character and string literals can contain any character directly: newlines, null characters, or other Unicode.</p>
+<a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=4omgwqgg4p+oICJzdHIiIOKLhCAicyd0IiJyIiDii4QgJ2MnIOKLhCAnJycg4ouEICciJyDin6kgICAjICIiIGlzIGFuIGVzY2FwZQoK4omhwqgg4p+oICJhIiDii4QgJ2EnIOKfqSAgICMgQSBzdHJpbmcgaXMgYW4gYXJyYXkgYnV0IGEgY2hhcmFjdGVyIGlzbid0">↗️</a><pre> <span class='Function'>≠</span><span class='Modifier'>¨</span> <span class='Bracket'>⟨</span> <span class='String'>&quot;str&quot;</span> <span class='Separator'>⋄</span> <span class='String'>&quot;s't&quot;&quot;r&quot;</span> <span class='Separator'>⋄</span> <span class='String'>'c'</span> <span class='Separator'>⋄</span> <span class='String'>'''</span> <span class='Separator'>⋄</span> <span class='String'>'&quot;'</span> <span class='Bracket'>⟩</span> <span class='Comment'># &quot;&quot; is an escape
+</span>⟨ 3 5 1 1 1 ⟩
+
+ <span class='Function'>≡</span><span class='Modifier'>¨</span> <span class='Bracket'>⟨</span> <span class='String'>&quot;a&quot;</span> <span class='Separator'>⋄</span> <span class='String'>'a'</span> <span class='Bracket'>⟩</span> <span class='Comment'># A string is an array but a character isn't
+</span>⟨ 1 0 ⟩
+</pre>
+<p>But including a null character in your source code is probably not a great idea for other reasons. The null character (code point 0) has a dedicated literal representation <code><span class='String'>@</span></code>. Null can be used with <a href="arithmetic.html#character-arithmetic">character arithmetic</a> to directly convert between characters and numeric code points, which among many other uses allows tricky characters to be entered by code point: for example, a non-breaking space is <code><span class='String'>@</span><span class='Function'>+</span><span class='Number'>160</span></code>.</p>
+<h2 id="words"><a class="header" href="#words">Words</a></h2>
+<p>Numbers and variable names share a token formation rule, and are collectively called words. A word is a number if it starts with a digit or numeric character <code><span class='Number'>¯∞π</span></code>, and a name otherwise.</p>
+<p>Words are formed from digits, letters, and the characters <code><span class='Modifier2'>_</span><span class='Value'>.</span><span class='Number'>¯∞π</span></code>. All these characters stick together, so that you need to separate words with whitespace in order to write them next to each other. But <code><span class='Value'>.</span></code> only counts if it's followed by a digit: otherwise it forms its own token to support <a href="namespace.html#imports">namespace syntax</a> <code><span class='Value'>ns.field</span></code>. A word may be preceded by <code><span class='Value'>•</span></code> to form a system name.</p>
+<p>The character <code><span class='Value'>𝕣</span></code> also sticks with other word-forming characters, but is only allowed form the special names <code><span class='Value'>𝕣</span></code>, <code><span class='Modifier'>_𝕣</span></code>, and <code><span class='Modifier2'>_𝕣_</span></code>.</p>
+<h3 id="numbers"><a class="header" href="#numbers">Numbers</a></h3>
+<p><a href="types.html#numbers">Numbers</a> are written as decimals, allowing <code><span class='Number'>¯</span></code> for the negative sign (because <code><span class='Function'>-</span></code> is a function) and <code><span class='Value'>e</span></code> or <code><span class='Function'>E</span></code> for scientific notation. They must have digits before and after the decimal point (so, <code><span class='Number'>0.5</span></code> instead of <code><span class='Number'>.5</span></code>), and any exponent must be an integer. Two special numbers <code><span class='Number'>∞</span></code> and <code><span class='Number'>π</span></code> are supported, possibly with a minus sign. If complex numbers are supported (no implementation to date has them), then they can be written with the components separated by <code><span class='Value'>i</span></code> or <code><span class='Function'>I</span></code>.</p>
+<a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=4p+oIMKvz4Ag4ouEIDAuNSDii4QgNWXCrzEg4ouEIDEuNUUzIOKLhCDiiJ4g4p+pICAgIyBBIGxpc3Qgb2YgbnVtYmVycw==">↗️</a><pre> <span class='Bracket'>⟨</span> <span class='Number'>¯π</span> <span class='Separator'>⋄</span> <span class='Number'>0.5</span> <span class='Separator'>⋄</span> <span class='Number'>5e¯1</span> <span class='Separator'>⋄</span> <span class='Number'>1.5E3</span> <span class='Separator'>⋄</span> <span class='Number'>∞</span> <span class='Bracket'>⟩</span> <span class='Comment'># A list of numbers
+</span>⟨ ¯3.141592653589793 0.5 0.5 1500 ∞ ⟩
+</pre>
+<h3 id="names"><a class="header" href="#names">Names</a></h3>
+<p>A variable name starts with a letter but otherwise can contain anything, including characters like <code><span class='Number'>∞</span></code> and <code><span class='Number'>¯</span></code>. Names represent identifiers according to the rules of <a href="lexical.html">lexical scoping</a>. A somewhat unusual feature of BQN is that identifiers are case- and underscore-insensitive, so that <code><span class='Value'>abc</span></code> is treated as the same name as <code><span class='Modifier'>_a_B_c</span></code>. This works with the <a href="expression.html#role-spellings">role spelling</a> system so that changing the case or adding underscores allows the same variable to be used in different roles.</p>
+<p>The system dot <code><span class='Value'>•</span></code> can only start a word, and must be followed by a name. This accesses a system value such as the debugging display function <code><span class='Function'>•Show</span></code>.</p>
+<h2 id="separators"><a class="header" href="#separators">Separators</a></h2>
+<p>The characters <code><span class='Separator'>⋄</span></code> and <code><span class='Separator'>,</span></code> and newline are completely interchangeable and are used to separate expressions. An expression might be an element in a list or a line in a block. Empty sections—those that consist only of whitespace—are ignored. This means that any number of separators can be used between expressions, and that leading and trailing separators are also allowed. The expressions are evaluated in text order: left to right and top to bottom.</p>
+<p>Both LF and CR are allowed as newline characters, and CRLF functions as a separator too because of the way multiple separators work.</p>
diff --git a/docs/help/character.html b/docs/help/character.html
index 7a29a0f5..4675c644 100644
--- a/docs/help/character.html
+++ b/docs/help/character.html
@@ -6,7 +6,7 @@
<div class="nav">(<a href="https://github.com/mlochbaum/BQN">github</a>) / <a href="../index.html">BQN</a> / <a href="index.html">help</a></div>
<h1 id="single-quote-"><a class="header" href="#single-quote-">Single Quote (<code><span class='String'>'</span></code>)</a></h1>
<h2 id="c-character"><a class="header" href="#c-character"><code><span class='String'>'c'</span></code>: Character</a></h2>
-<p><a class="fulldoc" href="../doc/syntax.html#constants">→full documentation</a></p>
+<p><a class="fulldoc" href="../doc/token.html#characters-and-strings">→full documentation</a></p>
<p>A character literal whose value is the character between quotes. Any character can be used, even <code><span class='String'>'</span></code> and newline.</p>
<a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=J2En4oC/J2In">↗️</a><pre> <span class='String'>'a'</span><span class='Ligature'>‿</span><span class='String'>'b'</span>
"ab"
diff --git a/docs/help/comment.html b/docs/help/comment.html
index 70671d81..8b02d745 100644
--- a/docs/help/comment.html
+++ b/docs/help/comment.html
@@ -6,7 +6,7 @@
<div class="nav">(<a href="https://github.com/mlochbaum/BQN">github</a>) / <a href="../index.html">BQN</a> / <a href="index.html">help</a></div>
<h1 id="number-sign-"><a class="header" href="#number-sign-">Number Sign (<code><span class='Comment'>#</span></code>)</a></h1>
<h2 id="-comment"><a class="header" href="#-comment"><code><span class='Comment'>#</span></code>: Comment</a></h2>
-<p><a class="fulldoc" href="../doc/syntax.html#comments">→full documentation</a></p>
+<p><a class="fulldoc" href="../doc/token.html#comments">→full documentation</a></p>
<p>Create a comment that extends to the end of the line.</p>
<p>Anything written in comments is ignored.</p>
<a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=MSArIDIgIyArIDMgKyA0CgoiSGVsbG8gd29ybGQhIiAjIHRoaXMgaXMgaWdub3JlZCE=">↗️</a><pre> <span class='Number'>1</span> <span class='Function'>+</span> <span class='Number'>2</span> <span class='Comment'># + 3 + 4
diff --git a/docs/help/infinity.html b/docs/help/infinity.html
index c607967e..8771e545 100644
--- a/docs/help/infinity.html
+++ b/docs/help/infinity.html
@@ -6,7 +6,7 @@
<div class="nav">(<a href="https://github.com/mlochbaum/BQN">github</a>) / <a href="../index.html">BQN</a> / <a href="index.html">help</a></div>
<h1 id="infinity-"><a class="header" href="#infinity-">Infinity (<code><span class='Number'>∞</span></code>)</a></h1>
<h2 id="-infinity"><a class="header" href="#-infinity"><code><span class='Number'>∞</span></code>: Infinity</a></h2>
-<p><a class="fulldoc" href="../doc/syntax.html#constants">→full documentation</a></p>
+<p><a class="fulldoc" href="../doc/token.html#numbers">→full documentation</a></p>
<p>Mathematical constant Infinity, a numeric literal. Can be negative (<code><span class='Number'>¯∞</span></code>).</p>
<a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=4oieCgrCr+KIngoKMSviiJ4=">↗️</a><pre> <span class='Number'>∞</span>
diff --git a/docs/help/minus.html b/docs/help/minus.html
index c235aa75..ca43170a 100644
--- a/docs/help/minus.html
+++ b/docs/help/minus.html
@@ -6,7 +6,7 @@
<div class="nav">(<a href="https://github.com/mlochbaum/BQN">github</a>) / <a href="../index.html">BQN</a> / <a href="index.html">help</a></div>
<h1 id="macron-"><a class="header" href="#macron-">Macron (<code><span class='Number'>¯</span></code>)</a></h1>
<h2 id="-minus"><a class="header" href="#-minus"><code><span class='Number'>¯</span></code>: Minus</a></h2>
-<p><a class="fulldoc" href="../doc/syntax.html#constants">→full documentation</a></p>
+<p><a class="fulldoc" href="../doc/token.html#numbers">→full documentation</a></p>
<p>Prefix before numbers to indicate that they are negative.</p>
<p>Note that this is not the same as <code><span class='Function'>-</span></code>, since it is part of the number, rather than a primitive that negates its value.</p>
<a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=LTHigL8y4oC/MwoKwq8x4oC/MuKAvzM=">↗️</a><pre> <span class='Function'>-</span><span class='Number'>1</span><span class='Ligature'>‿</span><span class='Number'>2</span><span class='Ligature'>‿</span><span class='Number'>3</span>
diff --git a/docs/help/nullcharacter.html b/docs/help/nullcharacter.html
index 24bcf67e..491642e8 100644
--- a/docs/help/nullcharacter.html
+++ b/docs/help/nullcharacter.html
@@ -6,7 +6,7 @@
<div class="nav">(<a href="https://github.com/mlochbaum/BQN">github</a>) / <a href="../index.html">BQN</a> / <a href="index.html">help</a></div>
<h1 id="commercial-at-"><a class="header" href="#commercial-at-">Commercial At (<code><span class='String'>@</span></code>)</a></h1>
<h2 id="-null-character"><a class="header" href="#-null-character"><code><span class='String'>@</span></code>: Null Character</a></h2>
-<p><a class="fulldoc" href="../doc/syntax.html#constants">→full documentation</a></p>
+<p><a class="fulldoc" href="../doc/token.html#characters-and-strings">→full documentation</a></p>
<p>Null character, code point 0 in ASCII. A shortcut character literal.</p>
<p>Add to a code point number to get that character.</p>
<a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=QCs1MAoKQAoKQCs2NA==">↗️</a><pre> <span class='String'>@</span><span class='Function'>+</span><span class='Number'>50</span>
diff --git a/docs/help/pi.html b/docs/help/pi.html
index 3a947cb2..7d677211 100644
--- a/docs/help/pi.html
+++ b/docs/help/pi.html
@@ -6,7 +6,7 @@
<div class="nav">(<a href="https://github.com/mlochbaum/BQN">github</a>) / <a href="../index.html">BQN</a> / <a href="index.html">help</a></div>
<h1 id="pi-π"><a class="header" href="#pi-π">Pi (<code><span class='Number'>π</span></code>)</a></h1>
<h2 id="π-pi"><a class="header" href="#π-pi"><code><span class='Number'>π</span></code>: Pi</a></h2>
-<p><a class="fulldoc" href="../doc/syntax.html#constants">→full documentation</a></p>
+<p><a class="fulldoc" href="../doc/token.html#numbers">→full documentation</a></p>
<p>The mathematical constant pi, a numeric literal. Can be negative (<code><span class='Number'>¯π</span></code>).</p>
<a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=z4AKCsKvz4A=">↗️</a><pre> <span class='Number'>π</span>
3.141592653589793
diff --git a/docs/help/separator.html b/docs/help/separator.html
index 3c104dbe..931d635e 100644
--- a/docs/help/separator.html
+++ b/docs/help/separator.html
@@ -6,7 +6,7 @@
<div class="nav">(<a href="https://github.com/mlochbaum/BQN">github</a>) / <a href="../index.html">BQN</a> / <a href="index.html">help</a></div>
<h1 id="comma--and-diamond-"><a class="header" href="#comma--and-diamond-">Comma (<code><span class='Separator'>,</span></code>) and Diamond (<code><span class='Separator'>⋄</span></code>)</a></h1>
<h2 id="-or--separator"><a class="header" href="#-or--separator"><code><span class='Separator'>,</span></code> or <code><span class='Separator'>⋄</span></code>: Separator</a></h2>
-<p><a class="fulldoc" href="../doc/syntax.html#separators">→full documentation</a></p>
+<p><a class="fulldoc" href="../doc/token.html#separators">→full documentation</a></p>
<p>Separates statements in blocks, programs, and arrays. Characters <code><span class='Separator'>,</span></code> and <code><span class='Separator'>⋄</span></code> are interchangeable with each other and with newline.</p>
<a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=YSDihpAgMyAsIOKKoiBiIOKGkCAyCgoxIOKLhCAyICwgMwoK4p+oMSAsIDIg4ouEIDPin6kKCnsxIOKLhCAyIOKLhCAzfQ==">↗️</a><pre> <span class='Value'>a</span> <span class='Gets'>←</span> <span class='Number'>3</span> <span class='Separator'>,</span> <span class='Function'>⊢</span> <span class='Value'>b</span> <span class='Gets'>←</span> <span class='Number'>2</span>
2
diff --git a/docs/help/string.html b/docs/help/string.html
index d7d1e74a..18a6db4f 100644
--- a/docs/help/string.html
+++ b/docs/help/string.html
@@ -6,7 +6,7 @@
<div class="nav">(<a href="https://github.com/mlochbaum/BQN">github</a>) / <a href="../index.html">BQN</a> / <a href="index.html">help</a></div>
<h1 id="double-quote-"><a class="header" href="#double-quote-">Double Quote (<code><span class='String'>&quot;</span></code>)</a></h1>
<h2 id="str-string"><a class="header" href="#str-string"><code><span class='String'>&quot;str&quot;</span></code>: String</a></h2>
-<p><a class="fulldoc" href="../doc/syntax.html#constants">→full documentation</a></p>
+<p><a class="fulldoc" href="../doc/token.html#characters-and-strings">→full documentation</a></p>
<p>Literal notation for a string, or list of characters. Double quotes must be escaped by writing them twice. Any other characters can be included directly.</p>
<a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=MiDiipEgInN0cmluZyIKCjIg4oqRICJhYiIiY2Qi">↗️</a><pre> <span class='Number'>2</span> <span class='Function'>⊑</span> <span class='String'>&quot;string&quot;</span>
'r'
diff --git a/help/character.md b/help/character.md
index 7f1e3487..0dd299ff 100644
--- a/help/character.md
+++ b/help/character.md
@@ -3,7 +3,7 @@
# Single Quote (`'`)
## `'c'`: Character
-[→full documentation](../doc/syntax.md#constants)
+[→full documentation](../doc/token.md#characters-and-strings)
A character literal whose value is the character between quotes. Any character can be used, even `'` and newline.
diff --git a/help/comment.md b/help/comment.md
index 9e966a50..ac661530 100644
--- a/help/comment.md
+++ b/help/comment.md
@@ -3,7 +3,7 @@
# Number Sign (`#`)
## `#`: Comment
-[→full documentation](../doc/syntax.md#comments)
+[→full documentation](../doc/token.md#comments)
Create a comment that extends to the end of the line.
diff --git a/help/infinity.md b/help/infinity.md
index d26b4614..6af8db68 100644
--- a/help/infinity.md
+++ b/help/infinity.md
@@ -3,7 +3,7 @@
# Infinity (`∞`)
## `∞`: Infinity
-[→full documentation](../doc/syntax.md#constants)
+[→full documentation](../doc/token.md#numbers)
Mathematical constant Infinity, a numeric literal. Can be negative (`¯∞`).
diff --git a/help/minus.md b/help/minus.md
index 534d553b..525fa293 100644
--- a/help/minus.md
+++ b/help/minus.md
@@ -3,7 +3,7 @@
# Macron (`¯`)
## `¯`: Minus
-[→full documentation](../doc/syntax.md#constants)
+[→full documentation](../doc/token.md#numbers)
Prefix before numbers to indicate that they are negative.
diff --git a/help/nullcharacter.md b/help/nullcharacter.md
index 6c0c18ab..95b9d753 100644
--- a/help/nullcharacter.md
+++ b/help/nullcharacter.md
@@ -3,7 +3,7 @@
# Commercial At (`@`)
## `@`: Null Character
-[→full documentation](../doc/syntax.md#constants)
+[→full documentation](../doc/token.md#characters-and-strings)
Null character, code point 0 in ASCII. A shortcut character literal.
diff --git a/help/pi.md b/help/pi.md
index e32ff767..8e106419 100644
--- a/help/pi.md
+++ b/help/pi.md
@@ -3,7 +3,7 @@
# Pi (`π`)
## `π`: Pi
-[→full documentation](../doc/syntax.md#constants)
+[→full documentation](../doc/token.md#numbers)
The mathematical constant pi, a numeric literal. Can be negative (`¯π`).
diff --git a/help/separator.md b/help/separator.md
index a64720bf..b38fdd3f 100644
--- a/help/separator.md
+++ b/help/separator.md
@@ -3,7 +3,7 @@
# Comma (`,`) and Diamond (`⋄`)
## `,` or `⋄`: Separator
-[→full documentation](../doc/syntax.md#separators)
+[→full documentation](../doc/token.md#separators)
Separates statements in blocks, programs, and arrays. Characters `,` and `⋄` are interchangeable with each other and with newline.
diff --git a/help/string.md b/help/string.md
index a8a4741f..94c0a81d 100644
--- a/help/string.md
+++ b/help/string.md
@@ -3,7 +3,7 @@
# Double Quote (`"`)
## `"str"`: String
-[→full documentation](../doc/syntax.md#constants)
+[→full documentation](../doc/token.md#characters-and-strings)
Literal notation for a string, or list of characters. Double quotes must be escaped by writing them twice. Any other characters can be included directly.
diff --git a/md.bqn b/md.bqn
index 8aa21c43..fd325102 100644
--- a/md.bqn
+++ b/md.bqn
@@ -273,9 +273,9 @@ Markdown ← {filename𝕊𝕩:
items ↩ { ∨´indent ?
# Require indented lines to form a nested list
Len ← { ! ∧´(⊑¨𝕩)∊"-+*" ⋄ LenBullet ⊑𝕩 }
- start ← »⊸< indent
# Process items recursively
- sub ← Len⊸ProcBullet¨ (1-˜indent×+`start) ⊔ items
+ groups ← 1 -˜ (indent∾1) × +` (¬indent)∾1
+ sub ← Len⊸ProcBullet⍟(0<≠)¨ groups ⊔ items
# Append to the first line, which is assumed to stand alone
(ProcInline¨ indent ¬⊸/ items) JoinLines∘⋈¨ sub
;