Update manuals and other additions
This commit is contained in:
@@ -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
|
||||
Reference in New Issue
Block a user