Update manuals and other additions
This commit is contained in:
@@ -48,14 +48,14 @@ int main(int argc, char** argv) {
|
||||
|
||||
When the ENTRY body does not **RETURNS integer**, the wrapper calls the procedure and returns `0`.
|
||||
|
||||
### Example: `examples/intro_5_5_2_args_exit.protel`
|
||||
### Example: `examples/intro_5_5_2_args_exit.P`
|
||||
|
||||
This module prints each command-line argument (including the program name) and **RETURN**s `argc` as the exit status.
|
||||
|
||||
Build and run:
|
||||
|
||||
```bash
|
||||
./protel examples/intro_5_5_2_args_exit.protel -o build/ArgsExit --run -- one two
|
||||
./Pc examples/intro_5_5_2_args_exit.P -o build/ArgsExit --run -- one two
|
||||
echo $?
|
||||
```
|
||||
|
||||
@@ -77,6 +77,6 @@ Command-line demonstration uses **EXTERNAL** C linkage to the minimal POSIX runt
|
||||
|
||||
### See also
|
||||
|
||||
- §7.0 — **PROTEL 2026 Development Tools** (`protel` driver, `--run`)
|
||||
- §7.0.5 — **Runnable `.protel` files (shebang)** — direct execution with `#!/usr/bin/env protel-run`
|
||||
- §7.0 — **PROTEL 2026 Development Tools** (`Pc` compiler, `--run`)
|
||||
- §7.0.5 — **Runnable `.P` files (shebang)** — direct execution with `#!/usr/bin/env Pc!`
|
||||
- Reference Manual §13 — **EXPORT** / **EXTERNAL** (ENTRY vs library procedures)
|
||||
@@ -10,9 +10,55 @@ The PROTEL 2026 toolchain ships with a small set of command-line and editor tool
|
||||
|
||||
| Tool | Section | Summary |
|
||||
|------|---------|---------|
|
||||
| **`protel`** | §7.1 | Parser, transpiler, and compiler driver |
|
||||
| **`Pc`** | §7.1 | **PROTEL compiler** — parser, transpiler, and GCC/clang++ driver |
|
||||
| **`Pc!`** | §7.0.5 | **Shebang runner** — pronounced *"P c Bang"*; runs `.P` files from `#!` lines or the shell |
|
||||
| **`Pb`** | §7.0.1 | Source beautifier (keyword uppercasing) |
|
||||
| **`protel-mode`** | §7.2 | GNU Emacs major mode for `.protel`, `.pt`, `.ptl`, legacy `.P`, and PLS `.AA01`–`.ZZ99` files |
|
||||
| **`protel-mode`** | §7.2 | GNU Emacs major mode for `.P`, `.protel`, `.pt`, `.ptl`, and PLS `.AA01`–`.ZZ99` files |
|
||||
|
||||
---
|
||||
|
||||
## 7.0.0 Source file extensions
|
||||
|
||||
**`.P`** is the default suffix for PROTEL 2026 sources (historical Nortel/BNR convention). The **`Pc`** compiler and parser **do not require** any particular extension — you may name a module `myprog.P`, `myprog.protel`, `myprog.pt`, or even `myprog.txt` if you wish.
|
||||
|
||||
Recognized suffixes (`.P`, `.protel`, `.pt`, `.ptl`, and PLS `.AA01`–`.ZZ99`) enable Emacs **`protel-mode`** auto-detection and suppress the optional extension warning from **`Pc`**. Unrecognized suffixes still compile when the file contains valid PROTEL source.
|
||||
|
||||
---
|
||||
|
||||
## 7.0.0.1 System-wide installation
|
||||
|
||||
For a host-wide install (macOS or UNIX/Linux), use **`make install-system`**. The default layout is:
|
||||
|
||||
| Path | Contents |
|
||||
|------|----------|
|
||||
| **`/usr/local/protel/`** | Toolkit root — `Pc`, `Pc!`, `Pb`, `src/`, `examples/`, `emacs/`, `.venv/` |
|
||||
| **`/usr/local/bin/`** | Symlinks to `Pc`, `Pb`, and `Pc!` in the toolkit root |
|
||||
| **`/usr/local/share/man/man1/`** | Manual pages `Pc.1` and `Pb.1` |
|
||||
|
||||
```bash
|
||||
sudo make install-system
|
||||
Pc /usr/local/protel/examples/Hello.P --run
|
||||
man Pc
|
||||
```
|
||||
|
||||
`/usr/local/bin` is normally already on **`PATH`**, so shebang lines (`#!/usr/bin/env Pc!`) work without extra setup once **`Pc!`** is on the path.
|
||||
|
||||
Override locations for packaging or non-default prefixes:
|
||||
|
||||
```bash
|
||||
sudo make install-system SYSPREFIX=/opt/protel SYSBINDIR=/opt/bin
|
||||
sudo make install-system DESTDIR=/tmp/stage SYSPREFIX=/usr/local/protel
|
||||
```
|
||||
|
||||
Remove a system install:
|
||||
|
||||
```bash
|
||||
sudo make uninstall-system
|
||||
```
|
||||
|
||||
### Local (checkout) installation
|
||||
|
||||
From a source tree, **`make install`** prepares the repository for development: marks tools executable, creates a local **`.venv`**, and installs manual pages under **`./man/man1/`** (set **`MANPATH=$PWD/man:$MANPATH`** to read them).
|
||||
|
||||
---
|
||||
|
||||
@@ -21,11 +67,11 @@ The PROTEL 2026 toolchain ships with a small set of command-line and editor tool
|
||||
`Pb` uppercases PROTEL reserved keywords for readable, manual-style source. It is a filter-style tool:
|
||||
|
||||
```bash
|
||||
Pb examples/Hello.protel build/Hello.pretty.protel
|
||||
Pb --bold < myprog.protel > myprog.pretty.protel
|
||||
Pb examples/Hello.P build/Hello.pretty.P
|
||||
Pb --bold < myprog.P > myprog.pretty.P
|
||||
```
|
||||
|
||||
Install with `make install` (marks `Pb` executable). See `Pb --help` for options.
|
||||
Install with `make install` (checkout) or `sudo make install-system` (host-wide). See `Pb --help` and `man Pb`.
|
||||
|
||||
In Emacs, run Pb on the current buffer with **`C-c C-f`** (`M-x protel-beautify`) — see Introductory Manual §7.2.
|
||||
|
||||
@@ -33,10 +79,10 @@ In Emacs, run Pb on the current buffer with **`C-c C-f`** (`M-x protel-beautify`
|
||||
|
||||
## 7.0.2 PLS edition modules (`.AA01` … `.ZZ99`)
|
||||
|
||||
Historical DMS/PLS modules use edition suffixes such as `vdi.aa01`. The `protel` driver **automatically enables classical preprocessing** for these names (keyword normalization, `$LI` / `$EJECT` linker directives stripped before parse).
|
||||
Historical DMS/PLS modules use edition suffixes such as `vdi.aa01`. The `Pc` compiler **automatically enables classical preprocessing** for these names (keyword normalization, `$LI` / `$EJECT` linker directives stripped before parse).
|
||||
|
||||
```bash
|
||||
protel vdi.aa01 -c -o build/vdi.aa01.o
|
||||
Pc vdi.aa01 -c -o build/vdi.aa01.o
|
||||
make vdi
|
||||
```
|
||||
|
||||
@@ -47,75 +93,89 @@ make vdi
|
||||
The transpiler performs **strong typing** checks (Reference Manual §11.3). Invalid assignments — such as storing an **integer** into **char** or a **PACK** byte — are rejected before code generation. See `docs/reference-error-messages.md` and `examples/errors/`.
|
||||
|
||||
```bash
|
||||
./protel examples/errors/err_assign_integer_to_char.protel
|
||||
./protel examples/errors/ok_assign_char_literal.protel -o build/ok_char
|
||||
./Pc examples/errors/err_assign_integer_to_char.P
|
||||
./Pc examples/errors/ok_assign_char_literal.P -o build/ok_char
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 7.0.4 UNIX command line and exit status
|
||||
|
||||
Standalone programs may read **`argc`** and **`argv`** in the **IS ENTRY** procedure and **RETURN** an integer exit status to the shell. See Introductory Manual §5.5.2 (`docs/intro-5-5-2-entry-args-exit.md`) and `examples/intro_5_5_2_args_exit.protel`.
|
||||
Standalone programs may read **`argc`** and **`argv`** in the **IS ENTRY** procedure and **RETURN** an integer exit status to the shell. See Introductory Manual §5.5.2 (`docs/intro-5-5-2-entry-args-exit.md`) and `examples/intro_5_5_2_args_exit.P`.
|
||||
|
||||
```bash
|
||||
./protel examples/intro_5_5_2_args_exit.protel -o build/ArgsExit --run -- one two
|
||||
./Pc examples/intro_5_5_2_args_exit.P -o build/ArgsExit --run -- one two
|
||||
echo $?
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 7.0.5 Runnable `.protel` files (shebang)
|
||||
## 7.0.5 Runnable `.P` files (shebang)
|
||||
|
||||
A PROTEL source file may be executed directly from the shell when:
|
||||
|
||||
1. **Line 1** is a UNIX shebang (`#!...`) naming **`protel-run`** (or `protel --run` via `env -S`).
|
||||
1. **Line 1** is a UNIX shebang (`#!...`) naming **`Pc!`** (or `Pc --run` via `env -S`).
|
||||
2. The file is **executable** (`chmod +x`).
|
||||
3. The PROTEL project directory is on your **`PATH`** so `protel-run` (or `protel`) is found.
|
||||
3. **`Pc!`** (or `Pc`) is on your **`PATH`** — automatic after **`make install-system`** (`/usr/local/bin`); for a checkout, add the project directory to **`PATH`**.
|
||||
|
||||
The shebang is **not** PROTEL syntax. The preprocessor removes it before parse; **`Pb`** preserves it unchanged when beautifying.
|
||||
|
||||
`examples/Hello.protel` demonstrates the usual form:
|
||||
`examples/Hello.P` demonstrates the usual form:
|
||||
|
||||
```protel
|
||||
#!/usr/bin/env protel-run
|
||||
% Hello World — run with: ./Hello.protel
|
||||
#!/usr/bin/env Pc!
|
||||
% Hello World — run with: ./Hello.P
|
||||
SECTION Hello;
|
||||
...
|
||||
```
|
||||
|
||||
**`protel-run`** is a small helper in the project root. The kernel runs `protel-run /path/to/script.protel [args]`; the helper invokes `protel script.protel --run -- [args]`.
|
||||
**`Pc!`** (pronounced *"P c Bang"*) is a small helper in the project root. The exclamation mark echoes the **`#!`** *shebang* convention and doubles as a memorable command-line shortcut for running PROTEL programs. The kernel runs `Pc! /path/to/script.P [args]`; the helper invokes `Pc script.P --run -- [args]`.
|
||||
|
||||
You can also invoke **`Pc!`** directly from the shell (with the project directory on **`PATH`**):
|
||||
|
||||
```bash
|
||||
Pc! examples/Hello.P
|
||||
Pc! examples/intro_5_5_2_args_exit.P one two
|
||||
```
|
||||
|
||||
### Setup
|
||||
|
||||
From the PROTEL project directory:
|
||||
**System-wide** (after `sudo make install-system`):
|
||||
|
||||
```bash
|
||||
Pc! /usr/local/protel/examples/Hello.P
|
||||
/usr/local/protel/examples/Hello.P # if executable
|
||||
```
|
||||
|
||||
**From a source checkout**:
|
||||
|
||||
```bash
|
||||
make install
|
||||
export PATH="$PWD:$PATH"
|
||||
./examples/Hello.protel
|
||||
./examples/Hello.P
|
||||
```
|
||||
|
||||
From any directory (replace with your checkout path):
|
||||
|
||||
```bash
|
||||
export PATH="$HOME/PROTEL:$PATH"
|
||||
~/PROTEL/examples/Hello.protel
|
||||
~/PROTEL/examples/Hello.P
|
||||
```
|
||||
|
||||
`make install` marks `protel`, `protel-run`, `Pb`, and `examples/Hello.protel` executable.
|
||||
`make install` marks `Pc`, `Pc!`, `Pb`, and `examples/Hello.P` executable in the tree. `make install-system` installs the same tools under **`/usr/local/protel`** with symlinks in **`/usr/local/bin`**.
|
||||
|
||||
**PATH pitfall:** `export PATH="~/PROTEL:$PATH"` does **not** work — the shell does not expand `~` inside double quotes, so `env` cannot find `protel-run`. Use **`$PWD`**, **`$HOME/PROTEL`**, or an absolute path instead.
|
||||
**PATH pitfall:** `export PATH="~/PROTEL:$PATH"` does **not** work — the shell does not expand `~` inside double quotes, so `env` cannot find **`Pc!`**. Use **`$PWD`**, **`$HOME/PROTEL`**, or an absolute path instead.
|
||||
|
||||
### ENTRY programs with arguments
|
||||
|
||||
Add the same shebang to programs such as `examples/intro_5_5_2_args_exit.protel`, then:
|
||||
Add the same shebang to programs such as `examples/intro_5_5_2_args_exit.P`, then:
|
||||
|
||||
```bash
|
||||
chmod +x examples/intro_5_5_2_args_exit.protel
|
||||
./examples/intro_5_5_2_args_exit.protel one two
|
||||
chmod +x examples/intro_5_5_2_args_exit.P
|
||||
./examples/intro_5_5_2_args_exit.P one two
|
||||
```
|
||||
|
||||
The kernel invokes `protel --run -- script.protel one two`. The driver promotes the script path from after **`--`** to the input positional, then forwards **`one`** and **`two`** to the ENTRY procedure.
|
||||
The kernel invokes `Pc --run -- script.P one two`. The driver promotes the script path from after **`--`** to the input positional, then forwards **`one`** and **`two`** to the ENTRY procedure.
|
||||
|
||||
### Notes
|
||||
|
||||
@@ -125,8 +185,8 @@ The kernel invokes `protel --run -- script.protel one two`. The driver promotes
|
||||
| **`Pb`** | Copies line 1 unchanged when it begins with `#!` |
|
||||
| **`protel-mode`** | Displays the shebang line with `protel-comment-face` (§7.2) |
|
||||
| **Parser** | `strip_shebang()` in `src/preprocess.py` runs before keyword normalization |
|
||||
| **Output binary** | Default `a.out` in the current working directory (same as `protel … --run`) |
|
||||
| `env: protel: No such file or directory` | **`PATH` wrong** — avoid quoted `~/PROTEL`; use `export PATH="$PWD:$PATH"` from the repo or `export PATH="$HOME/PROTEL:$PATH"` |
|
||||
| **Output binary** | Default `a.out` in the current working directory (same as `Pc … --run`) |
|
||||
| `env: Pc!: No such file or directory` | **`PATH` wrong** — avoid quoted `~/PROTEL`; use `export PATH="$PWD:$PATH"` from the repo or `export PATH="$HOME/PROTEL:$PATH"` |
|
||||
|
||||
---
|
||||
|
||||
@@ -134,6 +194,6 @@ The kernel invokes `protel --run -- script.protel one two`. The driver promotes
|
||||
|
||||
- §11.3 — **Type errors** (`docs/reference-error-messages.md`)
|
||||
- §5.5.2 — **UNIX argc/argv and shell exit status**
|
||||
- §7.0.5 — **Runnable `.protel` files (shebang)**
|
||||
- §7.2 — **EMACS PROTEL mode** (`.emacs` setup; automatic `.protel`, `.P`, and PLS suffix detection)
|
||||
- §7.0.5 — **Runnable `.P` files (shebang)**
|
||||
- §7.2 — **EMACS PROTEL mode** (`.emacs` setup; automatic `.P`, `.protel`, and PLS suffix detection)
|
||||
- §7.3 — Foreign language interoperability
|
||||
@@ -33,7 +33,7 @@ Edit the copy once and set your checkout path (required when the file is not ins
|
||||
(setq protel-user-root "/path/to/PROTEL")
|
||||
```
|
||||
|
||||
The project `.emacs` also searches, in order: `PROTEL_ROOT` environment variable, the directory containing this init file (if it still lives inside PROTEL), the `protel` executable on your `PATH`, then `~/PROTEL`.
|
||||
The project `.emacs` also searches, in order: `PROTEL_ROOT` environment variable, the directory containing this init file (if it still lives inside PROTEL), the `Pc` executable on your `PATH` (including `/usr/local/bin` after `make install-system`), then `~/PROTEL` and `/usr/local/protel`.
|
||||
|
||||
**Option B — load from the project directory**
|
||||
|
||||
@@ -48,10 +48,10 @@ After Emacs loads this block, `protel-mode` is available and **file-name detecti
|
||||
|
||||
| Extension | Mode started |
|
||||
|-----------|--------------|
|
||||
| `.P` | `protel-mode` (default PROTEL 2026 suffix; historical Nortel/BNR) |
|
||||
| `.protel` | `protel-mode` |
|
||||
| `.pt` | `protel-mode` |
|
||||
| `.ptl` | `protel-mode` |
|
||||
| `.P` | `protel-mode` (legacy Nortel/BNR suffix; case-sensitive match) |
|
||||
| `.AA01` … `.ZZ99` | `protel-mode` (PLS edition suffix: two letters + two digits) |
|
||||
|
||||
The PLS pattern matches any extension of the form **`.LLNN`** where `L` is a letter (`A`–`Z` or `a`–`z`) and `N` is a decimal digit. Examples: `vdi.aa01`, `module.AB18`, `Hello.aa01`.
|
||||
@@ -79,7 +79,7 @@ Then in `.emacs`:
|
||||
## 7.2.2 Verifying automatic detection
|
||||
|
||||
1. Restart Emacs (or evaluate the `.emacs` block with `M-x eval-buffer`).
|
||||
2. Open a PROTEL source file, for example `examples/Hello.protel`, legacy `examples/Hello.P`, or PLS `examples/Hello.aa01`.
|
||||
2. Open a PROTEL source file, for example `examples/Hello.P` or PLS `examples/Hello.aa01`.
|
||||
3. Confirm the mode line shows **`PROTEL`** (not `Fundamental`).
|
||||
4. Alternatively, run `M-x describe-mode` — it should report `protel-mode`.
|
||||
|
||||
@@ -191,13 +191,13 @@ Example:
|
||||
From the PROTEL project directory:
|
||||
|
||||
```bash
|
||||
emacs -nw -l .emacs examples/Hello.protel
|
||||
emacs -nw -l .emacs examples/Hello.P
|
||||
```
|
||||
|
||||
On Linux with a separate nox build:
|
||||
|
||||
```bash
|
||||
emacs-nox -l /path/to/PROTEL/.emacs /path/to/PROTEL/examples/Hello.protel
|
||||
emacs-nox -l /path/to/PROTEL/.emacs /path/to/PROTEL/examples/Hello.P
|
||||
```
|
||||
|
||||
Ensure **Font Lock** is on (`M-x font-lock-mode` or `(global-font-lock-mode 1)` in `.emacs`, already set in the project file). If keywords are not bold, verify your terminal profile allows bold text (Terminal.app: Settings → Profiles → Text → “Use bold fonts”).
|
||||
@@ -215,7 +215,7 @@ Ensure **Font Lock** is on (`M-x font-lock-mode` or `(global-font-lock-mode 1)`
|
||||
|
||||
| Tool | Manual section | Purpose |
|
||||
|------|----------------|---------|
|
||||
| `protel` | §7.1 | Transpile and compile PROTEL sources |
|
||||
| `Pc` | §7.1 | Transpile and compile PROTEL sources |
|
||||
| `Pb` | §7.0 | Beautify / uppercase keywords |
|
||||
| `protel-mode` | §7.2 (this section) | Emacs editing support |
|
||||
|
||||
@@ -228,9 +228,9 @@ For foreign-language linking from PROTEL, see §7.3.
|
||||
| Symptom | Likely cause | Remedy |
|
||||
|---------|--------------|--------|
|
||||
| `Cannot open load file: protel-mode` | `load-path` does not include `emacs/` | In `~/.emacs`, set `(setq protel-user-root "/path/to/PROTEL")` |
|
||||
| `PROTEL mode not loaded` warning at startup | Copied `~/.emacs` without checkout path | Set `protel-user-root` in `~/.emacs`, or add PROTEL `protel` to `PATH` |
|
||||
| `PROTEL mode not loaded` warning at startup | Copied `~/.emacs` without checkout path | Set `protel-user-root` in `~/.emacs`, or add PROTEL `Pc` to `PATH` |
|
||||
| `Cannot find Pb` on beautify | Pb not on PATH | Set `protel-root` or `protel-beautify-command` after mode loads |
|
||||
| Buffer stays in `Fundamental` mode | `protel-mode` not loaded, or wrong extension | Add `(require 'protel-mode)`; use `.protel`, `.P`, `.AA01`-style PLS suffix, or `M-x protel-mode` |
|
||||
| Buffer stays in `Fundamental` mode | `protel-mode` not loaded, or wrong extension | Add `(require 'protel-mode)`; use `.P`, `.protel`, `.AA01`-style PLS suffix, or `M-x protel-mode` |
|
||||
| No keyword highlighting | Font-lock not enabled | `M-x font-lock-mode` (normally on by default) |
|
||||
| `Cannot open load file: cc-mode` | Incomplete Emacs install | Use a full GNU Emacs build, not a minimal editor |
|
||||
| No bold in Terminal | Terminal profile disables bold | Enable bold fonts in Terminal.app / iTerm; `protel-keyword-face` uses `:weight bold` |
|
||||
|
||||
@@ -101,7 +101,7 @@ DCL Start PROC() IS
|
||||
### Step 4 — Build and link
|
||||
|
||||
```bash
|
||||
protel myprog.protel --keep -o build/myprog.cpp
|
||||
Pc myprog.P --keep -o build/myprog.cpp
|
||||
clang++ -std=c++20 -c build/myprog.cpp -o build/myprog.o
|
||||
rustc --crate-type staticlib rust_greet.rs -o build/librust_greet.a
|
||||
clang++ build/myprog.o build/librust_greet.a src/runtime/protel_io.c -o myprog
|
||||
@@ -185,7 +185,7 @@ Compile the EXPORT module and a thin **JNI** bridge into `libjavacallsprotel.dyl
|
||||
### Step 4 — Link
|
||||
|
||||
```bash
|
||||
protel protel_for_rust.protel --keep -o build/protel_for_rust.cpp
|
||||
Pc protel_for_rust.P --keep -o build/protel_for_rust.cpp
|
||||
clang++ -std=c++20 -c build/protel_for_rust.cpp -o build/protel_for_rust.o
|
||||
rustc rust_calls_protel.rs build/protel_for_rust.o -o rust_calls_protel
|
||||
```
|
||||
@@ -193,7 +193,7 @@ rustc rust_calls_protel.rs build/protel_for_rust.o -o rust_calls_protel
|
||||
**Python** (shared library + ctypes):
|
||||
|
||||
```bash
|
||||
protel protel_for_python.protel --keep -o build/protel_for_python.cpp
|
||||
Pc protel_for_python.P --keep -o build/protel_for_python.cpp
|
||||
clang++ -std=c++20 -fPIC -c build/protel_for_python.cpp -o build/protel_for_python.o
|
||||
clang++ -shared -o build/libprotel_for_python.so build/protel_for_python.o
|
||||
python3 examples/interop/python_calls_protel.py
|
||||
@@ -202,7 +202,7 @@ python3 examples/interop/python_calls_protel.py
|
||||
**Java** (shared library + JNI):
|
||||
|
||||
```bash
|
||||
protel protel_for_java.protel --keep -o build/protel_for_java.cpp
|
||||
Pc protel_for_java.P --keep -o build/protel_for_java.cpp
|
||||
clang++ -std=c++20 -fPIC -c build/protel_for_java.cpp -o build/protel_for_java.o
|
||||
clang -fPIC -c java_calls_protel.c -o build/java_calls_protel.o -I$JAVA_HOME/include
|
||||
clang++ -shared -o build/libjavacallsprotel.so build/protel_for_java.o build/java_calls_protel.o
|
||||
@@ -215,7 +215,7 @@ java -Djava.library.path=build/interop -cp build/interop JavaCallsProtel
|
||||
|
||||
### PROTEL calls Rust
|
||||
|
||||
File: `examples/interop/protel_calls_rust.protel`
|
||||
File: `examples/interop/protel_calls_rust.P`
|
||||
|
||||
```
|
||||
SECTION protel_calls_rust;
|
||||
@@ -237,7 +237,7 @@ DCL Start PROC() IS
|
||||
|
||||
### PROTEL calls Python
|
||||
|
||||
File: `examples/interop/protel_calls_python.protel`
|
||||
File: `examples/interop/protel_calls_python.P`
|
||||
|
||||
```
|
||||
SECTION protel_calls_python;
|
||||
@@ -259,7 +259,7 @@ DCL Start PROC() IS
|
||||
|
||||
### Rust calls PROTEL
|
||||
|
||||
File: `examples/interop/protel_for_rust.protel` (same EXPORT library as Swift example)
|
||||
File: `examples/interop/protel_for_rust.P` (same EXPORT library as Swift example)
|
||||
|
||||
```
|
||||
INTERFACE protel_math;
|
||||
@@ -276,7 +276,7 @@ DCL protel_add PROC(a integer, b integer) RETURNS integer IS
|
||||
|
||||
### PROTEL calls Java
|
||||
|
||||
File: `examples/interop/protel_calls_java.protel`
|
||||
File: `examples/interop/protel_calls_java.P`
|
||||
|
||||
```
|
||||
SECTION protel_calls_java;
|
||||
@@ -298,11 +298,11 @@ DCL Start PROC() IS
|
||||
|
||||
### Python calls PROTEL
|
||||
|
||||
File: `examples/interop/python_calls_protel.py` loads `protel_for_python.protel` as a shared library via **ctypes**.
|
||||
File: `examples/interop/python_calls_protel.py` loads `protel_for_python.P` as a shared library via **ctypes**.
|
||||
|
||||
### Java calls PROTEL
|
||||
|
||||
File: `examples/interop/JavaCallsProtel.java` loads `protel_for_java.protel` via **JNI** (`java_calls_protel.c` bridge).
|
||||
File: `examples/interop/JavaCallsProtel.java` loads `protel_for_java.P` via **JNI** (`java_calls_protel.c` bridge).
|
||||
|
||||
---
|
||||
|
||||
@@ -320,14 +320,14 @@ A single module may have **one ENTRY** and **many EXPORT** procedures.
|
||||
|
||||
| Task | PROTEL | Build driver |
|
||||
|------|--------|--------------|
|
||||
| Hello World (PROTEL only) | `protel Hello.protel --run` | `protel` + `clang++` |
|
||||
| Hello World (direct shebang) | `./examples/Hello.protel` | §7.0.5 — `export PATH="$PWD:$PATH"`, file executable |
|
||||
| Hello World (PROTEL only) | `Pc Hello.P --run` | `Pc` + `clang++` |
|
||||
| Hello World (direct shebang) | `./examples/Hello.P` | §7.0.5 — `export PATH="$PWD:$PATH"`, file executable |
|
||||
| PROTEL + Swift | `make interop-swift` | `examples/interop/build_interop.sh` |
|
||||
| PROTEL + Rust | `make interop-rust` | `examples/interop/build_interop_rust.sh` |
|
||||
| PROTEL + Python | `make interop-python` | `examples/interop/build_interop_python.sh` |
|
||||
| PROTEL + Java | `make interop-java` | `examples/interop/build_interop_java.sh` |
|
||||
| Edit `.protel` / `.P` / PLS `.AA01` in Emacs | Add `emacs/` to `load-path`, `(require 'protel-mode)` | See §7.2 |
|
||||
| Beautify source | `Pb file.protel` | `Pb` |
|
||||
| Edit `.P` / `.P` / PLS `.AA01` in Emacs | Add `emacs/` to `load-path`, `(require 'protel-mode)` | See §7.2 |
|
||||
| Beautify source | `Pb file.P` | `Pb` |
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -145,7 +145,7 @@ extern "C" {
|
||||
|
||||
## Linking
|
||||
|
||||
1. Transpile PROTEL to `.cpp` with the PROTEL 2026 compiler (`protel`).
|
||||
1. Transpile PROTEL to `.cpp` with the PROTEL 2026 compiler (`Pc`).
|
||||
|
||||
2. Compile generated C++ with `g++` or `clang++` (`-std=c++20`).
|
||||
|
||||
|
||||
@@ -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