Procházet zdrojové kódy

Language plugins 0.1.6 and trilingual tutorial

Eric Streit před 3 dny
rodič
revize
35be2b5c51

+ 69 - 32
TUTORIAL.md

@@ -1,8 +1,15 @@
-# Theia-Modula-2: Short Tutorial
+# Theia Modula-2/Pascal/Oberon: Short Tutorial
 
-Modula-2 Studio is a GNU Modula-2 IDE built on Eclipse Theia (`modula2-ide/`).
+This is a Modula-2, Pascal and Oberon IDE built on Eclipse Theia (`modula2-ide/`).
+All three languages get the same depth: syntax highlighting, snippets,
+auto-uppercasing, outline / hover / go-to-definition / references / rename,
+formatting, Build-Run tasks, GDB debug, and project wizards.
 
-It gives you: `.mod`/`.def` highlighting, snippets, auto-uppercasing, outline / hover / go-to-definition / rename, `gm2` Build-Run, GDB debug, and `modula2.json` projects.
+| Language | Files | Validators | Compiler | Debug type | Project file |
+|---|---|---|---|---|---|
+| Modula-2 | `.mod`/`.def` | Coco/R `gm2` grammar | `gm2` | `modula2` | `modula2.json` |
+| Pascal | `.pas`/`.pp`/`.p` | 8 Coco/R dialects | `fpc`, Blaise | `pascal` | `pascal.json` |
+| Oberon | `.Mod`/`.mod`/`.om` (`.def`/`.od`) | O07, Oberon-2, Ulm | `voc`, `ulmo` | `oberon` | `oberon.json` |
 
 ## 1. Prerequisites
 
@@ -10,10 +17,14 @@ It gives you: `.mod`/`.def` highlighting, snippets, auto-uppercasing, outline /
 node --version  # >=24
 yarn --version  # 1.x Classic
 gm2 --version
+fpc -iV
+voc         # prints its banner; ulmo likewise
 gdb --version
 ```
 
-Debian/Ubuntu: `sudo apt install gm2 gdb binutils`
+Debian/Ubuntu: `sudo apt install gm2 gdb binutils fp-compiler`.
+`voc`/`ulmo` come from their own distributions. Editing features
+(hover, outline, rename, formatting) work without any compiler.
 
 ## 2. Build and run
 
@@ -26,59 +37,85 @@ yarn start:browser   # http://localhost:3000
 yarn start:electron
 ```
 
+Standalone editor plugins (VS Code-compatible) ship as versioned zips:
+`modula2-language-*.zip`, `pascal-language-*.zip`,
+`oberon-language-*.zip`.
+
 ## 3. Open an example
 
-1. Open folder `examples/hello/`
-2. Look at:
-   - `src/Main.mod` — sample program
-   - `modula2.json` — project descriptor:
+| Example | Project file | Main file |
+|---|---|---|
+| `examples/hello/` | `modula2.json` | `src/Main.mod` |
+| `examples/hello-pascal/` | `pascal.json` | `src/Main.pas` |
+| `examples/hello-oberon/` | `oberon.json` | `src/Main.Mod` |
+
+`pascal.json`:
 
 ```json
 {
   "name": "Hello",
-  "compiler": {"type": "gnu-modula-2", "path": "gm2", "options": []},
+  "compiler": {"type": "fpc", "path": "fpc", "options": []},
   "sourceDirectories": ["src"],
-  "main": "src/Main.mod"
+  "main": "src/Main.pas"
 }
 ```
 
-## 4. Edit Modula-2
+`oberon.json` has the same shape with `"type": "voc"` (or `"ulm"`)
+and `"main": "src/Main.Mod"`.
+
+## 4. Edit
 
-- Create `Foo.mod` / `Foo.def`. Keywords auto-uppercase (`begin` -> `BEGIN`, but `beginning` is left alone).
-- Try: hover, `F12` go-to-definition, `Shift+F12` references, `F2` rename, `Ctrl+Shift+O` outline.
-- Snippets: `mod`, `proc`, `if`, `defmod`.
+- Keywords auto-uppercase (`begin` -> `BEGIN`, but `beginning` is left
+  alone). Oberon matching stays case-sensitive; Pascal is
+  case-insensitive.
+- Try: hover, `F12` go-to-definition, `Shift+F12` references, `F2`
+  rename, `Ctrl+Shift+O` outline, `Shift+Alt+F` format.
+- Cross-file jumps work through `USES` (Pascal), `IMPORT` (Oberon,
+  alias-aware) and `IMPORT`/`FROM` (Modula-2 `.def` files).
+- Snippets: Modula-2 `mod`/`proc`/`if`/`defmod`, Pascal
+  `program`/`unit`/`proc`/`func`, Oberon `module`/`proc`/`func`.
 
 Commands (via `F1` / Ctrl+Shift+P):
 
-- `Modula-2: New Modula-2 Project / New Module / New Definition Module`
-- `Modula-2: Validate Project`
-- `Modula-2: About Modula-2 IDE`
+- `Pascal: New Pascal Project / New Unit`, `Oberon: New Oberon Project / New Module`,
+  `Modula-2: New Modula-2 Project / New Module / New Definition Module`
+- `Pascal` / `Oberon` / `Modula-2: Validate Project`, `About`, theme commands
+
+Each language has its own Project explorer view (right-click for
+`New Unit/Module Here`, `Build`, `Refresh`).
 
 ## 5. Build and run
 
-With `modula2.json` open in workspace:
+With the project folder open in the workspace:
 
-- `F1 > Modula-2: Build` — builds `bin/<name>`
-- `Modula-2: Build File / Clean / Rebuild / Run`
-- Or terminal: `gm2 -o bin/Hello src/Main.mod && ./bin/Hello`
+- `F1 > Pascal: Build` — builds `bin/<name>` (`fpc -M<dialect>`,
+  dialect from `modula2.pascal.dialect`, default Free Pascal)
+- `Oberon: Build` — runs `voc` (or `ulmo`) frontend check on the main module
+- `Modula-2: Build` — `gm2 -fiso -g`
+- Each also offers Build File / Clean / Rebuild / Run, or use the terminal:
+  `fpc -o bin/Hello src/Main.pas`, `voc src/Main.Mod`,
+  `gm2 -o bin/Hello src/Main.mod`
 
 Build errors appear in Problems panel, click to jump to source.
 
 ## 6. Debug
 
-1. Build with `Modula-2: Build` (passes `-g` by default, so breakpoints bind).
+1. Build first (passes debug info: `-g`/`-gl`).
 2. Set breakpoint in gutter.
-3. `Run > Start Debugging`, type `modula2`. `program` defaults to `bin/<name>`.
-
-The example `launch.json` sets `"preLaunchTask": "Modula-2: Build"`, so
-debugging always builds first. You get: continue/step over/into/out, call
-stack, Locals + Module scopes, hover/evaluate.
+3. `Run > Start Debugging`, type `pascal`, `oberon` or `modula2`.
+   `program` defaults to `bin/<name>`.
 
-Right-click any file in the Modula-2 Project view for `New Module Here`,
-`Build` and `Refresh` without leaving the explorer.
+The example `launch.json` files set `"preLaunchTask": "<Lang>: Build"`,
+so debugging always builds first. You get: continue/step over/into/out,
+call stack, Locals + Module scopes, hover/evaluate.
 
 ## 7. Troubleshooting
 
-- Language features missing: check `plugins/modula2-language/` was synced by `yarn build:language`.
-- `gm2 not found`: set `"compiler": {"path": "/usr/bin/gm2"}` in `modula2.json`.
-- Debug `program not found`: run `Modula-2: Build` first.
+- Language features missing: check `plugins/<lang>-language/` was synced
+  by `yarn build:language`.
+- No validator diagnostics: set `modula2.pascal.validators` /
+  `modula2.oberon.validators` to the pilot binaries built by each
+  `grammars/*/build.sh`. Unconfigured dialects stay silent by design.
+- `fpc`/`voc` not found: set `"compiler": {"path": ...}` in
+  `pascal.json` / `oberon.json` (or the `*.compiler.path` preference).
+- Debug `program not found`: run `<Lang>: Build` first.

+ 13 - 0
examples/hello-oberon/.vscode/launch.json

@@ -0,0 +1,13 @@
+{
+  "version": "0.2.0",
+  "configurations": [
+    {
+      "type": "oberon",
+      "request": "launch",
+      "name": "Debug Hello",
+      "program": "${workspaceFolder}/bin/Hello",
+      "cwd": "${workspaceFolder}",
+      "preLaunchTask": "Oberon: Build"
+    }
+  ]
+}

+ 6 - 0
examples/hello-oberon/oberon.json

@@ -0,0 +1,6 @@
+{
+  "name": "Hello",
+  "compiler": {"type": "voc", "path": "voc", "options": []},
+  "sourceDirectories": ["src"],
+  "main": "src/Main.Mod"
+}

+ 19 - 0
examples/hello-oberon/src/Main.Mod

@@ -0,0 +1,19 @@
+MODULE Main;
+
+IMPORT Out;
+
+VAR
+  count: INTEGER;
+
+PROCEDURE Next(n: INTEGER): INTEGER;
+BEGIN
+  RETURN n + 1
+END Next;
+
+BEGIN
+  count := 0;
+  WHILE count < 3 DO
+    Out.String("Hello, Oberon!"); Out.Ln;
+    count := Next(count)
+  END
+END Main.

+ 13 - 0
examples/hello-pascal/.vscode/launch.json

@@ -0,0 +1,13 @@
+{
+  "version": "0.2.0",
+  "configurations": [
+    {
+      "type": "pascal",
+      "request": "launch",
+      "name": "Debug Hello",
+      "program": "${workspaceFolder}/bin/Hello",
+      "cwd": "${workspaceFolder}",
+      "preLaunchTask": "Pascal: Build"
+    }
+  ]
+}

+ 6 - 0
examples/hello-pascal/pascal.json

@@ -0,0 +1,6 @@
+{
+  "name": "Hello",
+  "compiler": {"type": "fpc", "path": "fpc", "options": []},
+  "sourceDirectories": ["src"],
+  "main": "src/Main.pas"
+}

+ 18 - 0
examples/hello-pascal/src/Main.pas

@@ -0,0 +1,18 @@
+PROGRAM Main;
+
+VAR
+  count: INTEGER;
+
+FUNCTION Next(n: INTEGER): INTEGER;
+BEGIN
+  Next := n + 1;
+END;
+
+BEGIN
+  count := 0;
+  WHILE count < 3 DO
+  BEGIN
+    WriteLn('Hello, Pascal!');
+    count := Next(count);
+  END;
+END.

+ 0 - 1
examples/hello/.vscode/launch.json

@@ -1,7 +1,6 @@
 {
   "version": "0.2.0",
   "configurations": [
-    modula2
     {
       "type": "modula2",
       "request": "launch",

+ 28 - 14
extensions/oberon-language/COCOR-LSP.md

@@ -1,17 +1,18 @@
-# Coco/R diagnostics through LSP
+# Oberon language services (LSP)
 
-Version 0.1.7 adds the first real Language Server connection. The Theia/VS
-Code extension starts `out/server.js` through `vscode-languageclient`; the
-server invokes a configured executable containing the **generated Coco/R
-parser/validator**.
+The Theia/VS Code extension starts `out/server.js` through
+`vscode-languageclient`. Two diagnostic sources merge on every edit:
 
-## Oberon dialects (`.Mod` / `.mod` / `.def`, Ulmo `.om` / `.od`)
+1. **Coco/R dialect validators** (external, per-dialect executables).
+2. **Local analysis** — header/`END`-name checks plus a lenient
+   declaration parser driving all navigation features below.
 
-The server validates Oberon files with the pilot validators from
-`grammars/`. Each pilot binary takes the source file as its single
-argument and writes a `.LST` listing next to it; the server parses the
-listing's `***** ^ message` lines (positions are caret-relative to the
-code after the listing prefix, zero-based columns).
+## Oberon dialects (`.Mod` / `.mod` / `.def`, Ulm `.om` / `.od`)
+
+Each pilot binary takes the source file as its single argument and
+writes a `.LST` listing next to it; the server parses the listing's
+`***** ^ message` lines (positions are caret-relative to the code
+after the listing prefix, zero-based columns).
 
 ```json
 "modula2.oberon.dialect": "oberon2",
@@ -23,6 +24,19 @@ code after the listing prefix, zero-based columns).
 ```
 
 Build each binary first with its pilot `build.sh` (needs `CR` and
-`gm2 -fiso`). The local Modula-2 analysis never runs on Oberon text.
-With no command configured for the active dialect the server publishes
-no diagnostics.
+`gm2 -fiso`). With no command configured for the active dialect the
+server publishes no validator diagnostics.
+
+## Local intelligence (always on, no compiler needed)
+
+- Outline (modules, routines incl. type-bound receivers, params,
+  record fields with `*`/`-` export marks)
+- Completion (`.`-triggered: imported module names alias-aware,
+  record fields, visible declarations, keywords, predefined routines)
+- Hover, go-to-definition, references, rename — incl. `M.Name`
+  resolution through `IMPORT` (same-directory `.Mod`/`.mod`/`.def`/
+  `.om`/`.od`) and go-to-module on `IMPORT` names; matching is
+  case-sensitive, like Oberon itself
+- Full + range formatting (`modula2.oberon.format.*`; export marks
+  stay attached), semantic tokens, snippets, uppercase-while-typing
+  (`modula2.oberon.uppercaseKeywords`)

+ 1 - 1
extensions/oberon-language/package.json

@@ -1,7 +1,7 @@
 {
   "name": "oberon-language",
   "displayName": "Oberon Language Support",
-  "version": "0.1.5",
+  "version": "0.1.6",
   "publisher": "modula2",
   "license": "MIT",
   "engines": {

+ 27 - 14
extensions/pascal-language/COCOR-LSP.md

@@ -1,17 +1,18 @@
-# Coco/R diagnostics through LSP
+# Pascal language services (LSP)
 
-Version 0.1.7 adds the first real Language Server connection. The Theia/VS
-Code extension starts `out/server.js` through `vscode-languageclient`; the
-server invokes a configured executable containing the **generated Coco/R
-parser/validator**.
+The Theia/VS Code extension starts `out/server.js` through
+`vscode-languageclient`. Two diagnostic sources merge on every edit:
+
+1. **Coco/R dialect validators** (external, per-dialect executables).
+2. **Local analysis** — header/`END` checks plus a lenient
+   declaration parser driving all navigation features below.
 
 ## Pascal dialects (`.pas` / `.pp` / `.p`)
 
-The same server validates Pascal files with the pilot validators from
-`grammars/`. Each pilot binary takes the source file as its single
-argument and writes a `.LST` listing next to it; the server parses the
-listing's `***** ^ message` lines (positions are caret-relative to the
-code after the listing prefix, zero-based columns).
+Each pilot binary takes the source file as its single argument and
+writes a `.LST` listing next to it; the server parses the listing's
+`***** ^ message` lines (positions are caret-relative to the code
+after the listing prefix, zero-based columns).
 
 ```json
 "modula2.pascal.dialect": "freepascal",
@@ -28,7 +29,19 @@ code after the listing prefix, zero-based columns).
 ```
 
 Build each binary first with its pilot `build.sh` (needs `CR` and
-`gm2 -fiso`). The local Modula-2 analysis never runs on Pascal text.
-With no command configured for the active dialect the server publishes
-no diagnostics. Never point these at the `pcom`/`psc` oracle compilers
-— they can hang on invalid input.
+`gm2 -fiso`). With no command configured for the active dialect the
+server publishes no validator diagnostics. Never point these at the
+`pcom`/`psc` oracle compilers — they can hang on invalid input.
+
+## Local intelligence (always on, no compiler needed)
+
+- Outline (`parsePascal`: programs, units, routines, params, locals,
+  record fields, enum literals)
+- Completion (`.`-triggered: unit interface names, record fields,
+  visible declarations, keywords, predefined routines)
+- Hover, go-to-definition, references, rename — incl. `Unit.Name`
+  resolution through `USES` (same-directory `.pas`/`.pp`/`.p`) and
+  go-to-unit on `USES` names; matching is case-insensitive
+- Full + range formatting (`modula2.pascal.format.*`), semantic
+  tokens, snippets, uppercase-while-typing
+  (`modula2.pascal.uppercaseKeywords`)

+ 1 - 1
extensions/pascal-language/package.json

@@ -1,7 +1,7 @@
 {
   "name": "pascal-language",
   "displayName": "Pascal Language Support",
-  "version": "0.1.5",
+  "version": "0.1.6",
   "publisher": "modula2",
   "license": "MIT",
   "engines": {

binární
oberon-language-0.1.5.zip


binární
oberon-language-0.1.6.zip


binární
pascal-language-0.1.5.zip


binární
pascal-language-0.1.6.zip