Update manuals and other additions
This commit is contained in:
@@ -6,17 +6,17 @@
|
||||
|
||||
## Overview
|
||||
|
||||
The `protel` driver reports errors in three phases: **parse**, **type check**, and **compile**. Error examples live under `examples/errors/`.
|
||||
The **`Pc`** driver reports errors in three phases: **parse**, **type check**, and **compile**. Error examples live under `examples/errors/`.
|
||||
|
||||
```bash
|
||||
./protel examples/errors/err_assign_integer_to_char.protel
|
||||
./Pc examples/errors/err_assign_integer_to_char.P
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 1. Parse errors
|
||||
|
||||
**Prefix:** `protel: parse error in '<file>':`
|
||||
**Prefix:** `Pc: parse error in '<file>':`
|
||||
|
||||
The Lark parser rejects invalid syntax before transpilation.
|
||||
|
||||
@@ -41,23 +41,23 @@ DCL demo PROC() IS
|
||||
|
||||
## 2. Type errors (strong typing)
|
||||
|
||||
**Prefix:** `protel: type error in '<file>':`
|
||||
**Prefix:** `Pc: type error in '<file>':`
|
||||
|
||||
PROTEL 2026 enforces Reference Manual §11.3 compatibility at transpile time. Wide **integer** values cannot be stored in **char**, **PACK** byte fields, or **BOOL** without an explicit **CAST**.
|
||||
|
||||
| Message | Meaning | Example file |
|
||||
|---------|---------|--------------|
|
||||
| `cannot assign integer to char in …` | A variable or expression typed **integer** is assigned to **char {0 TO 255}** | `examples/errors/err_assign_integer_to_char.protel` |
|
||||
| `cannot assign wide integer to packed byte-sized type {…} PACK(n) in …` | **integer** assigned to a **PACK** subrange | `examples/errors/err_assign_integer_to_packed_byte.protel` |
|
||||
| `cannot assign integer to BOOL in …` | Numeric value assigned to **BOOL** | `examples/errors/err_assign_integer_to_bool.protel` |
|
||||
| `value L..H is out of range for {A TO B} in …` | Numeric literal exceeds destination subrange | `examples/errors/err_constant_out_of_range.protel` |
|
||||
| `cannot assign PTR TO T1 to PTR TO T2 in …` | Pointer pointee types differ | `examples/errors/err_assign_incompatible_pointer.protel` |
|
||||
| `RETURN type T1 is not compatible with RETURNS T2 in procedure 'P'` | **RETURN** expression does not match **RETURNS** type | `examples/errors/err_return_type_mismatch.protel` |
|
||||
| `cannot assign integer to char in …` | A variable or expression typed **integer** is assigned to **char {0 TO 255}** | `examples/errors/err_assign_integer_to_char.P` |
|
||||
| `cannot assign wide integer to packed byte-sized type {…} PACK(n) in …` | **integer** assigned to a **PACK** subrange | `examples/errors/err_assign_integer_to_packed_byte.P` |
|
||||
| `cannot assign integer to BOOL in …` | Numeric value assigned to **BOOL** | `examples/errors/err_assign_integer_to_bool.P` |
|
||||
| `value L..H is out of range for {A TO B} in …` | Numeric literal exceeds destination subrange | `examples/errors/err_constant_out_of_range.P` |
|
||||
| `cannot assign PTR TO T1 to PTR TO T2 in …` | Pointer pointee types differ | `examples/errors/err_assign_incompatible_pointer.P` |
|
||||
| `RETURN type T1 is not compatible with RETURNS T2 in procedure 'P'` | **RETURN** expression does not match **RETURNS** type | `examples/errors/err_return_type_mismatch.P` |
|
||||
| `procedure 'P' cannot RETURN a value` | **RETURN** with value in a `PROC()` without **RETURNS** | — |
|
||||
| `procedure 'P' must RETURN T` | Missing **RETURN** in a **RETURNS** procedure | — |
|
||||
| `unknown identifier 'x' in …` | Assignment to an undeclared name | — |
|
||||
|
||||
**Valid contrast:** `examples/errors/ok_assign_char_literal.protel` assigns literal `65` to **char** (within `{0 TO 255}`).
|
||||
**Valid contrast:** `examples/errors/ok_assign_char_literal.P` assigns literal `65` to **char** (within `{0 TO 255}`).
|
||||
|
||||
### Strong typing rules (summary)
|
||||
|
||||
@@ -71,7 +71,7 @@ PROTEL 2026 enforces Reference Manual §11.3 compatibility at transpile time. Wi
|
||||
|
||||
## 3. Transpile errors
|
||||
|
||||
**Prefix:** `protel: transpile error in '<file>':`
|
||||
**Prefix:** `Pc: transpile error in '<file>':`
|
||||
|
||||
Structural or linkage problems in the transpiler (not type compatibility).
|
||||
|
||||
@@ -90,22 +90,22 @@ Structural or linkage problems in the transpiler (not type compatibility).
|
||||
|
||||
| Message | Cause |
|
||||
|---------|-------|
|
||||
| `protel: cannot read '<file>': …` | Missing or unreadable source path |
|
||||
| `protel: cannot write '<file>': …` | Output path not writable |
|
||||
| `protel: '<file>' is not a PROTEL source file` | Unrecognized extension |
|
||||
| `protel: warning: only the first source file is compiled` | Multiple inputs on command line |
|
||||
| `Pc: cannot read '<file>': …` | Missing or unreadable source path |
|
||||
| `Pc: cannot write '<file>': …` | Output path not writable |
|
||||
| `Pc: '<file>' is not a PROTEL source file` | Unrecognized extension |
|
||||
| `Pc: warning: only the first source file is compiled` | Multiple inputs on command line |
|
||||
|
||||
---
|
||||
|
||||
## 5. Compile and link errors
|
||||
|
||||
**Prefix:** `protel: compile error:`
|
||||
**Prefix:** `Pc: compile error:`
|
||||
|
||||
Emitted when GCC/clang++ rejects generated C++. Often caused by invalid generated code or missing runtime symbols.
|
||||
|
||||
| Underlying message | Typical fix |
|
||||
|--------------------|-------------|
|
||||
| `undefined reference to 'writeln'` | Link without `protel_io.c` (use default `protel` compile, not raw `g++` on `.cpp` alone) |
|
||||
| `undefined reference to 'writeln'` | Link without `protel_io.c` (use default `Pc` compile, not raw `g++` on `.cpp` alone) |
|
||||
| `functions that differ only in their return type` | Duplicate ENTRY/forward signatures (report as transpile bug) |
|
||||
| `no C++ compiler found` | Install `g++`, `clang++`, or `c++` on `PATH` |
|
||||
|
||||
@@ -115,7 +115,7 @@ Emitted when GCC/clang++ rejects generated C++. Often caused by invalid generate
|
||||
|
||||
| Message | Cause |
|
||||
|---------|-------|
|
||||
| `protel: warning: call to P uses a PROTEL string without an explicit NUL (0) suffix` | **EXTERNAL** call with string missing `, 0` in char tuple |
|
||||
| `Pc: warning: call to P uses a PROTEL string without an explicit NUL (0) suffix` | **EXTERNAL** call with string missing `, 0` in char tuple |
|
||||
|
||||
---
|
||||
|
||||
@@ -123,4 +123,4 @@ Emitted when GCC/clang++ rejects generated C++. Often caused by invalid generate
|
||||
|
||||
- Reference Manual §11.0–§11.3 — type compatibility
|
||||
- `examples/errors/` — intentional error and OK contrast programs
|
||||
- Introductory Manual §7.0 — `protel` driver usage
|
||||
- Introductory Manual §7.0 — **`Pc`** driver usage
|
||||
Reference in New Issue
Block a user