Commit 56801a60
56801a60cd3bMerged
Yukihiro "Matz" Matsumoto <[email protected]> · 7 months ago · 1 file · ~1 modified
Description
docs: update README for regexp support and 59/60 tests
- Add Regexp section (built-in NFA engine, no external dependency)
- Update test count to 59/60
- Update architecture (shell wrapper, regexp engine lines, Makefile)
- Simplify Building section to use Makefile
- Update Dependencies (regexp no longer needs oniguruma)
Co-Authored-By: Claude Opus 4.6 (1M context) [email protected]
Details
- Commit
- 56801a60cd3b
- Parent
- 7bf5bd08eab3
README.mdmodifiedView file
@@ -34,7 +34,10 @@
3434
## Quick Start3535
3636
```bash37-
# One command (requires spinel wrapper + compiled binaries):37+
# Build everything:38+
make39+
40+
# Compile a Ruby program:3841
./spinel app.rb # compiles to ./app3942
./spinel app.rb -o myapp # compiles to ./myapp4043
./spinel app.rb -c # generates app.c only@@ -45,8 +48,6 @@
4548
ruby spinel_codegen.rb app.ast app.c4649
cc -O2 app.c -lm -o app4750
```48-
49-
Programs using regular expressions need `--lonig` (links oniguruma).5051
5152
## Self-Hosting5253
@@ -62,7 +63,7 @@
6263
6364
## Benchmarks6465
65-
39/39 benchmarks pass. 58/60 tests pass.66+
39/39 benchmarks pass. 59/60 tests pass.6667
6768
| Benchmark | Spinel | CRuby 3.x | Speedup |6869
|-----------|--------|-----------|---------|@@ -108,6 +109,10 @@
108109
**Strings**: `<<` automatically promotes to mutable strings (`sp_String`)109110
for O(n) in-place append. `+`, interpolation, and methods work on both.110111
112+
**Regexp**: Built-in NFA regexp engine (no external dependency).113+
`=~`, `$1`-`$9`, `match?`, `gsub(/re/, str)`, `sub(/re/, str)`,114+
`scan(/re/)`, `split(/re/)`.115+
111116
**Memory**: Mark-and-sweep GC with explicit roots, conservative stack112117
scanning, and adaptive threshold. Arrays track GC-managed memory for113118
accurate collection.@@ -118,13 +123,15 @@
118123
## Architecture119124
120125
```121-
spinel One-command wrapper script (Ruby)126+
spinel One-command wrapper script (POSIX shell)122127
spinel_parse.rb CRuby frontend: Prism AST → text format (715 lines)123128
spinel_parse.c C frontend: libprism → text format (915 lines)124-
spinel_codegen.rb Compiler backend: AST → C code (14,280 lines)129+
spinel_codegen.rb Compiler backend: AST → C code (14,498 lines)130+
lib/regexp/ Built-in regexp engine (1,759 lines)125131
lib/ Stub libraries (stringio, strscan, optparse, etc.)126132
test/ 60 test programs127133
benchmark/ 39 benchmark programs134+
Makefile Build automation128135
```129136
130137
The compiler backend (`spinel_codegen.rb`) is written in a Ruby subset@@ -144,24 +151,17 @@
144151
## Building145152
146153
```bash147-
# Build libprism (from Prism gem source or standalone)148-
PRISM=~/.gem/ruby/3.2.0/gems/prism-1.9.0149-
cc -O2 -c -I$PRISM/include $PRISM/src/*.c $PRISM/src/util/*.c150-
ar rcs libprism.a *.o154+
make # build parser + regexp library + bootstrap compiler155+
make test # run 60 tests156+
make bench # run 39 benchmarks157+
make clean # remove build artifacts158+
```151159
152-
# Build the C parser153-
cc -O2 -I$PRISM/include spinel_parse.c libprism.a -lm -o spinel_parse_bin154-
155-
# Bootstrap the compiler backend156-
ruby spinel_parse.rb spinel_codegen.rb > codegen.ast157-
ruby spinel_codegen.rb codegen.ast gen1.c158-
cc -O2 -Wno-all gen1.c -lm -o bin1159-
./bin1 codegen.ast gen2.c160-
cc -O2 -Wno-all gen2.c -lm -o spinel_codegen160+
Requires [Prism](https://github.com/ruby/prism) gem installed (for161+
libprism source). Override with `PRISM_DIR=/path/to/prism`.161162
162-
# Now you can compile Ruby programs:163-
./spinel app.rb164-
```163+
CRuby is needed only for the initial bootstrap. After `make`, the164+
entire pipeline runs without Ruby.165165
166166
## Limitations167167
@@ -172,10 +172,10 @@
172172
173173
## Dependencies174174
175-
- **Parse time**: [libprism](https://github.com/ruby/prism) (C library),176-
or Prism gem (CRuby) as fallback175+
- **Build time**: [libprism](https://github.com/ruby/prism) (C library),176+
CRuby (bootstrap only)177177
- **Run time**: None. Generated binaries need only libc + libm.178-
- **Regexp**: Programs using regex link with [oniguruma](https://github.com/kkos/oniguruma)178+
- **Regexp**: Built-in engine, no external library needed.179179
180180
## History181181