From abf74c587442cc26ef0cf0605bf84e6dcdf7be7d Mon Sep 17 00:00:00 2001 From: Luis <42945842+ldiaz94@users.noreply.github.com> Date: Sat, 10 Oct 2026 03:51:49 +0000 Subject: [PATCH] Approve the report Per-target files of a module must export the same interface, and the compiler checks it. The plan gains its two limits: under 5,000 lines, and at least 400,000 lines of jed compiled a second. --- diff --git a/PLAN.md b/PLAN.md index adf2166..e1da5a0 100644 --- a/PLAN.md +++ b/PLAN.md @@ -3,7 +3,7 @@ jed (Polish *jeden*, one) is a small systems language in Wirth's tradition: full control of memory, volatile access, atomics, calls into C, generic modules. Its compiler is meant to be read in a long weekend: -about 4,500 lines of Free Pascal, one pass, no IR, no optimizer, writing +about 4,550 lines of Free Pascal, one pass, no IR, no optimizer, writing x86-64 machine code and the ELF file itself. The language is defined by `doc/jed.md`. Where this plan and the report @@ -14,6 +14,10 @@ - The compiler is Free Pascal 3.2.2, `{$mode objfpc}{$H-}`: records, pointers, shortstrings. No classes, ansistrings, exceptions, dynamic arrays or SysUtils. +- The compiler stays under 5,000 lines, and compiles at least 400,000 + lines of jed a second, from reading the sources to writing the + executable. `make bench` measures it, and a step that breaks either + limit isn't done. - Clarity over cleverness. Every unit opens with a header comment: what it is, what it depends on, what it leaves out. Comments say why, and what wherever a layout or encoding isn't obvious. @@ -52,7 +56,7 @@ | File | Lines | What | |---|---|---| | `src/scan.pas` | ~430 | Symbols, literals, comments, error messages | -| `src/sym.pas` | ~390 | Types, objects, scopes, layout | +| `src/sym.pas` | ~450 | Types, objects, scopes, layout | | `src/x64.pas` | ~400 | Code buffer, chunks, fixups, instruction encoder | | `src/gen.pas` | ~660 | Items: loading, storing, copying, frames, calls | | `src/parse.pas` | ~1,900 | Declarations, statements, expressions, built-ins | @@ -64,7 +68,7 @@ Stage 1: the core -- [ ] 1. Language report, `doc/jed.md`. Reviewed and approved before +- [x] 1. Language report, `doc/jed.md`. Reviewed and approved before any more code. - [ ] 2. Scanner and symbol table, `scan.pas` and `sym.pas` (drafts exist), brought in line with the report; they compile. @@ -76,7 +80,7 @@ modules and `extern`. - [ ] 6. `lib/Rt.jed`, `lib/Out.jed`; examples (hello, args, variants and slices, volatile); `make check` runs them against expected - output. + output; `make bench` times the compiler on generated jed. Stage 2: allocation, results, generics diff --git a/doc/jed.md b/doc/jed.md index e55fc2f..12580ba 100644 --- a/doc/jed.md +++ b/doc/jed.md @@ -137,9 +137,26 @@ first of `Name.OS-ARCH.jed`, `Name.OS.jed`, `Name.ARCH.jed` and `Name.jed` that exists, where `OS-ARCH` is the target, for now only `linux-x86_64`. So a module whose code depends on the machine or the -system comes in one file per target, each with the same exports, and -the modules that import it don't change. Machine code (section 8) and -system calls belong in such files. +system comes in one file per target, and the modules that import it +don't change. Machine code (section 8) and system calls belong in such +files. + +The compiler holds every file of such a module to the same interface. +When it takes one of `Name.*.jed`, it also reads the declarations of +the others beside it, and of `Name.jed` if there is one, and reports an +error unless they all export the same names, each the same kind of +thing: + +- a constant of the same type (its value may differ: a system call + number, say); +- a type of the same kind, and for a record or variant the same + exported fields and cases, with the same types (unexported fields, + and so the size and layout, may differ); +- a variable of the same type; +- a procedure of the same signature. + +Two types here are the same if they are built alike, a name in one file +standing for the same name in another. **Module bodies.** A module may end with `begin` and statements, its body. Every module's body runs once, before the main module's `main`: