# Error Codes

Severity is either `error` or `warning`.

## Input limits

| Code | Severity | Meaning | Example |
| --- | --- | --- | --- |
| G001 | error | Input file exceeds 64 MiB limit | Huge file |
| G002 | error | Command count exceeds 1,000,000 | Extremely large command stream |
| G103 | error | Command exceeds configured size limit | Oversized word/extended block |

## Scanner

| Code | Severity | Meaning | Example |
| --- | --- | --- | --- |
| G101 | error | Unterminated word command | `G01` without `*` |
| G102 | error | Unterminated extended block | `%MOMM*` without closing `%` |

## MO

| Code | Severity | Meaning | Example |
| --- | --- | --- | --- |
| G110 | error | Missing unit statement | No `%MOMM*%` / `%MOIN*%` |
| G111 | error | Duplicate unit statement | Two MO commands |
| G112 | error | Unit statement after first operation | MO after D01/D02/D03 |
| G113 | error | Malformed unit statement | `%MOXX*%` |

## FS

| Code | Severity | Meaning | Example |
| --- | --- | --- | --- |
| G120 | error | Missing format specification | No FS |
| G121 | error | Duplicate format specification | Two FS commands |
| G122 | error | Format specification after first operation | FS after D01/D02/D03 |
| G123 | error | Malformed format specification | `%FSLAX46Y36*%` |
| G124 | error | Unsupported or deprecated format variant | `%FSTA...*%` / `%FSLI...*%` |

## EOF

| Code | Severity | Meaning | Example |
| --- | --- | --- | --- |
| G130 | error | Missing M02 | File ends without `M02*` |
| G131 | error | Data after M02 | Commands after `M02*` |
| G132 | error | Duplicate M02 | Second `M02*` |

## Aperture

| Code | Severity | Meaning | Example |
| --- | --- | --- | --- |
| G201 | error | Undefined aperture | `D15*` before definition |
| G202 | error | Duplicate aperture | `%ADD10...*%` twice |
| G203 | error | Invalid aperture code | `D9*` |
| G204 | error | Malformed aperture definition | Broken AD/AM header |
| G205 | error | Undefined aperture macro | `%ADD10UNKNOWN,0.2*%` |
| G206 | error | Missing current aperture | D01/D03 outside region without Dnn |

## Operation

| Code | Severity | Meaning | Example |
| --- | --- | --- | --- |
| G210 | error | Malformed operation | `Y100X200D01*` |
| G211 | error | Draw without valid current point | D01 before D02 establishes point |
| G212 | error | Draw without plot mode | D01 without G01/G02/G03 |
| G213 | error | Circular draw before G75 | G02/G03 D01 without G75 |
| G214 | error | I/J used in linear mode | I/J with G01 |
| G215 | error | Circular draw missing I or J | Arc D01 without both offsets |
| G216 | error | Coordinate exceeds FS precision | Too many digits for FS |
| G217 | error | Current point cannot be resolved | First `X100D02*` without Y |

## Region

| Code | Severity | Meaning | Example |
| --- | --- | --- | --- |
| G220 | error | Nested region | G36 while region open |
| G221 | error | Region end without active region | Orphan G37 |
| G222 | error | Unclosed region | G36 without G37 |
| G223 | error | Disallowed command inside a region | D03/AD/TF inside G36..G37 |

## Attribute

| Code | Severity | Meaning | Example |
| --- | --- | --- | --- |
| G230 | error | FileFunction outside header | TF.FileFunction after first operation |
| G231 | error | Duplicate file attribute | Same TF name twice |

## Warnings

| Code | Severity | Meaning | Example |
| --- | --- | --- | --- |
| G301 | warning | Missing X2 FileFunction | No `%TF.FileFunction...*%` |
| G302 | warning | Unsupported command | `%SR...*%` |
| G303 | warning | Aperture macro geometry not analyzed | `%AM...*%` |
| G304 | warning | Deprecated syntax not supported | `G01X100Y100D01*` |
| G305 | warning | Region geometry not verified | Any G36 region |
| G306 | warning | Arc geometry not verified | Circular D01 |
