Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

02: Parsing

E0201

Expected a different token. The parser found a token where the grammar doesn’t allow one: a missing operand, a missing : or = after a signature, a declaration inside a function, a return outside a function in a notebook cell, and so on. The message says what was expected.

dim H = * 2

See Grammar.

E0202

Unexpected indentation. A line is indented more than the line before it, where no block starts. Only the line after a : that ends a fn, for, if, else or model line, or after a devices line, starts an indented block; to continue an expression on the next line, put it in brackets or start the line with |>.

fn f(x: [n]) -> [n]:
    return x
        extra

See Lines and indentation.

E0203

Pattern outside a pattern operation. A pattern (... -> ...) can only be an argument to rearrange, reduce, repeat, einsum or split.

fn f(x: [n D]) = softmax(x, n D -> D n)

See Expressions and Pattern operations.

E0204

Invalid pipe stage. A pipe stage must be a function name, a call, or to T. Since a stage is parsed like an operand of or, x |> f + 1 makes f + 1 the stage. Wrap the pipeline in parentheses to use its result: (x |> f) + 1, (x |> f) as T.

fn f(x: [n]) = x |> relu + 1

See Pipes and Operator precedence.

E0205

Misused _. _ can only be an argument of a call that is a pipe stage, and only once per stage.

fn f(x: [n]) = add(_, x)

See Pipes.

E0206

Chained comparison. Comparisons don’t chain: a < b < c isn’t a < b and b < c. Write that instead.

fn f(x: [n]) = 0.0 < x < 1.0

See Operator precedence.

E0207

Expected a declaration. At the top level of a file there can only be devices, dim, domain, fn, extern fn, import python and model. Statements belong inside a function, except in a notebook cell.

x = 1

See Files and items.

E0208

Integer too large. An integer literal is larger than 18446744073709551615 (2^64 − 1).

dim D = 99999999999999999999

See Tokens.

W0201

Doc comment not attached to a declaration. A ## comment documents the declaration on the line directly below it. This one has none: it is followed by a blank line or a statement, or it is at the end of a line of code. Move it, or use # for an ordinary comment.

## The model width.

dim D = 768

See Comments and doc comments.