raz / commit 44405d9a

commit
44405d9a7dc9a98a4a9e41b88194d51870b2dd7c
author
Luis <42945842+ldiaz94@users.noreply.github.com>
date
parent
bc1240a7
Stage 1 done: tick the plan, record the lines

The report's library table gains Sys, and three long lines wrap.

patch · log

2 files changed, +26 -22

PLAN.md (history) modified +19 -16

@@ -3,7 +3,7 @@
33 jed (Polish *jeden*, one) is a small systems language in Wirth's
44 tradition: full control of memory, volatile access, atomics, calls into
55 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
77 x86-64 machine code and the ELF file itself.
88
99 The language is defined by `doc/jed.md`. Where this plan and the report
@@ -53,17 +53,20 @@
5353 is a library.
5454
5555 ## 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:
5659
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 |
6770
6871 ## Steps
6972
@@ -71,17 +74,17 @@
7174
7275 - [x] 1. Language report, `doc/jed.md`. Reviewed and approved before
7376 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
7578 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,
7881 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`:
8083 everything in the report except multiple results, errors,
8184 enumerations and sets, record literals, `defer`, `NEW`, generic
8285 modules and `extern`. Module bodies, per-target modules and their
8386 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`;
8588 examples (hello, args, variants and slices, volatile, a code
8689 procedure); `make check` runs them against expected output;
8790 `make bench` times the compiler on generated jed.

doc/jed.md modified +7 -6

@@ -37,8 +37,8 @@
3737 comments is ASCII. Spaces, tabs and line breaks separate symbols and
3838 are otherwise ignored.
3939
40-**Identifiers** are an ASCII letter or `_` followed by letters, digits and `_`,
41-up to 63 characters. Case matters: `count` and `Count` are different
40+**Identifiers** are an ASCII letter or `_` followed by letters, digits
41+and `_`, up to 63 characters. Case matters: `count` and `Count` are different
4242 names.
4343
4444 **Reserved words** are lowercase, except `VOLATILE`:
@@ -590,8 +590,8 @@
590590 field or element of it. Each read or write of a volatile variable of a
591591 basic, enumeration, set or pointer type is exactly one memory access,
592592 of exactly its size, and volatile accesses happen in the order the
593-program writes them. Copying a whole record or array through a volatile pointer is
594-not allowed, since it can't be one access.
593+program writes them. Copying a whole record or array through a
594+volatile pointer is not allowed, since it can't be one access.
595595
596596 A `^VOLATILE T` doesn't convert to `^T` without a written conversion.
597597
@@ -723,8 +723,8 @@
723723 and indexing arrays and slices is checked, so a program's behaviour is
724724 defined by this report, with one exception: memory reached through a
725725 pointer. Dereferencing a stale or made-up pointer, indexing through a
726-pointer, a code procedure that breaks its rules, and C code can read or write any
727-memory, and what follows isn't defined. Dereferencing `nil`, dividing
726+pointer, a code procedure that breaks its rules, and C code can read or
727+write any memory, and what follows isn't defined. Dereferencing `nil`, dividing
728728 by zero and calling a `nil` procedure stop the program with a signal.
729729
730730 ## 11. The library
@@ -734,6 +734,7 @@
734734 | Module | What |
735735 |---|---|
736736 | `Rt` | what the compiler's checks call when they fail, and string comparison |
737+| `Sys` | system calls: `write`, `exit`; one file per target |
737738 | `Out` | writing text and numbers to standard output |
738739 | `Mem` | `mmap`, and `Allocator`, the interface of every allocator |
739740 | `Heap` | a general allocator |