# DS lexer contract

The lexer's contract. Paired with
[LGRA], which carries the parser productions
(BNF) and the prose / disambiguation rules.

The lexer turns a UTF-8 source file into a token stream the
parser consumes. Everything the parser grammar assumes — that
comments are gone, that blank lines don't appear, that
`INDENT` / `DEDENT` / `NEWLINE` mark block structure, that
`-->` is one token not two — is the lexer's responsibility to
deliver.

This spec is authoritative for the lexer's behaviour. A
conforming implementation of DS must produce the token stream
specified here; the parser is written against this stream, not
the raw source.

## What this is not

- Not the parser grammar — see [LGRA].
- Not the string-interpolation sub-grammar — interpolation
  sites `{…}` inside string literals are parsed in a second
  pass over the already-lexed `STRING_LIT` content (see
  [LGRA.11] / [LGRA.2.9.6]).
- Not an implementation guide for a specific parser-generator
  tool. The rules here can be implemented in any framework and
  need no parser-state-dependent lexing ([LLEX.10.7]).

---

(LLEX-1)=
## Source encoding [LLEX.1]

(LLEX-1-1)=
- [LLEX.1.1] **UTF-8.** Source files are UTF-8. The lexer must refuse a file with an
  ill-formed sequence anywhere in it, a comment and a string literal included.

(LLEX-1-2)=
- [LLEX.1.2] **BOM.** A UTF-8 byte-order mark at the start of the file is
  stripped silently; at any other position it is a lexer error.

*ratified*

(LLEX-1-3)=
- [LLEX.1.3] **Non-ASCII.** Permitted inside string literals, regex literals
  and comments, in an identifier as [LNAM.2] admits it, and in a `TYPE_SYM`
  ([LLEX.10]). The lexer must refuse a non-ASCII character anywhere else.

*see also:* [LLEX.10](#LLEX-10), [LNAM.2](#LNAM-2)

(LLEX-2)=
## Line endings [LLEX.2]

(LLEX-2-1)=
- [LLEX.2.1] **LF (`\n`) or CRLF (`\r\n`)** are both accepted. They are
  normalised to a single logical end-of-line internally.

(LLEX-2-2)=
- [LLEX.2.2] **Lone CR (`\r` without following `\n`)** is rejected with a
  lexer error.

*ratified*

(LLEX-3)=
## Horizontal whitespace [LLEX.3]

(LLEX-3-1)=
- [LLEX.3.1] **Space (0x20)** is the only legal horizontal whitespace in
  source.

(LLEX-3-2)=
- [LLEX.3.2] **Tab (0x09)** is rejected outright with a lexer error:
  `"tab character at line N, column M"`. Deliberate — block
  structure depends on indent, and tab/space mixing is the
  single most common source of whitespace-sensitive bugs.

(LLEX-3-3)=
- [LLEX.3.3] **Form feed (0x0C), vertical tab (0x0B), other whitespace
  code points** — all rejected with a lexer error.

---

*ratified*

(LLEX-4)=
## Comments [LLEX.4]

```
comment ::= '#' <any-char-except-newline>*
```

(LLEX-4-1)=
[LLEX.4.1] A comment begins with `#` and runs to the end of the line. Any
run of `#` (`##`, `###`, …) is legal and has no grammatical
meaning; authors use the count for visual hierarchy. There are
no block comments.

*ratified*

(LLEX-4-2)=
[LLEX.4.2] **Comments are stripped by the lexer.** They do not produce
tokens. The parser never sees them.

---

*ratified*

(LLEX-5)=
## Blank lines [LLEX.5]

(LLEX-5-1)=
[LLEX.5.1] A **blank line** is one containing only spaces, only a comment,
or no content at all (immediate newline).

(LLEX-5-2)=
- [LLEX.5.2] **Blank lines emit no tokens.** No `NEWLINE`, no `INDENT`, no
  `DEDENT`. The parser sees the token stream as if blank lines
  weren't there.

*ratified*

(LLEX-5-3)=
- [LLEX.5.3] **Blank lines don't affect indentation tracking.** A block
  body may contain blank lines without signalling `DEDENT`.

*ratified*

(LLEX-5-4)=
[LLEX.5.4] This is what makes blank-line separation between top-level
declarations "free" at the grammar level — the lexer absorbs
them.

---

(LLEX-6)=
## Indentation [LLEX.6]

(LLEX-6-1)=
[LLEX.6.1] DS is indent-sensitive in the Python tradition. Indentation
**must be exactly 4 spaces per level**.

*ratified*

(LLEX-6-2)=
- [LLEX.6.2] The lexer tracks a stack of active indent levels, starting
  with `[0]` at the top of the file.

(LLEX-6-3)=
- [LLEX.6.3] On the first non-blank line whose leading-space count differs
  from the current top of stack:
  - **Greater** than current top, by exactly 4 × N spaces
    (N ≥ 1): push N new levels; emit N `INDENT` tokens.
  - **Less** than current top: pop levels until the stack top
    matches; emit one `DEDENT` per popped level. If no stack
    level matches, emit a lexer error
    (`"inconsistent dedent: column M does not match any
    enclosing block"`).
  - **Equal**: emit nothing.

(LLEX-6-4)=
- [LLEX.6.4] **Inconsistent indentation** — a leading-space count that
  isn't a multiple of 4 from the enclosing block's indent —
  is a lexer error (`"inconsistent indentation: expected
  multiple of 4 from column M"`). This constraint is
  **suspended inside unbalanced bracket groups** (see
  LLEX.7.5.5); any leading-space count is legal on
  continuation lines inside `( )`, `[ ]`, or `{ }`.

*see also:* [LLEX.7.5.5](#LLEX-7-5-5)

(LLEX-6-5)=
- [LLEX.6.5] **At end of file**: emit one `DEDENT` per level still on the
  stack above 0.

(LLEX-6-6)=
### Interaction with blank lines and comments [LLEX.6.6]

(LLEX-6-6-1)=
[LLEX.6.6.1] Leading-space counts on blank lines (including comment-only
lines) are **ignored** for indentation tracking. Only the next
non-blank line affects the stack.

(LLEX-6-7)=
### Indentation inside string literals [LLEX.6.7]

(LLEX-6-7-1)=
[LLEX.6.7.1] Triple-quoted strings (`"""…"""`) can span multiple lines. The
lexer does **not** track indentation inside a triple string;
line breaks and leading whitespace inside the literal are part
of the string value. The consumer applies the Python
`inspect.cleandoc` rule when it reads the literal's value
(strip the common leading whitespace on non-empty lines;
remove leading and trailing blank lines).

---

(LLEX-7)=
## NEWLINE emission [LLEX.7]

(LLEX-7-1)=
[LLEX.7.1] A `NEWLINE` token marks the end of one **logical** line — a
line that produced at least one non-blank token. Specifically:

(LLEX-7-2)=
- [LLEX.7.2] After the last content token of a non-blank, non-comment-only
  line, the lexer emits `NEWLINE`.

(LLEX-7-3)=
- [LLEX.7.3] Inside an unclosed bracket group (see [LLEX.7.5] below), the lexer suppresses `NEWLINE`. This is
  the only mechanism for continuing a logical line across
  physical lines in v1.

*see also:* [LLEX.7.5](#LLEX-7-5)

(LLEX-7-4)=
- [LLEX.7.4] The lexer emits `INDENT` / `DEDENT` **before** the first
  content token of the new indented line, not after the
  previous line's `NEWLINE`.

(LLEX-7-5)=
### Bracket-balanced line continuation [LLEX.7.5]

(LLEX-7-5-1)=
[LLEX.7.5.1] While the lexer is inside unbalanced parentheses `( )`, square
brackets `[ ]`, or curly braces `{ }`, physical newlines do
**not** emit `NEWLINE`. The unclosed bracket signals to the
reader that a logical line continues.

*ratified*

(LLEX-7-5-2)=
[LLEX.7.5.2] Here the opening `(` suppresses newline emission until the
matching `)`; the whole call is one logical line.

(LLEX-7-5-3)=
- [LLEX.7.5.3] **Nesting** is tracked: `(`, `[`, `{` increment; their closers
  decrement. Mismatched closers are a lexer error.

(LLEX-7-5-4)=
- [LLEX.7.5.4] **Unterminated brackets** at end of file are a lexer error.

(LLEX-7-5-5)=
- [LLEX.7.5.5] **Indentation tracking** inside an unbalanced bracket group
  is suspended. The lexer still reads characters but doesn't
  emit `INDENT` / `DEDENT` until the group closes.
  Consequently, the 4-space multiple constraint (LLEX.6.4) is
  also suspended for those lines — any leading-space count is
  accepted. This matches Python's bracket-continuation
  semantics and is the standard mechanism for multi-line
  `where` predicates, written inside one parenthesised group.

  The continuation lines inside `(` / `)` may be indented to
  any column; the 4-space rule resumes after the closing `)`.

*see also:* [LLEX.6.4](#LLEX-6-4)

(LLEX-7-5-6)=
[LLEX.7.5.6] Unpaired `{` / `}` are always lexer errors — the braces are
only legal inside string literals (as interpolation delimiters)
or as bracket-balanced continuation. A bare `{` at the start of
an expression is rejected.

---

*ratified*

(LLEX-8)=
## Tokens [LLEX.8]

(LLEX-8-1)=
### Longest-match disambiguation [LLEX.8.1]

(LLEX-8-1-1)=
[LLEX.8.1.1] Multi-character operator tokens follow the longest-match rule:
the lexer emits the longest operator string starting at the
current position.

| Precedes | Longer form (emitted if next char matches) |
|---|---|
| `-` | `->` |
| `*` | `**` |
| `/` | `//` |
| `<` | `<=`, `<<` |
| `>` | `>=`, `>>` |
| `=` | `==` |
| `!` | `!=`, `!~` (lone `!` is a lexer error) |
| `:` | `::` |
| `?` | `??` |
| `.` | `..` |
| `"` | `"""` (if followed by two more `"`; else single `"` opens a `SINGLE_STR`) |

*ratified*

(LLEX-8-1-2)=
[LLEX.8.1.2] Example: `a<-b` lexes as `a` `<` `-` `b` (no `<-` token);
`a<=b` lexes as `a` `<=` `b`.

*ratified*

(LLEX-8-1-3)=
[LLEX.8.1.3] [LLEX.8.1.1] holds every longer form. `<`, `>` and `!` each have
two, and the next character selects between them.

*see also:* [LLEX.8.1.1](#LLEX-8-1-1)

(LLEX-8-2)=
### `@` and a lone `=` [LLEX.8.2]

(LLEX-8-2-1)=
- [LLEX.8.2.1] **`@`** is lexed as a single-character token `@` and is
  reserved: any parser production sees it as an error.

*ratified*

(LLEX-8-2-2)=
- [LLEX.8.2.2] **`=`** alone (not followed by `=`) is lexed as `=`, a token
  distinct from `==` ([LGRA.2.10.1]). It is not an operator. It binds a name to
  the expression after it, and only the productions that name it accept it:
  `const_decl` ([LGRA.4.1]), `let_binding` ([LGRA.6.1]), `capture_binding`
  ([LGRA.8.1]), `unit_inline` ([LUNI.4.3]) and `formula_line` ([LUNI.4.5]).
  The compiler must refuse a `=` anywhere else as a parse error.

*see also:* [LGRA.2.10.1](#LGRA-2-10-1), [LGRA.4.1](#LGRA-4-1), [LGRA.6.1](#LGRA-6-1), [LGRA.8.1](#LGRA-8-1), [LUNI.4.3](#LUNI-4-3), [LUNI.4.5](#LUNI-4-5)

(LLEX-8-2-3)=
- [LLEX.8.2.3] **`...`** is rejected by the lexer with
  `"ellipsis not valid in DS"`. Lexing it as an error rather than as
  tokens `.` `.` `.` is what makes the diagnostic nameable.

*ratified*

(LLEX-8-3)=
### Punctuation [LLEX.8.3]

(LLEX-8-3-1)=
[LLEX.8.3.1] Single-character tokens with no longer form:
`+`  `%`  `&`  `|`  `^`  `~`  `(`  `)`  `[`  `]`  `{`  `}`
`,`  `@`

(LLEX-8-3-2)=
[LLEX.8.3.2] Multi-character tokens:
`->`  `**`  `//`  `<<`  `>>`  `==`  `!=`  `!~`  `<=`  `>=`  `::`  `??`  `..`

(LLEX-8-3-3)=
[LLEX.8.3.3] String-literal delimiters:
`"`  `"""`

---

(LLEX-9)=
## Reserved words [LLEX.9]

(LLEX-9-2)=
### BOOL_LIT [LLEX.9.2]

(LLEX-9-2-1)=
[LLEX.9.2.1] `true` and `false` are lexed as a single `BOOL_LIT` token (not
as `NAME`, not as class-1 keywords in their own right).

(LLEX-9-5)=
[LLEX.9.5] An author must not declare an identifier that is a
reserved word, and the compiler must refuse such a declaration. The
reserved words are the rows of [LLEX.9.6], the percentile family and `_`,
below. The restriction binds at
every site an author names something — a slot, a binding, a schema, a
rule, a `const`, a service kwarg, and an `opaque type` — and admits no
position, scope or class in which a reserved word becomes nameable.

A word is reserved as one exact NFC string, so reservation is
case-sensitive on the terms [LNAM.2.1.1] already sets: `where` is
refused, and `Where` and `WHERE` are ordinary identifiers. An author
who meets a reserved word renames; DS supplies no quoted-identifier
form.

**The restriction binds an author's declarations, and nothing else.** A
schema the compiler itself declares may name a slot with a reserved word.
Reading such a slot is a read, not a declaration, so it is admissible in any
position a slot read is.

The percentile aggregations are the one reserved vocabulary that is a
family rather than a set of words. Every `p1` … `p99` is reserved, and
[LLEX.9.6] carries no row for any of them.

The identifier `_` alone is reserved and has no meaning. It is a `NAME`
([LLEX.10.4]), no construct gives it a meaning, and [LLEX.9.6] carries no row for
it. Nothing declares it, so a read of it is a read of an undeclared name.

---

*ratified*  —  *checks:* `alloy×4`  —  *see also:* [LLEX.10.4](#LLEX-10-4), [LLEX.9.6](#LLEX-9-6), [LNAM.2.1.1](#LNAM-2-1-1)

(LLEX-9-6)=
[LLEX.9.6]

| Word             | Reserved by | Class       |
|------------------|-------------|-------------|
| abs              | builtin     |             |
| activated        | grammar     | clause      |
| activation       | grammar     | clause      |
| active_fraction  | aggregation |             |
| after            | grammar     | clause      |
| alias            | grammar     | clause      |
| all_time         | grammar     | clause      |
| ambient          | grammar     | clause      |
| and              | grammar     | operator    |
| as               | grammar     | clause      |
| at               | grammar     | clause      |
| base             | grammar     | clause      |
| Bool             | type        |             |
| bool_and         | aggregation |             |
| bool_or          | aggregation |             |
| by               | grammar     | clause      |
| Bytes            | type        |             |
| cache            | grammar     | action      |
| cache_delete     | grammar     | action      |
| cache_deleted    | grammar     | clause      |
| cached           | grammar     | clause      |
| call             | grammar     | action      |
| called           | grammar     | clause      |
| capacity         | grammar     | clause      |
| ComputationError | type        |             |
| const            | grammar     | declaration |
| contains         | grammar     | operator    |
| cooldown         | grammar     | clause      |
| count            | grammar     | clause      |
| count_distinct   | aggregation |             |
| count_of         | aggregation |             |
| Date             | type        |             |
| default          | grammar     | clause      |
| dimension        | grammar     | clause      |
| direction        | aggregation |             |
| Duration         | type        |             |
| dwell            | alias       |             |
| emit             | grammar     | action      |
| emitted          | grammar     | clause      |
| empty            | grammar     | clause      |
| error            | grammar     | clause      |
| explicit         | grammar     | clause      |
| false            | grammar     | constant    |
| field            | grammar     | clause      |
| filter           | kwarg       |             |
| filter_fields    | grammar     | clause      |
| first            | aggregation |             |
| Float            | type        |             |
| for              | grammar     | clause      |
| formula          | grammar     | clause      |
| from             | grammar     | declaration |
| from_base        | grammar     | clause      |
| fx_pair          | grammar     | clause      |
| gap              | grammar     | clause      |
| has              | grammar     | clause      |
| hold             | grammar     | clause      |
| hydrates         | grammar     | clause      |
| hydration        | grammar     | clause      |
| implicit         | grammar     | clause      |
| import           | grammar     | declaration |
| in               | grammar     | operator    |
| inf              | grammar     | constant    |
| initial          | grammar     | clause      |
| inputs           | grammar     | clause      |
| Int              | type        |             |
| integral         | aggregation |             |
| Interval         | type        |             |
| inverting        | grammar     | clause      |
| is               | grammar     | operator    |
| Json             | type        |             |
| key              | grammar     | clause      |
| kwarg            | grammar     | clause      |
| last             | aggregation |             |
| latest           | grammar     | clause      |
| len              | builtin     |             |
| let              | grammar     | clause      |
| limit            | kwarg       |             |
| literal          | grammar     | clause      |
| log              | grammar     | action      |
| logged           | grammar     | clause      |
| logical          | grammar     | clause      |
| max              | aggregation |             |
| max_limit        | grammar     | clause      |
| max_window       | grammar     | clause      |
| mean             | aggregation |             |
| median           | aggregation |             |
| min              | aggregation |             |
| monotonic_ns     | builtin     |             |
| mutable          | grammar     | clause      |
| nan              | grammar     | constant    |
| NaN              | grammar     | constant    |
| never            | grammar     | clause      |
| no               | grammar     | clause      |
| nocooldown       | kwarg       |             |
| none             | grammar     | clause      |
| not              | grammar     | operator    |
| now              | builtin     |             |
| null             | grammar     | constant    |
| on               | grammar     | clause      |
| onset_rate       | aggregation |             |
| opaque           | grammar     | declaration |
| or               | grammar     | operator    |
| over             | grammar     | clause      |
| overlaps         | grammar     | operator    |
| persist          | grammar     | clause      |
| produces         | grammar     | clause      |
| pstdev           | aggregation |             |
| publish          | grammar     | action      |
| published        | grammar     | clause      |
| pvariance        | aggregation |             |
| rate             | aggregation |             |
| record_event     | grammar     | clause      |
| recorded         | grammar     | clause      |
| required         | grammar     | clause      |
| response         | grammar     | clause      |
| responses        | grammar     | clause      |
| retain           | kwarg       |             |
| retained         | grammar     | clause      |
| retracted        | grammar     | clause      |
| round            | builtin     |             |
| rule             | grammar     | declaration |
| sample           | grammar     | clause      |
| sampled          | grammar     | clause      |
| scalar           | grammar     | clause      |
| Schema           | type        |             |
| schema           | grammar     | declaration |
| scope            | grammar     | clause      |
| series           | grammar     | declaration |
| service          | grammar     | declaration |
| skip             | grammar     | clause      |
| sliding          | grammar     | clause      |
| stdev            | aggregation |             |
| storage          | grammar     | clause      |
| String           | type        |             |
| sum              | aggregation |             |
| test             | grammar     | declaration |
| then             | grammar     | clause      |
| Time             | type        |             |
| timeout          | grammar     | clause      |
| to               | grammar     | clause      |
| to_base          | grammar     | clause      |
| tolerance        | grammar     | clause      |
| true             | grammar     | constant    |
| ttl              | grammar     | clause      |
| tumbling         | grammar     | clause      |
| type             | grammar     | clause      |
| TypeError        | type        |             |
| unit             | grammar     | declaration |
| until            | grammar     | clause      |
| use              | grammar     | declaration |
| value            | kwarg       |             |
| variance         | aggregation |             |
| via              | grammar     | clause      |
| where            | grammar     | clause      |
| withdraw         | grammar     | action      |
| within           | grammar     | clause      |
| wm               | grammar     | clause      |
| zero             | grammar     | clause      |

(LLEX-9-7)=
[LLEX.9.7] **Which code a refusal carries.** [LLEX.9.5] refuses every reserved
word at every naming site with one rule; the diagnostic the compiler reports is
chosen by the word and the site, the first matching row applying:

| Word | Declared as | Code |
|---|---|---|
| `cooldown`, `retain`, `nocooldown` or `as` — a call or emit control-plane modifier | anything | `DS_VALIDATE_RESERVED_META_KWARG` |
| a word [LLEX.9.6] reserves as `type` | a schema, a unit or an `opaque type` | `DS_VALIDATE_RESERVED_TYPE_NAME` |
| a word [LLEX.9.6] reserves as `builtin` | a binding, a `let` or a `const` | `DS_VALIDATE_RESERVED_BUILTIN_NAME` |
| a word [LLEX.9.6] reserves as `aggregation` or `alias`, or any of `p1` … `p99` | a slot | `DS_VALIDATE_COMPANION_SLOT_COLLISION` ([LSER.6.6.1]) |
| any other reserved word | anything | `DS_VALIDATE_HARD_KEYWORD_NAME` |

The modifier row names the four words directly because they are not one class on
[LLEX.9.6]: the engine gives each a meaning at a call or an emit, and a
same-named declaration — a service kwarg above all — would be bound to the
modifier rather than to the author's name.

*ratified*  —  *see also:* [LLEX.9.5](#LLEX-9-5), [LLEX.9.6](#LLEX-9-6), [LSER.6.6.1](#LSER-6-6-1)

(LLEX-9-8)=
[LLEX.9.8] **A grammar word's class.** [LLEX.9.6]'s `Class` column sorts the
words reserved by `grammar` by the role the grammar gives them, and is empty on
every other row. A word's class is the first row of this table that holds for
it:

| Class | The word is |
|---|---|
| `declaration` | the first word of a `use_decl` or a `top_level_decl` alternative ([LGRA.3.1]), or of an import form ([LIMP.2.1.1]) |
| `action` | the first word of an `action_head` ([LGRA.10.1]) |
| `operator` | a word of the expression productions ([LGRA.9.3.1]) |
| `constant` | a word of the `is` subject vocabulary's constants ([LGRA.9.3.3]) |
| `clause` | any other word the grammar reserves |

The class changes nothing about a word's reservation or the code its refusal
carries ([LLEX.9.5], [LLEX.9.7]). It is how a tool that presents DS source
groups the grammar's words.

*see also:* [LGRA.10.1](#LGRA-10-1), [LGRA.3.1](#LGRA-3-1), [LGRA.9.3.1](#LGRA-9-3-1), [LGRA.9.3.3](#LGRA-9-3-3), [LIMP.2.1.1](#LIMP-2-1-1), [LLEX.9.5](#LLEX-9-5), [LLEX.9.6](#LLEX-9-6), [LLEX.9.7](#LLEX-9-7)

(LLEX-10)=
## Identifiers [LLEX.10]

```
LOWER     ::= 'a'..'z'
UPPER     ::= 'A'..'Z'
DIGIT     ::= '0'..'9'

NAME           ::= <XID identifier, NFC-normalized; XID_Start (∪ '_') narrowed
                   by UAX #39 Identifier_Status, then XID_Continue; pinned
                   Unicode version per [LNAM.2.2.5]; realized per [LLEX.10.8]>
TYPE_SYM       ::= <the NAME class plus the non-XID unit glyphs (° ′ ″ % …);
                   type positions only; realized per [LLEX.10.8]>
```

*see also:* [LLEX.10.8](#LLEX-10-8), [LNAM.2.2.5](#LNAM-2-2-5)

(LLEX-10-1)=
- [LLEX.10.1] `NAME` is the single identifier terminal over the XID
  class ([LNAM.2.2]); its role (type reference versus binding) is by grammatical
  position, not case ([LGRA.22]). The lexer NFC-normalizes
  before interning ([LLEX.10.8]).

*see also:* [LGRA.22](#LGRA-22), [LLEX.10.8](#LLEX-10-8), [LNAM.2.2](#LNAM-2-2)

(LLEX-10-2)=
- [LLEX.10.2] `TYPE_SYM` is `NAME` plus the non-XID unit glyphs, lexed only in
  type positions ([LGRA.2.5.3]).

  A run that contains one of [LLEX.12.2]'s unit glyphs, after
  [LLEX.12.2.1]'s normalisation, and is not a legal `NAME` under [LNAM.2.5.1],
  the lexer **must** read as a `TYPE_SYM`, not refuse as an identifier. So `kΩ`
  and `μs` are unit symbols although each mixes Latin with Greek. [LNAM.2.5.1]
  still governs every `NAME`: a `TYPE_SYM` stands only where a type or unit is
  expected and resolves only against declared units, so it binds no name.

*ratified*  —  *see also:* [LGRA.2.5.3](#LGRA-2-5-3), [LLEX.12.2](#LLEX-12-2), [LLEX.12.2.1](#LLEX-12-2-1), [LNAM.2.5.1](#LNAM-2-5-1)

(LLEX-10-4)=
- [LLEX.10.4] Identifiers **cannot** start with a digit. A single leading
  `_` is admitted, as [LLEX.10]'s production writes it, and marks a library
  name internal ([LIMP.9.9]). A `_` alone is a `NAME` too, and is reserved
  ([LLEX.9.5]).

*ratified*  —  *see also:* [LIMP.9.9](#LIMP-9-9), [LLEX.9.5](#LLEX-9-5), [LLEX.10](#LLEX-10)

(LLEX-10-5)=
- [LLEX.10.5] Hyphens are not permitted in identifiers. Multi-word
  identifiers use underscores.

(LLEX-10-6)=
### Synthetic names [LLEX.10.6]

(LLEX-10-6-1)=
[LLEX.10.6.1] **A synthetic name is `$` followed by the name.** Every name the compiler or the engine makes for itself is
spelt this way: a rule, schema or binding the compiler generates ([RLOW.9.1]),
an engine-internal fact (`$ClockTick`, [IRET.19.5]) and a fault's rule name
([LERR.9.11]). `$` is not a `NAME` character ([LLEX.10]), so no author name
equals a synthetic one and no source text writes one: a synthetic name has no
surface form. An author may declare any `NAME`, `__Foo__` included.

*ratified*  —  *see also:* [IRET.19.5](#IRET-19-5), [LERR.9.11](#LERR-9-11), [LLEX.10](#LLEX-10), [RLOW.9.1](#RLOW-9-1)

(LLEX-10-7)=
### No pattern-position lexer mode [LLEX.10.7]

(LLEX-10-7-1)=
[LLEX.10.7.1] **The lexer has no pattern-position mode.** `*` is
unconditionally the multiplication operator and `.<name>` is unconditionally slot
access, so the token stream is context-free — no lexing decision depends on
parser state. An adapter entity is matched by a `where` regex over its identity
slot (`where entity_id ~ /…/`), which needs no lexical mode
([LADP.2]).

*ratified*  —  *see also:* [LADP.2](#LADP-2)

(LLEX-10-8)=
### Unicode identifier realization [LLEX.10.8]

(LLEX-10-8-1)=
[LLEX.10.8.1] **Classification.** `NAME` and `TYPE_SYM` are classified per
codepoint against the pinned Unicode version ([LNAM.2.2.5]): `NAME` against
`XID`, NFC-normalized before interning; `TYPE_SYM` against `XID` ∪ the
non-`XID` unit-glyph set. Keywords retain their contextual priority, so they
win over `NAME` ([LLEX.9]).

*see also:* [LLEX.9](#LLEX-9), [LNAM.2.2.5](#LNAM-2-2-5)

(LLEX-10-8-2)=
[LLEX.10.8.2] **NFC at lex time.** The lexer must NFC-normalize a `NAME` before
interning, comparison, and emission ([LNAM.2.4]); it must not normalize
string-literal content ([LNAM.2.7]). All Unicode work — legality and NFC — is
compile-time; the runtime carries no Unicode tables ([LNAM.2.2.5]).

*see also:* [LNAM.2.2.5](#LNAM-2-2-5), [LNAM.2.4](#LNAM-2-4), [LNAM.2.7](#LNAM-2-7)

(LLEX-10-8-3)=
[LLEX.10.8.3] **State isolation.** The non-`XID` `TYPE_SYM` glyphs must remain
state-restricted to type positions — they must not be lexable in an identifier
state. With the glob mode removed ([LLEX.10.7]), `*` is unconditionally the
multiply operator and `.<name>` unconditionally slot access, so no
parser-state-dependent lexing remains; the implementation must confirm the
`TYPE_SYM`-glyph isolation after the character-class broadening.

*see also:* [LLEX.10.7](#LLEX-10-7)

(LLEX-10-8-4)=
[LLEX.10.8.4] **The single `NAME` terminal is unambiguous at three points**;
[LGRA.22.3] owns the unambiguity guarantee. The pattern head
`type_ref binding?` is decided by the token that follows the head: a `NAME`
begins a binding, a `.` continues a qualified head, and anything else ends the
pattern; the binding is optional ([LGRA.8.6]). The expression `atom` versus
`function_call` split is decided by the following `(` or `.`. The suffix chain
interleaving `slot_suffix` and `cast_suffix` on one atom is decided by the
following `.`, `[` or `::` ([LGRA.9.6]). What a dotted chain denotes is not the
lexer's or the grammar's to decide ([LGRA.22.9]).

*see also:* [LGRA.22.3](#LGRA-22-3), [LGRA.22.9](#LGRA-22-9), [LGRA.8.6](#LGRA-8-6), [LGRA.9.6](#LGRA-9-6)

(LLEX-10-8-5)=
[LLEX.10.8.5] **`??` / `?` munch.** `??` (COALESCE) is a single token by longest-match
([LLEX.17.2]) — it out-munches a would-be `?` (NULLABLE). So `x::Int??d` lexes as
`x :: Int ?? d` and reduces as `(x::Int) ?? d` — a total cast then coalesce, with no
`NULLABLE` on `Int` ([LGRA.9.6], [LCST.4.1.3]). A fallible cast
that then coalesces must separate the target `?` from the `??`: `x::Int? ?? d` →
`(x::Int?) ?? d`. The implementation must verify all three: `x::Int??d` and `x::Int ?? d`
(the same token stream) → `(x::Int) ?? d`, and `x::Int? ?? d` → `(x::Int?) ?? d`.

---

*see also:* [LCST.4.1.3](#LCST-4-1-3), [LGRA.9.6](#LGRA-9-6), [LLEX.17.2](#LLEX-17-2)

(LLEX-11)=
## Numeric literals [LLEX.11]

(LLEX-11-1)=
### Integer (`INT_LIT`) [LLEX.11.1]

```
INT_LIT   ::= DEC_LIT | HEX_LIT | BIN_LIT | OCT_LIT

DEC_LIT   ::= DIGIT ('_'? DIGIT)*
HEX_LIT   ::= '0x' HEX_DIGIT ('_'? HEX_DIGIT)*
BIN_LIT   ::= '0b' BIN_DIGIT ('_'? BIN_DIGIT)*
OCT_LIT   ::= '0o' OCT_DIGIT ('_'? OCT_DIGIT)*

HEX_DIGIT ::= DIGIT | 'a'..'f' | 'A'..'F'
OCT_DIGIT ::= '0'..'7'
BIN_DIGIT ::= '0' | '1'
```

A `_` that a unit suffix follows is the unit `_` of [LLEX.12.1] and ends the
literal. The lexer must refuse any other `_` that these productions and those
of [LLEX.11.2] do not admit: one at the end of a digit run, beside a base
prefix, a decimal point or an exponent marker, or beside another `_`.

*ratified*  —  *checks:* `idris×10`  —  *see also:* [LLEX.11.2](#LLEX-11-2), [LLEX.12.1](#LLEX-12-1)

(LLEX-11-1-5)=
[LLEX.11.1.5] Integer overflow at parse time (literal exceeds 64-bit signed
range) is a lexer error: `"integer literal out of range"`.

*checks:* `idris×2`

(LLEX-11-2)=
### Float (`FLOAT_LIT`) [LLEX.11.2]

```
FLOAT_LIT ::= DEC_LIT '.' DEC_LIT EXPONENT?
           |  DEC_LIT EXPONENT
EXPONENT  ::= ('e' | 'E') ('+' | '-')? DIGIT ('_'? DIGIT)*
```

*ratified*  —  *checks:* `k` `idris×6`

(LLEX-11-2-1)=
- [LLEX.11.2.1] **Both sides of the decimal point are required.** `.5` and
  `5.` are lexer errors.

*checks:* `idris×2`

(LLEX-11-2-2)=
- [LLEX.11.2.2] **Exponent is optional** on the dotted form; required on the
  bare form (to disambiguate from `INT_LIT`).

*ratified*  —  *checks:* `idris×2`

(LLEX-11-2-3)=
- [LLEX.11.2.3] **A based literal is an integer**, so `0x1.8p3` is a lexer
  error by [LLEX.11.2.1]. **A name adjacent to a number is a unit suffix**
  ([LUNI.3.1.4]), so `5L`, `5i32` and `1.0f` are unit literals.

*see also:* [LLEX.11.2.1](#LLEX-11-2-1), [LUNI.3.1.4](#LUNI-3-1-4)

(LLEX-11-2-4)=
- [LLEX.11.2.4] **A float literal past the largest finite `Float` is a lexer
  error.** A `FLOAT_LIT`, and the `DEC_PREFIX` of a `UNIT_LIT`
  ([LLEX.12]), reads as the `Float` nearest its value, ties to even
  ([LDET.3.2.8]). Where that value lies past the largest finite `Float`, so that
  it would round to an infinity, the compiler **must** refuse the literal as a
  lexer error, `"float literal out of range"`, with `DS_PARSE_FLOAT_RANGE`, as
  it refuses an integer literal out of range ([LLEX.11.1.5]). The compiler
  **must not** read such a literal as an infinity, and **must not** saturate it
  to the largest finite `Float`. A literal whose value rounds to zero is that
  zero. An infinity is written `inf` ([LEXP.4.2]).

  So `1.7976931348623157e308` is a literal, and `1.8e308` and `1e400` are lexer
  errors. So is the literal in `-1e400`, since a negative number is unary minus
  applied to a non-negative literal ([LGRA.2.7.6]).

*ratified*  —  *see also:* [LDET.3.2.8](#LDET-3-2-8), [LEXP.4.2](#LEXP-4-2), [LGRA.2.7.6](#LGRA-2-7-6), [LLEX.11.1.5](#LLEX-11-1-5), [LLEX.12](#LLEX-12)

(LLEX-11-3)=
### Numeric adjacency [LLEX.11.3]

(LLEX-11-3-1)=
[LLEX.11.3.1] Resolution order for a numeric literal followed by a
non-space token: **`UNIT_LIT` (numeric prefix, an optional `_`, and a
unit suffix — or a numeric prefix directly followed by an angle glyph
`°`/`′`/`″`) → `FLOAT_LIT` scientific (`Ne…`) → error.**

`COMPLEX_LIT` is **not** a rung in v1. It is the surface syntax of the
`complex` type, which is deferred ([LUNI.14]), so a bare `i`/`j` suffix
reaches no token class at all, and `5i` is refused ([LUNI.14.9]).

A digit directly followed by an alphabetic character **is** a unit
literal: `30s`, `100km` and `30x` each lex as one token. The first two
name known units; `30x` names an unknown one and is an unknown-unit
error, never `30 * x` ([LUNI.3.1.4]).

Since the separator is optional it is not what separates these classes.
What does is the suffix restriction of [LUNI.3.1.5]: a bare `i`/`j`, and
an `e`/`E` followed by digits, are withheld from `UNIT_SUFFIX`. That
withholding is the only reason `1e6` reaches `FLOAT_LIT` at all, and —
with `COMPLEX_LIT` absent from v1 — it is why `5i` and `5_i` alike reach
no token class. The separator changes neither: it is
optional, so it cannot be what tells them apart.

*ratified*  —  *see also:* [LLEX.12.1](#LLEX-12-1), [LUNI.14](#LUNI-14), [LUNI.14.9](#LUNI-14-9), [LUNI.3.1.4](#LUNI-3-1-4), [LUNI.3.1.5](#LUNI-3-1-5)

(LLEX-11-4)=
### Negative numbers [LLEX.11.4]

(LLEX-11-4-1)=
[LLEX.11.4.1] Negative literals are not lexed as a unit — the `-` is a
separate unary-minus operator token applied to a non-negative
literal. `-5` is two tokens: `-` and `5`.

---

(LLEX-12)=
## Unit literals (`UNIT_LIT`) [LLEX.12]

```
UNIT_LIT     ::= DEC_PREFIX '_'? UNIT_SUFFIX       # separator OPTIONAL
DEC_PREFIX   ::= DEC_LIT ('.' DEC_LIT)? EXPONENT?
EXPONENT     ::= ('e' | 'E') ('+' | '-')? DEC_LIT
UNIT_SUFFIX  ::= UNIT_START UNIT_CONT*
UNIT_START   ::= LOWER | UPPER | '°' | '′' | '″' | 'Ω' | 'µ' | 'Å'
UNIT_CONT    ::= LOWER | UPPER | DIGIT | '_' | '°' | '′' | '″' | 'Ω' | 'µ' | 'Å' | 'ₙ'
```

*ratified*

(LLEX-12-1)=
- [LLEX.12.1] **`_` is optional, for every unit** (LUNI.3.1.1). A unit
  literal is `NUM_PREFIX _? UNIT_SUFFIX`: `30_s` and `30s` are one
  token, as are `100_km` / `100km`, `23_°C` / `23°C`, and — `45°` / `45_°`, `30′`, `45″`. The plane-angle
  glyphs are ordinary `UNIT_SUFFIX` characters. Within the numeric prefix, `_` before a digit is a group
  separator (`23_000_m` = `INT_LIT(23000)` then unit `_` then
  `UNIT_SUFFIX(m)`); the separator before the suffix is the unit `_`.

*checks:* `idris×2`  —  *see also:* [LUNI.3.1.1](#LUNI-3-1-1)

(LLEX-12-1-1)=
- [LLEX.12.1.1] **Scientific literals are a distinct token class**
  (LUNI.3.1.5). `1e6` (`FLOAT_LIT` scientific) keeps its spelling, and
  the unit `_` ([LLEX.12.1]) never stands inside it: a `_` within it is a digit
  group separator, between two digits of its mantissa or of its exponent as
  [LLEX.11.2] places it (`1e1_0` = `1e10`); resolution order is §LLEX.11.3.1. Because the `_` is
  **optional** ([LLEX.12.1]), it cannot be what marks a unit, so the
  reservation of `i`/`j`/`e`/`E` as non-unit-names and the `e<digit>`
  shadow exclusion are **load-bearing, not guards** — they are the only
  thing that lets `1e6` reach `FLOAT_LIT` at all ([LLEX.11.3.1]).
  `COMPLEX_LIT` is not a v1 token class ([LUNI.14]), so `5i` is refused
  ([LUNI.14.9]) and `5_i` reaches no token class. A scientific prefix on a unit
  may take the `_`: `1e6_s`, `1.0e3_ms`.

*ratified*  —  *see also:* [LLEX.11.2](#LLEX-11-2), [LLEX.11.3.1](#LLEX-11-3-1), [LLEX.12.1](#LLEX-12-1), [LUNI.14](#LUNI-14), [LUNI.14.9](#LUNI-14-9), [LUNI.3.1.5](#LUNI-3-1-5)

(LLEX-12-2)=
- [LLEX.12.2] **Non-ASCII characters.** `UNIT_SUFFIX` admits seven in
  addition to ASCII letters, digits and `_` (continuation only,
  [LUNI.3.2]): `°` (U+00B0 DEGREE SIGN), `′` (U+2032 PRIME), `″` (U+2033 DOUBLE PRIME), `Ω` (U+03A9 GREEK CAPITAL
  LETTER OMEGA), `µ` (U+00B5 MICRO SIGN), `Å` (U+00C5 — ångström), and
  `ₙ` (U+2099 LATIN SUBSCRIPT SMALL LETTER N — for `gₙ`). No other
  non-ASCII characters are permitted.

  `ₙ` is a **continuation** character only: it may not begin a unit
  symbol ([LUNI.3.2]).

  The three plane-angle glyphs are ordinary suffix characters — there is
  no separate `ANGLE_GLYPH` set and no `attached` class ([LUNI.3.2.1]).
  They remain **Unicode-only**: ASCII `'` and `"` are not aliases for
  `′` and `″`, since `"` is the string delimiter.

*ratified*  —  *see also:* [LUNI.3.2](#LUNI-3-2), [LUNI.3.2.1](#LUNI-3-2-1)

(LLEX-12-2-1)=
- [LLEX.12.2.1] **Unicode confusable normalisation.** The lexer normalises
  known look-alikes before symbol lookup:
  - μ (U+03BC GREEK SMALL LETTER MU) → µ (U+00B5 MICRO SIGN)
  - Ω (U+2126 OHM SIGN) → Ω (U+03A9 GREEK CAPITAL LETTER OMEGA)
  - ʹ (U+02B9 MODIFIER LETTER PRIME) → ′ (U+2032 PRIME); ʺ (U+02BA
    MODIFIER LETTER DOUBLE PRIME) → ″ (U+2033 DOUBLE PRIME)
  All input forms resolve to the same unit/glyph.

(LLEX-12-3)=
- [LLEX.12.3] **`UNIT_SUFFIX` is its own lexical class, not the `NAME` identifier terminal.**
  Case-sensitive. This enables `dB`, `dBm`, `MHz`, `hPa`, `°C`, `Ω`, `µs`.

(LLEX-12-6)=
- [LLEX.12.6] **No whitespace** between the numeric literal and the `_`
  separator. `23 _m` is a parse error.

(LLEX-12-4)=
- [LLEX.12.4] **Negative unit literals.** `-23_c` parses as `-(23_c)`. Unary
  minus applies to the unit-typed value.

(LLEX-12-5)=
- [LLEX.12.5] **`UNIT_SUFFIX` resolution is a name-resolver concern**, not a
  lexer concern. The lexer emits the suffix as an opaque token; the name
  resolver looks up the symbol. See [LUNI.15].

*see also:* [LUNI.15](#LUNI-15)

(LLEX-12-7)=
### Complex literals (`COMPLEX_LIT`) [LLEX.12.7]

`COMPLEX_LIT` is the surface syntax of the `complex` type ([LUNI.14]). A v1
lexer produces no such token, and `5i` is refused ([LUNI.14.9]).

```
COMPLEX_LIT ::= (INT_LIT | FLOAT_LIT | SCI_LIT) ('i' | 'j')
```

*Deferred: not binding in this edition.*

*see also:* [LUNI.14](#LUNI-14), [LUNI.14.9](#LUNI-14-9)

(LLEX-12-7-1)=
- [LLEX.12.7.1] `i` and `j` suffixes produce identical values. The suffix is
  a display-convention choice only; `use_j` is not stored in the value.

(LLEX-12-7-2)=
- [LLEX.12.7.2] `2i` is always `COMPLEX_LIT`: identifiers cannot start with
  a digit, so it cannot be read as a `NAME`.

(LLEX-12-7-3)=
- [LLEX.12.7.3] Display convention is `i` unless a `:i` / `:j` format
  specifier at the interpolation site says otherwise ([LUNI.14.8]).

*see also:* [LUNI.14.8](#LUNI-14-8)

(LLEX-12-8)=
### Duration literals [LLEX.12.8]

Duration values are expressed as `time`-dimensioned `UNIT_LIT` values; the `_` sigil is
**optional** per LUNI.3.1, so `30s` and `30_s` produce the same token:

| Duration | Bare form | With sigil |
|---|---|---|
| 100 milliseconds | `100ms` | `100_ms` |
| 5 seconds | `5s` | `5_s` |
| 1 minute | `1min` (`m` is meters) | `1_min` |
| 2 hours | `2h` | `2_h` |
| 1 day | `1d` | `1_d` |

The bare suffixes `5s` / `100ms` / `2h` / `1d` are valid through the general
`UNIT_LIT` rule. A bare `m` is meters, never minutes: minutes are `min`.

Every construct that takes a duration accepts any
`time`-dimensioned `UNIT_LIT` value (parser-side check; non-time suffixes
emit `DS_VALIDATE_BAD_UNIT_DIMENSION`).

---

*see also:* [LUNI.3.1](#LUNI-3-1)

(LLEX-13)=
## String literals [LLEX.13]

```
STRING_LIT  ::= SINGLE_STR | TRIPLE_STR

SINGLE_STR  ::= '"' SINGLE_CHAR* '"'
SINGLE_CHAR ::= <any UTF-8 char except '"', NEWLINE, or '\'>
             |  '\' ESCAPE_SEQ

TRIPLE_STR  ::= '"""' TRIPLE_CHAR* '"""'
TRIPLE_CHAR ::= <any UTF-8 char except unescaped '"""' or '\'>
             |  '\' ESCAPE_SEQ

ESCAPE_SEQ  ::= '"'  | '\'' | '\' | 'n' | 't' | 'r'
             |  'x' HEX_DIGIT HEX_DIGIT
             |  'u' HEX_DIGIT{4}
             |  'U' HEX_DIGIT{8}
```

(LLEX-13-1)=
### Rules [LLEX.13.1]

(LLEX-13-1-1)=
- [LLEX.13.1.1] **Single-line** (`SINGLE_STR`) strings cannot contain a raw
  newline. Use `\n` or switch to `TRIPLE_STR`.

(LLEX-13-1-2)=
- [LLEX.13.1.2] **Triple-quoted** strings can span multiple lines. The
  opening `"""` and closing `"""` do not themselves count as
  newlines in terms of block structure (the lexer does not
  track indentation inside).

(LLEX-13-1-3)=
- [LLEX.13.1.3] **Unknown escape sequences** (`\q`, `\e`, etc.) are lexer
  errors — no silent pass-through.

(LLEX-13-1-4)=
- [LLEX.13.1.4] **Unterminated strings** (EOF before closing `"` or `"""`)
  are lexer errors.

*ratified*

(LLEX-13-1-5)=
- [LLEX.13.1.5] **`"` is the only string delimiter** ([LGRA.2.9.5]).

*see also:* [LGRA.2.9.5](#LGRA-2-9-5)

(LLEX-13-2)=
### Interpolation sites inside strings [LLEX.13.2]

(LLEX-13-2-1)=
[LLEX.13.2.1] Interpolation sites `{…}` and literal-brace escapes `{{` /
`}}` are **not** lexer concerns. They are parsed in a second
pass over the `STRING_LIT` content by the parser or its
client, per the interpolation sub-grammar in [LGRA.11]. The
lexer treats `{` and `}` inside a string as ordinary
characters. Validation of interpolation syntax happens when the
`STRING_LIT`'s value is consumed in an action-argument
position.

---

*see also:* [LGRA.11](#LGRA-11)

(LLEX-14-2)=
[LLEX.14.2] This division of responsibility keeps the lexer context-free
and keeps contextual-keyword semantics where they make sense —
at the parser and compiler levels.

---

(LLEX-15)=
## Error reporting [LLEX.15]

(LLEX-15-1)=
### Precision [LLEX.15.1]

(LLEX-15-1-1)=
[LLEX.15.1.1] All lexer errors carry **line and column** numbers pointing to
the start of the offending construct. Columns are 1-based;
lines are 1-based.

(LLEX-15-2)=
### Error kinds [LLEX.15.2]

(LLEX-15-2-1)=
[LLEX.15.2.1] Standard lexer errors (non-exhaustive). The first column names the
kind for this table; a compiler's message need not use those words:

| Error kind | Example trigger |
|---|---|
| `lone carriage return` | `\r` not followed by `\n` |
| `inconsistent indentation` | indent not a multiple of 4 (outside bracket groups; see LLEX.6.4, LLEX.7.5.5) |
| `inconsistent dedent` | dedent to a column no enclosing block used |
| `unexpected character` | any character outside the legal alphabet: a `\t`, or U+FEFF anywhere other than offset 0, among them |
| `invalid identifier` | a character glued to a name that [LNAM.2.2] does not admit |
| `ellipsis not valid in DS` | `...` in source |
| `lone '!' is not a valid token` | `!` followed by neither `=` nor `~` |
| `unterminated string literal` | EOF before closing `"` or `"""` |
| `invalid numeric literal` | `0x_FF`, `1_.5`, `42_` |
| `integer literal out of range` | > 2⁶³−1 |
| `unterminated bracket group` | `(`, `[`, or `{` with no match |
| `mismatched bracket` | `)` without matching `(` |

*ratified*  —  *see also:* [LLEX.6.4](#LLEX-6-4), [LLEX.7.5.5](#LLEX-7-5-5), [LNAM.2.2](#LNAM-2-2)

(LLEX-15-3)=
### Recovery [LLEX.15.3]

(LLEX-15-3-1)=
[LLEX.15.3.1] Recovery behaviour is implementation-defined. A reference
implementation may halt at the first error or continue
tokenising after inserting a synthetic marker; the contract is
only that the error is reported with position and kind.

---

(LLEX-17)=
## Lexer commitments [LLEX.17]

(LLEX-17-1)=
- [LLEX.17.1] **Exactly 4-space indent**, tabs rejected, no mixed indent —
  except inside bracket groups, where any indentation is legal
  (LLEX.6.4, LLEX.7.5.5).

*ratified*  —  *see also:* [LLEX.6.4](#LLEX-6-4), [LLEX.7.5.5](#LLEX-7-5-5)

(LLEX-17-2)=
- [LLEX.17.2] **Longest-match tokenisation** for all multi-character
  operators.

*ratified*

(LLEX-17-3)=
- [LLEX.17.3] **Bracket-balanced line continuation** (newlines suppressed
  inside `( )`, `[ ]`, `{ }`).

(LLEX-17-4)=
- [LLEX.17.4] **Blank lines and comments stripped** before the parser sees
  the token stream — including NEWLINE/INDENT/DEDENT
  tracking.
  Restates [LLEX.5].

*ratified*  —  *see also:* [LLEX.5](#LLEX-5)

(LLEX-17-5)=
- [LLEX.17.5] **`...` rejected at the lexer** with a specific error
  message, not as three `.` tokens.

*ratified*

(LLEX-17-6)=
- [LLEX.17.6] **The lexer is context-free** — `*` is always the multiply
  operator and `.<name>` always slot access ([LLEX.10.7]).

*ratified*  —  *see also:* [LLEX.10.7](#LLEX-10-7)

(LLEX-17-8)=
- [LLEX.17.8] **A reserved word that lexes as `NAME` is promoted by
  grammatical position**; the parser and compiler own those positions.
  Which words are reserved is [LLEX.9.5]; recognition is the production's.

*ratified*  —  *see also:* [LLEX.9.5](#LLEX-9-5)

(LLEX-16-3)=
- [LLEX.16.3] **`INDENT` / `DEDENT` / `NEWLINE`** — synthetic tokens
  emitted by the lexer; the parser relies on them for block
  structure.

(LLEX-16-5)=
- [LLEX.16.5] **`;` is not a token.** The lexer must reject it as an
  unexpected character ([LLEX.15.2.1]). A library member is reached with `.`
  ([LGRA.2.10.4]).

*ratified*  —  *see also:* [LGRA.2.10.4](#LGRA-2-10-4), [LLEX.15.2.1](#LLEX-15-2-1)

(LLEX-16-8)=
- [LLEX.16.8] **Interpolation sites** — not lexed at the top level; parsed
  in a second pass over `STRING_LIT` content.

