| | @@ -3,7 +3,7 @@ |
| 3 | 3 | jed (Polish *jeden*, one) is a small systems language in Wirth's |
| 4 | 4 | tradition: full control of memory, volatile access, atomics, calls into |
| 5 | 5 | C, generic modules. Its compiler is meant to be read in a long weekend: |
| 6 | | -about 4,550 lines of Free Pascal, one pass, no IR, no optimizer, writing |
| 6 | +under 5,000 lines of Free Pascal, one pass, no IR, no optimizer, writing |
| 7 | 7 | x86-64 machine code and the ELF file itself. |
| 8 | 8 | |
| 9 | 9 | The language is defined by `doc/jed.md`. Where this plan and the report |
| | @@ -53,17 +53,20 @@ |
| 53 | 53 | is a library. |
| 54 | 54 | |
| 55 | 55 | ## The compiler, in reading order |
| 56 | + |
| 57 | +Lines after stage 1, all of them and those of code (neither blank nor |
| 58 | +only comment), as `make loc` counts them: |
| 56 | 59 | |
| 57 | | -| File | Lines | What | |
| 58 | | -|---|---|---| |
| 59 | | -| `src/scan.pas` | ~430 | Symbols, literals, comments, error messages | |
| 60 | | -| `src/sym.pas` | ~450 | Types, objects, scopes, layout | |
| 61 | | -| `src/x64.pas` | ~400 | Code buffer, chunks, fixups, instruction encoder | |
| 62 | | -| `src/gen.pas` | ~660 | Items: loading, storing, copying, frames, calls | |
| 63 | | -| `src/parse.pas` | ~1,900 | Declarations, statements, expressions, built-ins | |
| 64 | | -| `src/link.pas` | ~200 | Tree shaking, layout, patching | |
| 65 | | -| `src/elf.pas` | ~450 | Static and dynamic ELF, symbol table | |
| 66 | | -| `src/jed.pas` | ~115 | The command line | |
| 60 | +| File | Lines | Code | What | |
| 61 | +|---|---|---|---| |
| 62 | +| `src/scan.pas` | 548 | 471 | Symbols, literals, comments, error messages | |
| 63 | +| `src/sym.pas` | 452 | 380 | Types, objects, scopes, layout | |
| 64 | +| `src/x64.pas` | 613 | 491 | Code buffer, chunks, fixups, instruction encoder | |
| 65 | +| `src/gen.pas` | 1,177 | 1,035 | Items: loading, storing, copying, frames, calls | |
| 66 | +| `src/parse.pas` | 1,370 | 1,265 | Declarations, statements, expressions, built-ins | |
| 67 | +| `src/link.pas` | 123 | 92 | Tree shaking, layout, patching | |
| 68 | +| `src/elf.pas` | 185 | 147 | Static ELF, symbol table | |
| 69 | +| `src/jed.pas` | 113 | 85 | The command line, the entry point | |
| 67 | 70 | |
| 68 | 71 | ## Steps |
| 69 | 72 | |
| | @@ -71,17 +74,17 @@ |
| 71 | 74 | |
| 72 | 75 | - [x] 1. Language report, `doc/jed.md`. Reviewed and approved before |
| 73 | 76 | any more code. |
| 74 | | -- [ ] 2. Scanner and symbol table, `scan.pas` and `sym.pas`, written |
| 77 | +- [x] 2. Scanner and symbol table, `scan.pas` and `sym.pas`, written |
| 75 | 78 | against the report; they compile. |
| 76 | | -- [ ] 3. Machine code, `x64.pas`. |
| 77 | | -- [ ] 4. Linking and output, `link.pas` and `elf.pas`: tree shaking, |
| 79 | +- [x] 3. Machine code, `x64.pas`. |
| 80 | +- [x] 4. Linking and output, `link.pas` and `elf.pas`: tree shaking, |
| 78 | 81 | static ELF, symbol table. A hand built chunk runs. |
| 79 | | -- [ ] 5. Parser and code generator, `gen.pas` and `parse.pas`: |
| 82 | +- [x] 5. Parser and code generator, `gen.pas` and `parse.pas`: |
| 80 | 83 | everything in the report except multiple results, errors, |
| 81 | 84 | enumerations and sets, record literals, `defer`, `NEW`, generic |
| 82 | 85 | modules and `extern`. Module bodies, per-target modules and their |
| 83 | 86 | interface check, and code procedures are in. |
| 84 | | -- [ ] 6. `lib/Rt.jed`, `lib/Sys.linux-x86_64.jed`, `lib/Out.jed`; |
| 87 | +- [x] 6. `lib/Rt.jed`, `lib/Sys.linux-x86_64.jed`, `lib/Out.jed`; |
| 85 | 88 | examples (hello, args, variants and slices, volatile, a code |
| 86 | 89 | procedure); `make check` runs them against expected output; |
| 87 | 90 | `make bench` times the compiler on generated jed. |