E0003: unexpected token

View source

The parser reads tokens in the order the grammar allows.

The parser reads tokens in the order the grammar allows. It reports this error when the next token cannot continue the construct it is parsing. The message says what was expected and which token was found, such as expected expression, found ;``. The cause is usually a missing or extra token before the one that is reported.

When the token that was found is the end of the file, the code is E0004 instead.

Example

actus
verb main() {
    erg limit = ;
}
actus
verb main() {
    erg limit = 10
    erg other = 20;
}

Fix

Write the missing part, or remove the extra token. In the first program the binding needs a value. In the second the first statement needs its ;.

actus check --format json offers this as a fix: when the parser expected exactly one of ;, ), ], } or ,, insert it right after the previous token (a safe fix).

actus
verb main() {
    erg limit = 10;
}
actus
verb main() {
    erg limit = 10;
    erg other = 20;
}

Run actus explain E0003 in your terminal to read this entry offline. Browse Lexer & parser or all error codes.