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 Start
3535
3636 ```bash
37-# One command (requires spinel wrapper + compiled binaries):
37+# Build everything:
38+make
39+
40+# Compile a Ruby program:
3841 ./spinel app.rb # compiles to ./app
3942 ./spinel app.rb -o myapp # compiles to ./myapp
4043 ./spinel app.rb -c # generates app.c only
@@ -45,8 +48,6 @@
4548 ruby spinel_codegen.rb app.ast app.c
4649 cc -O2 app.c -lm -o app
4750 ```
48-
49-Programs using regular expressions need `--lonig` (links oniguruma).
5051
5152 ## Self-Hosting
5253
@@ -62,7 +63,7 @@
6263
6364 ## Benchmarks
6465
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 stack
112117 scanning, and adaptive threshold. Arrays track GC-managed memory for
113118 accurate collection.
@@ -118,13 +123,15 @@
118123 ## Architecture
119124
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 programs
127133 benchmark/ 39 benchmark programs
134+Makefile Build automation
128135 ```
129136
130137 The compiler backend (`spinel_codegen.rb`) is written in a Ruby subset
@@ -144,24 +151,17 @@
144151 ## Building
145152
146153 ```bash
147-# Build libprism (from Prism gem source or standalone)
148-PRISM=~/.gem/ruby/3.2.0/gems/prism-1.9.0
149-cc -O2 -c -I$PRISM/include $PRISM/src/*.c $PRISM/src/util/*.c
150-ar rcs libprism.a *.o
154+make # build parser + regexp library + bootstrap compiler
155+make test # run 60 tests
156+make bench # run 39 benchmarks
157+make clean # remove build artifacts
158+```
151159
152-# Build the C parser
153-cc -O2 -I$PRISM/include spinel_parse.c libprism.a -lm -o spinel_parse_bin
154-
155-# Bootstrap the compiler backend
156-ruby spinel_parse.rb spinel_codegen.rb > codegen.ast
157-ruby spinel_codegen.rb codegen.ast gen1.c
158-cc -O2 -Wno-all gen1.c -lm -o bin1
159-./bin1 codegen.ast gen2.c
160-cc -O2 -Wno-all gen2.c -lm -o spinel_codegen
160+Requires [Prism](https://github.com/ruby/prism) gem installed (for
161+libprism source). Override with `PRISM_DIR=/path/to/prism`.
161162
162-# Now you can compile Ruby programs:
163-./spinel app.rb
164-```
163+CRuby is needed only for the initial bootstrap. After `make`, the
164+entire pipeline runs without Ruby.
165165
166166 ## Limitations
167167
@@ -172,10 +172,10 @@
172172
173173 ## Dependencies
174174
175-- **Parse time**: [libprism](https://github.com/ruby/prism) (C library),
176- or Prism gem (CRuby) as fallback
175+- **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 ## History
181181