> For the complete documentation index, see [llms.txt](https://guide.cronuszen.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://guide.cronuszen.com/gpcscripting/gpc-script-guide/troubleshooting/compiler-diagnostic-catalog/parser-syntax-errors-gpc2xxx.md).

# Parser syntax errors (GPC2xxx)

All parser diagnostics are **Errors**. Most messages follow the pattern `Expected X after Y got '{token}'.`, where `{token}` is the actual token found. The parser recovers and keeps going after most of these, so one real mistake can produce several follow-on diagnostics — fix the first reported error first.

### GPC2100 — Syntax Error

Representative messages:

```
Expected function name
Expected string value.
```

**Severity:** Error

General/unclassified syntax error used where no more specific code applies: a call target that isn't a name, or a `const string` initializer that isn't a string literal.

***

### GPC2101 — Trailing Comma

```
Trailing comma in array initializer.
Trailing comma in data initializer.
Trailing comma in enum.
```

**Severity:** Error

A comma with nothing after it in a `data(...)` section, const array initializer, or `enum` body.

```c
const int8 vals[] = { 1, 2, 3, };   // GPC2101 — remove the last comma
```

***

### GPC2102 — Expected Expression

```
Expected expression got '{token}'.
Expected expression after '{operator}' got '{token}'.
Expected constant expression. Got '{token}'.
```

**Severity:** Error

The parser needed an expression (after an operator, as a call argument, as a `define` value, in a constant-expression context, etc.) but found something else — often a misplaced `;`, `)`, or keyword.

***

### GPC2103 — Expected Statement

```
Expected a top-level declaration. Got '{token}'.
Expected statement after '}' got '{token}'.
```

**Severity:** Error

A token appears where a statement or declaration must start. At the top level of a script this usually means executable code was written outside of `main`, `init`, a combo, or a function.

***

### GPC2104 — Missing `)`

```
Expected ')' after expression got '{token}'.
```

Also: after arguments, after data values, after while condition, after else if condition, after for clauses, after `(`.

**Severity:** Error

A closing parenthesis is missing in an expression, call, or statement header. Count your parentheses on the reported line.

***

### GPC2105 — Missing `]`

```
Expected ']' after expression got '{token}'.
Expected ']' after array size.
Expected ']' after '['.
Expected ']'.
```

**Severity:** Error

A closing bracket is missing in an array access or array declaration.

***

### GPC2106 — Missing `}`

```
Expected '}' after const array values.
Expected '}' after enum members.
Expected '}' after switch body got '{token}'.
```

And similar.

**Severity:** Error

A closing brace is missing at the end of a const array initializer, enum body, or switch body.

***

### GPC2108 — Unexpected `;`

```
Unexpected ';' at top level.
Expected statement after ';' got ';'.
```

**Severity:** Error

A stray extra semicolon, either at the top level of the script or doubled after a statement.

***

### GPC2109 — Expected `;` Got `)`

```
Expected ';' after expression got ')'.
```

**Severity:** Error

An expression statement is terminated by `)` instead of `;` — usually one closing parenthesis too many. The parser consumes the `)` and continues.

***

### GPC2110 — Expected `;` Got `]`

```
Expected ';' after expression got ']'.
```

**Severity:** Error

Same as GPC2109 but with a stray `]` — usually one closing bracket too many.

***

### GPC2111 — Missing `(`

```
Expected '(' after 'data' got '{token}'.
```

Also: after `addr`, `sizeof`, `switch`, `else if`, `while`, after a function name.

**Severity:** Error

An opening parenthesis is missing after a keyword or function name that requires one.

***

### GPC2112 — Missing `[`

```
Expected '[' after const array name.
Expected '[' before array size.
```

**Severity:** Error

An opening bracket is missing in an array declaration — e.g. `const int8 table = { ... }` instead of `const int8 table[] = { ... }`, or `int arr 5];`.

***

### GPC2113 — Missing `{`

```
Expected '{' before main statements got '{token}'.
```

Also: before init statements, combo statements, fcombo body, function body, const array values/rows, switch body, values, after `enum`.

**Severity:** Error

An opening brace is missing where a block must start. GPC requires braces around `main`, `init`, combo, and function bodies.

***

### GPC2114 — Missing `=`

```
Expected '=' after definition name.
Expected '=' before const array body.
Expected '=' before initializer value.
Expected '=' before const string value.
```

**Severity:** Error

An `=` is missing in a `define`, const array, const string, or variable initializer.

***

### GPC2115 — Missing Identifier

```
Expected definition name.
Expected combo name.
Expected fcombo name.
Expected function name.
Expected const array name.
Expected const string name.
Expected enum member name.
```

**Severity:** Error

A name is missing right after a declaration keyword (`define`, `combo`, `function`, `const`, `enum`, ...). Often caused by using a reserved keyword as a name.

***

### GPC2116 — Missing `,`

```
Expected ',' between values got '{token}'.
Expected ',' after enum member got '{token}'.
Expected ',' between array row blocks got '{token}'.
```

**Severity:** Error

Two items in a list (const array values, enum members, 2D array rows) are not separated by a comma. The parser inserts a virtual separator and keeps parsing.

***

### GPC2117 — Conditional Missing `:`

```
Expected ':' after conditional expression got '{token}'.
```

**Severity:** Error

A conditional expression `condition ? true_value : false_value` is missing its `:`. Both branches are required — the operator has no two-part form.

```c
result = enabled ? 100;      // GPC2117
result = enabled ? 100 : 0;  // OK
```

***

### GPC2120 — Block Missing `}`

```
Expected '}' after block.
```

**Severity:** Error

A statement block (`{ ... }`) is not closed before the file or enclosing construct ends. Almost always an unbalanced brace somewhere above the reported location.

***

### GPC2130 — Const Array Size Not Allowed

```
Const arrays cannot have a size specified in brackets. Use empty brackets [] instead.
```

**Severity:** Error

Const arrays derive their size from the initializer; an explicit size in the brackets is rejected.

```c
const int8 table[3] = { 1, 2, 3 };   // GPC2130
const int8 table[]  = { 1, 2, 3 };   // OK
```

***

### GPC2131 — Invalid Const Array Type

```
Expected const array data type got '{token}'.
```

**Severity:** Error

The keyword after `const` is not a valid const array element type. Valid types include `int8`, `uint8`, `int16`, `uint16`, `int24`, `uint24`, `int32`, `string`, `image`, and `ps5adt`.

***

### GPC2140 — Invalid `data` Brace Syntax

```
Invalid data syntax. Use 'data(value1, value2, ...);' instead of braces.
```

**Severity:** Error

The `data` section was written with braces (`data { ... }` or `data(...) { ... }`) instead of the required parenthesized value list. The parser skips the brace block and continues.

***

### GPC2141 — Empty `data()`

```
data() must contain at least one value.
```

**Severity:** Error

A `data()` section with no values. Unlike const arrays, the data section may not be declared empty — add at least one value or remove the section.

***

### GPC2150 — Expected Variable Name

```
Expected variable name after '{type}' got '{token}'.
```

**Severity:** Error

A type keyword (`int`, `int8`, ...) in a variable declaration is not followed by a valid identifier — e.g. `int 5x;` or `int if;`.

***

### GPC2180 — Function Missing `)`

```
Expected ')' after function parameters got '{token}'.
```

**Severity:** Error

The parameter list of a `function` declaration is not closed with `)` — either the parameter list ran into the end of file, or an unexpected token appears where a parameter or `)` should be.

***

### GPC2181 — Expected Parameter Name

```
Expected parameter name got '{token}'.
```

**Severity:** Error

Something other than an identifier appears in a function's parameter list. GPC parameters are plain names (an optional `int` keyword before a name is tolerated).

***

### GPC2200 — `if` Missing `(`

```
Expected '(' after 'if' got '{token}'.
```

**Severity:** Error

The condition of an `if` statement must be parenthesized.

***

### GPC2201 — `if` Missing `)`

```
Expected ')' after if condition got '{token}'.
```

**Severity:** Error

The closing parenthesis after an `if` condition is missing — check for unbalanced parentheses inside the condition itself.

***

### GPC2202 — `if` Missing `{`

```
Expected '{' after if condition got ')'.
```

**Severity:** Error

An extra `)` appears after an `if` condition where the body should start — one closing parenthesis too many, e.g. `if (a == 1)) {`.

***

### GPC2212 — `else if` Missing `{`

```
Expected '{' after else if condition got ')'.
```

**Severity:** Error

Same as GPC2202, for an `else if` condition: a surplus `)` before the branch body.

***

### GPC2232 — `while` Missing `{`

```
Expected '{' after while condition got ')'.
```

**Severity:** Error

Same pattern for `while`: an extra `)` after the loop condition where the body should start.

***

### GPC2240 — Missing `while` in do-while

```
Expected 'while' after do block.
```

**Severity:** Error

A `do { ... }` block is not followed by the `while` keyword.

***

### GPC2241 — do-while Missing `;`

```
Expected ';' after do-while statement got ')'.
```

**Severity:** Error

An extra `)` appears after the closing parenthesis of a do-while condition, where the terminating `;` belongs: `do { ... } while (x));`.

***

### GPC2250 — `for` Missing `(`

```
Expected '(' after 'for' got '{token}'.
```

**Severity:** Error

The header of a `for` loop must be parenthesized: `for (init; condition; increment)`.

***

### GPC2251 — `for` Missing `;` After Initializer

```
Expected ';' after for loop initializer.
```

**Severity:** Error

The first `;` inside the `for` header is missing.

***

### GPC2252 — `for` Missing `;` After Condition

```
Expected ';' after for loop condition.
```

**Severity:** Error

The second `;` inside the `for` header is missing.

***

### GPC2254 — `for` Missing `{`

```
Expected '{' after for loop header got ')'.
```

**Severity:** Error

An extra `)` appears after the `for` header where the loop body should start.

***

### GPC2255 — Nesting Too Deep

```
Expression or block nesting exceeds the maximum depth of 200.
```

**Severity:** Error

A single expression or nested block of statements is nested more than 200 levels deep (parentheses, nested `if`/`while`/`for`, deeply chained operators, and similar). The limit exists to keep compilation safe — 200 levels is far beyond anything hand-written, so hitting it almost always means generated or accidentally pathological code. Reported once per compile.

The practical fix is to restructure rather than shave off a level or two: move deeply nested inner blocks into user-defined functions (each function body starts its nesting count fresh), and split huge expressions into a few intermediate variable assignments instead of one giant formula.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://guide.cronuszen.com/gpcscripting/gpc-script-guide/troubleshooting/compiler-diagnostic-catalog/parser-syntax-errors-gpc2xxx.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
