flexr 1.2.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -1
- data/CHANGELOG.md +26 -26
- data/CONTRIBUTING.md +38 -7
- data/README.md +4 -7
- data/Rakefile +150 -63
- data/benchmark/baselines/json.json +2 -2
- data/benchmark/golden/calculator_lexer.rb +15 -15
- data/benchmark/golden/graphql_lexer.rb +3 -3
- data/benchmark/golden/json_lexer.rb +25 -25
- data/benchmark/golden/regexp_tokenizer.rb +23 -23
- data/benchmark/golden/ruby_subset_lexer.rb +3 -3
- data/benchmark/golden/sql_lexer.rb +3 -3
- data/benchmark/golden/toml_lexer.rb +3 -3
- data/benchmark/golden/toy_lang_lexer.rb +9 -9
- data/benchmark/golden/with_lrama_lexer.rb +3 -3
- data/benchmark/golden/with_racc_lexer.rb +3 -3
- data/docs/RELEASING.md +1 -7
- data/docs/explanation/backends.md +17 -0
- data/docs/how-to/deploy-a-standalone-lexer.md +1 -1
- data/docs/how-to/tune-performance.md +12 -0
- data/docs/migration-v2.md +3 -2
- data/docs/perf-log.md +88 -0
- data/docs/reference/cli.md +1 -1
- data/docs/reference/compatibility.md +7 -8
- data/docs/reference/dsl.md +4 -0
- data/docs/reference/generated-artifacts.md +31 -4
- data/docs/reference/public-api.md +5 -4
- data/docs/reference/runtime.md +2 -2
- data/docs/reference/tokens-and-locations.md +8 -0
- data/examples/json/lexer.flexr.rb +6 -6
- data/lib/flexr/automaton/accel.rb +58 -0
- data/lib/flexr/automaton/compiler.rb +4 -1
- data/lib/flexr/automaton/types.rb +1 -1
- data/lib/flexr/codegen/table.rb +6 -0
- data/lib/flexr/dsl.rb +2 -1
- data/lib/flexr/generated.rb +43 -7
- data/lib/flexr/generator.rb +21 -8
- data/lib/flexr/minitest.rb +4 -4
- data/lib/flexr/regexp/tokenizer.rb +24 -24
- data/lib/flexr/runtime/core.rb +28 -4
- data/lib/flexr/runtime/interpreter.rb +8 -1
- data/lib/flexr/runtime/location.rb +35 -13
- data/lib/flexr/runtime/record.rb +14 -0
- data/lib/flexr/runtime/token.rb +7 -2
- data/lib/flexr/runtime.rb +3 -2
- data/lib/flexr/source/prism_reader.rb +8 -2
- data/lib/flexr/unicode/property.rb +1 -2
- data/lib/flexr/unicode/reference_regexp.rb +1 -2
- data/lib/flexr/version.rb +1 -1
- data/sig/flexr.rbs +18 -12
- data/site/README.md +54 -3
- data/site/astro.config.mjs +3 -1
- data/site/package.json +12 -5
- data/site/playwright.config.mjs +16 -0
- data/site/pnpm-lock.yaml +218 -88
- data/site/ruby/playground.rb +57 -0
- data/site/scripts/prepare-playground.mjs +35 -0
- data/site/scripts/verify-site.mjs +5 -3
- data/site/src/content/docs/concepts/matching-semantics.md +4 -2
- data/site/src/content/docs/concepts/security-model.md +9 -1
- data/site/src/content/docs/learn/generation.md +1 -1
- data/site/src/content/docs/reference/dsl.md +2 -2
- data/site/src/content/docs/reference/public-api.md +4 -2
- data/site/src/content/docs/reference/tokens-and-locations.md +3 -0
- data/site/src/layouts/SiteLayout.astro +3 -1
- data/site/src/pages/playground.astro +40 -38
- data/site/src/playground/client.js +211 -0
- data/site/src/playground/graph-worker.mjs +11 -0
- data/site/src/playground/presets.mjs +33 -0
- data/site/src/playground/runtime.mjs +34 -0
- data/site/src/playground/share.mjs +30 -0
- data/site/src/playground/worker.mjs +29 -0
- data/site/src/styles/custom.css +8 -0
- data/site/tests/browser/playground.spec.mjs +99 -0
- data/site/tests/playground-runtime.test.mjs +85 -0
- data/tools/docs_verify.rb +2 -2
- data/tools/verification_failure.rb +119 -0
- metadata +17 -7
- data/lib/flexr/deprecations.rb +0 -26
- data/site/public/playground.js +0 -189
- data/tools/release_notes.rb +0 -16
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9ddc29026c24ee0e7fbb30d382589d810faa73e671324ea589c689744849b94b
|
|
4
|
+
data.tar.gz: ddda688781086eb9bd6707b4f92eeb4b1f7d24ecfdbd370942f4db0a06d42659
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6e55f1ba6d9130a3eb2869866040f5b35c7305788589898cdd1c949030f18b5a4a2855acc0e914d0c287472370e8688b5fdd5e755e8aa00a93b0729ae8c10ebf
|
|
7
|
+
data.tar.gz: a92711bf693c04cbc0ac9f8983165041de096e5f6b5ac0a2f8997113208dd70224d165f018ac2a065c78a56023934570a5f10284a2e3c9d1c8d774483f166890
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
|
@@ -3,41 +3,41 @@
|
|
|
3
3
|
Notable changes to flexr, newest first. Release dates use Japan Standard Time
|
|
4
4
|
(UTC+09:00).
|
|
5
5
|
|
|
6
|
-
## 1.
|
|
7
|
-
|
|
8
|
-
### Upgrade to 2.0
|
|
9
|
-
|
|
10
|
-
- Run `flexr check SPEC --target 2.0` to identify structured-token declarations and
|
|
11
|
-
see the Ruby and generated-artifact requirements for 2.0.
|
|
12
|
-
- Set `RUBYOPT=-W:deprecated` to find record mutations, unknown error modes,
|
|
13
|
-
older Ruby versions, and generated lexers that need regeneration in 2.0.
|
|
14
|
-
See the [migration guide](https://github.com/ydah/flexr/blob/v2.0.0/docs/migration-v2.md).
|
|
15
|
-
- 1.2 retains Ruby 3.1 runtime support, mutable `Struct` tokens and locations,
|
|
16
|
-
and generated artifact ABI 1. The Ruby 3.3 minimum for static generation
|
|
17
|
-
stays in effect.
|
|
6
|
+
## [2.0.0](https://github.com/ydah/flexr/compare/v1.1.0...v2.0.0) - 2026-11-22
|
|
18
7
|
|
|
19
8
|
### Added
|
|
20
9
|
|
|
21
|
-
-
|
|
22
|
-
|
|
23
|
-
-
|
|
24
|
-
and
|
|
25
|
-
-
|
|
26
|
-
|
|
27
|
-
-
|
|
28
|
-
|
|
29
|
-
-
|
|
10
|
+
- A real Ruby WASM Playground with editable specifications, diagnostics, DFA
|
|
11
|
+
diagrams, trace steps, generated code, presets, and share links.
|
|
12
|
+
- Input tracing with candidate lengths, rule priority, actions, state changes,
|
|
13
|
+
and human or JSON output for runtime and generated scanners.
|
|
14
|
+
- Optional phase profiling and isolated interpreter, YJIT, and ZJIT comparisons.
|
|
15
|
+
- RSpec and Minitest token assertions with explicit-update token snapshots.
|
|
16
|
+
- Grammar token validation with `check --grammar` and Lrama declaration export.
|
|
17
|
+
- Ruby LSP diagnostics and rule hovers for unsaved lexer specifications.
|
|
18
|
+
- Public API RBS signatures and typed consumer checks.
|
|
19
|
+
- TOML, GraphQL, and SQL subset examples with benchmarks and parity checks.
|
|
20
|
+
- A migration guide and static `check --target 2.0` impact reporting.
|
|
21
|
+
- Explicit `accel :strscan` whole-token acceleration for proven ASCII paths.
|
|
22
|
+
- Opt-in Ractor sharing of generated method-action tables; unsupported closures,
|
|
23
|
+
EOF blocks, and firstmatch reference caches are rejected explicitly.
|
|
30
24
|
|
|
31
25
|
### Changed
|
|
32
26
|
|
|
33
|
-
-
|
|
34
|
-
|
|
27
|
+
- Require Ruby 3.4+ for runtime, generation, and standalone artifacts.
|
|
28
|
+
- Make structured tokens and locations immutable `Data` records while retaining
|
|
29
|
+
attribute readers and read-only indexing. Replace field mutation with `with`.
|
|
30
|
+
- Reject unknown `error_mode` values during initialization.
|
|
31
|
+
- Use artifact schema 2 and runtime ABI 2; regenerate v1 lexers after upgrading.
|
|
32
|
+
- Stabilize explicit firstmatch selection while retaining longest-match defaults.
|
|
33
|
+
- Reduce temporary Range allocations and use direct emit declarations in the
|
|
34
|
+
JSON example without changing its tokens.
|
|
35
35
|
|
|
36
36
|
### Fixed
|
|
37
37
|
|
|
38
|
-
-
|
|
39
|
-
-
|
|
40
|
-
|
|
38
|
+
- Preserve UTF-8 source when generating lexers with Unicode action literals and surrounding constants.
|
|
39
|
+
- Show source context and installation guidance when Prism cannot load.
|
|
40
|
+
- Identify the installing file for incompatible generated artifacts when available.
|
|
41
41
|
|
|
42
42
|
## [1.1.0](https://github.com/ydah/flexr/compare/v1.0.0...v1.1.0) - 2026-08-13
|
|
43
43
|
|
data/CONTRIBUTING.md
CHANGED
|
@@ -8,8 +8,8 @@ bundle exec rake test
|
|
|
8
8
|
bundle exec rubocop
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
-
The runtime
|
|
12
|
-
|
|
11
|
+
The runtime and generator require Ruby 3.4 or newer.
|
|
12
|
+
The generator uses Prism for source analysis.
|
|
13
13
|
|
|
14
14
|
## Validation layers
|
|
15
15
|
|
|
@@ -28,11 +28,17 @@ Do not update a generated golden file to hide a semantic change; inspect the
|
|
|
28
28
|
generated diff and update the compatibility documentation when the change is
|
|
29
29
|
intentional.
|
|
30
30
|
|
|
31
|
-
Golden snapshots
|
|
32
|
-
compiler version and its derived digest normalized.
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
31
|
+
Golden snapshots in `benchmark/golden/*.rb` contain generated Ruby with only
|
|
32
|
+
the compiler version and its derived digest normalized. Scanner code, user
|
|
33
|
+
literals, artifact schema, runtime ABI, and Unicode metadata remain part of
|
|
34
|
+
the comparison. A release version bump alone does not change these snapshots.
|
|
35
|
+
Generator safety tests separately check the real compiler version, digest,
|
|
36
|
+
and exact reproduction of committed generated artifacts.
|
|
37
|
+
|
|
38
|
+
On a mismatch, `golden:verify` prints a source diff and saves the actual snapshot
|
|
39
|
+
under `tmp/golden/`. Review that diff before accepting an intentional generator
|
|
40
|
+
change with `bundle exec rake golden:update`, then review the committed snapshot
|
|
41
|
+
diffs. Verification never updates the expected snapshots.
|
|
36
42
|
|
|
37
43
|
Markdown-only pushes and pull requests run documentation verification without
|
|
38
44
|
the test matrices or other Ruby checks. Changes limited to `site/` or its Pages
|
|
@@ -40,6 +46,31 @@ workflow skip Ruby CI and follow the Pages workflow's triggers. Changes that
|
|
|
40
46
|
also include code or Ruby configuration still run the full Ruby checks. The
|
|
41
47
|
daily scheduled runs retain all validation layers.
|
|
42
48
|
|
|
49
|
+
## Replay a verification mismatch
|
|
50
|
+
|
|
51
|
+
`test:differential` and `fuzz` save the first mismatch in
|
|
52
|
+
`tmp/verification-failures/` and exit with status 1.
|
|
53
|
+
The differential-fuzz workflow attaches these files as the
|
|
54
|
+
`verification-failures` artifact when a job fails.
|
|
55
|
+
Replay one case from the repository root.
|
|
56
|
+
|
|
57
|
+
```sh
|
|
58
|
+
FLEXR_FAILURE_CASE=path/to/failure.json bundle exec rake verification:replay
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
The JSON records the commit, a fingerprint of the tracked diff and non-ignored
|
|
62
|
+
untracked files, Ruby and gem versions, seed, case number, comparison settings,
|
|
63
|
+
and both outcomes. For fuzz cases it also records the lexer path and its SHA-256.
|
|
64
|
+
The input is stored as hex with its original encoding, including invalid UTF-8.
|
|
65
|
+
|
|
66
|
+
Replay uses that exact input and runs the same comparison on the current
|
|
67
|
+
checkout. It reports drift in the fuzz lexer specification and exits with
|
|
68
|
+
status 1 if a mismatch persists or the comparison cannot run.
|
|
69
|
+
Before fixing a mismatch, record the base commit, expected behavior, and
|
|
70
|
+
validation commands in the task notes. Turn the mismatch into a focused
|
|
71
|
+
regression test that fails before the fix. Run it again after the fix with
|
|
72
|
+
the relevant validation layers and record the results.
|
|
73
|
+
|
|
43
74
|
## Documentation changes
|
|
44
75
|
|
|
45
76
|
README is an entry point. Put task-oriented instructions in `docs/how-to/`,
|
data/README.md
CHANGED
|
@@ -5,9 +5,6 @@
|
|
|
5
5
|
|
|
6
6
|
[Product site](https://ydah.github.io/flexr/) · [Playground](https://ydah.github.io/flexr/playground/) · [Documentation](docs/README.md)
|
|
7
7
|
|
|
8
|
-
This branch maintains flexr 1.x. See the [support policy](docs/reference/compatibility.md#flexr-1x-maintenance)
|
|
9
|
-
and the [migration guide](docs/migration-v2.md) when planning an upgrade to 2.0.
|
|
10
|
-
|
|
11
8
|
Ruby-native lexer generator for parser authors who want ordinary Ruby
|
|
12
9
|
specifications and deterministic generated output.
|
|
13
10
|
|
|
@@ -25,7 +22,7 @@ use the same rules and actions.
|
|
|
25
22
|
## Quick start
|
|
26
23
|
|
|
27
24
|
```sh
|
|
28
|
-
gem install flexr
|
|
25
|
+
gem install flexr
|
|
29
26
|
```
|
|
30
27
|
|
|
31
28
|
```ruby
|
|
@@ -63,8 +60,8 @@ backreferences, or other non-regular constructs.
|
|
|
63
60
|
| Mode | Build requirement | Runtime requirement | Best for |
|
|
64
61
|
|---|---|---|---|
|
|
65
62
|
| Runtime | `flexr` gem | `flexr` gem | Development, tests, and dynamic Ruby specs |
|
|
66
|
-
| Generated | `flexr` plus Prism on Ruby 3.
|
|
67
|
-
| Standalone generated | `flexr` plus Prism on Ruby 3.
|
|
63
|
+
| Generated | `flexr` plus Prism on Ruby 3.4+ | `flexr` gem and Ruby 3.4+ | Reproducible deployment artifacts |
|
|
64
|
+
| Standalone generated | `flexr` plus Prism on Ruby 3.4+ | Generated file and Ruby 3.4+ standard library | Distribution without the gem |
|
|
68
65
|
|
|
69
66
|
Static generation is the default. Use `--eval` only for trusted specifications;
|
|
70
67
|
it executes the specification during the build. See the
|
|
@@ -96,7 +93,7 @@ matches your task:
|
|
|
96
93
|
|
|
97
94
|
## Compatibility and stability
|
|
98
95
|
|
|
99
|
-
Runtime Ruby support starts at 3.
|
|
96
|
+
Runtime Ruby support starts at 3.4. The generator requires Ruby 3.4 or newer
|
|
100
97
|
because it uses Prism. Stable and experimental APIs are listed in the
|
|
101
98
|
[public API contract](docs/reference/public-api.md). The vendored Unicode
|
|
102
99
|
snapshot and generated-artifact policy are described in the
|
data/Rakefile
CHANGED
|
@@ -10,6 +10,7 @@ require "rspec/core/rake_task"
|
|
|
10
10
|
require "tmpdir"
|
|
11
11
|
require "flexr"
|
|
12
12
|
require_relative "tools/regexp_tokenizer_reference"
|
|
13
|
+
require_relative "tools/verification_failure"
|
|
13
14
|
require_relative "tools/golden"
|
|
14
15
|
|
|
15
16
|
RSpec::Core::RakeTask.new(:spec)
|
|
@@ -21,6 +22,7 @@ module FlexrVerification
|
|
|
21
22
|
TOKENIZER_SPEC = File.join(ROOT, "lib/flexr/regexp/tokenizer.flexr.rb").freeze
|
|
22
23
|
TOKENIZER_GENERATED = File.join(ROOT, "lib/flexr/regexp/tokenizer.rb").freeze
|
|
23
24
|
VERIFICATION_SPECS = (EXAMPLES + [TOKENIZER_SPEC]).freeze
|
|
25
|
+
FUZZ_OPTIONS = { error_mode: :panic }.freeze
|
|
24
26
|
EXPECTED_INPUTS = {
|
|
25
27
|
%r{/examples/calculator/} => "if ifx == = 12 + 3",
|
|
26
28
|
%r{/examples/json/} => '{"answer": 42}',
|
|
@@ -103,8 +105,8 @@ module FlexrVerification
|
|
|
103
105
|
end
|
|
104
106
|
end
|
|
105
107
|
|
|
106
|
-
def lexer_outcome(lexer_class, input, **
|
|
107
|
-
{ kind: :tokens, tokens: lexer_class.new(input.dup, **
|
|
108
|
+
def lexer_outcome(lexer_class, input, **)
|
|
109
|
+
{ kind: :tokens, tokens: lexer_class.new(input.dup, **).tokens }
|
|
108
110
|
rescue StandardError => e
|
|
109
111
|
{
|
|
110
112
|
kind: :error,
|
|
@@ -123,6 +125,91 @@ module FlexrVerification
|
|
|
123
125
|
}
|
|
124
126
|
end
|
|
125
127
|
|
|
128
|
+
def differential_outcomes(pattern, input, compiled, host_patterns)
|
|
129
|
+
key = [pattern.source, pattern.options]
|
|
130
|
+
host_expected = begin
|
|
131
|
+
(host_patterns[key] ||= Regexp.new("\\A(?:#{pattern.source})\\z", pattern.options)).match?(input)
|
|
132
|
+
rescue RegexpError, ArgumentError, EncodingError
|
|
133
|
+
false
|
|
134
|
+
end
|
|
135
|
+
if Flexr.reference_pattern?(pattern)
|
|
136
|
+
reference = Flexr::Unicode::ReferenceRegexp.compiled(
|
|
137
|
+
pattern, encoding: pattern.encoding, options: pattern.options, unicode: false
|
|
138
|
+
)
|
|
139
|
+
match = reference.match(input, 0)
|
|
140
|
+
vendored_expected = !match.nil? && match.begin(0).zero? && match[0].bytesize == input.bytesize
|
|
141
|
+
return unless vendored_expected == host_expected
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
[host_expected, (compiled[key] ||= Flexr.compile_pattern(pattern)).accept?(input)]
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
def differential_mismatch(pattern, input, expected, actual)
|
|
148
|
+
"differential mismatch: #{pattern.inspect} #{input.inspect} expected=#{expected} actual=#{actual}"
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
def with_fuzz_lexers(spec)
|
|
152
|
+
runtime_lexer = load_runtime(spec)
|
|
153
|
+
class_name = runtime_lexer.name
|
|
154
|
+
remove_constant(class_name)
|
|
155
|
+
Dir.mktmpdir("flexr-fuzz-") do |directory|
|
|
156
|
+
generated_path = File.join(directory, File.basename(spec))
|
|
157
|
+
File.binwrite(generated_path, generated_source(spec))
|
|
158
|
+
load generated_path
|
|
159
|
+
generated_lexer = constantize(class_name)
|
|
160
|
+
raise "no generated lexer found for #{spec}" unless generated_lexer&.__flexr_generated?
|
|
161
|
+
|
|
162
|
+
yield runtime_lexer, generated_lexer
|
|
163
|
+
end
|
|
164
|
+
ensure
|
|
165
|
+
if class_name
|
|
166
|
+
remove_constant(class_name)
|
|
167
|
+
parent, _, name = class_name.rpartition("::")
|
|
168
|
+
constantize(parent).const_set(name, runtime_lexer)
|
|
169
|
+
end
|
|
170
|
+
end
|
|
171
|
+
|
|
172
|
+
def fuzz_mismatch(spec, input, expected, actual)
|
|
173
|
+
"fuzz mode mismatch: #{relative_spec(spec)} input=#{input.inspect} " \
|
|
174
|
+
"runtime=#{expected.inspect} generated=#{actual.inspect}"
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
def replay_failure(record)
|
|
178
|
+
input = FailureCase.decode_bytes(FailureCase.section(record, "input"))
|
|
179
|
+
task = record.fetch("task")
|
|
180
|
+
case task
|
|
181
|
+
when "test:differential"
|
|
182
|
+
source = FailureCase.section(record, "pattern")
|
|
183
|
+
options = source.fetch("options")
|
|
184
|
+
raise ArgumentError, "invalid regexp options" unless options.is_a?(Integer)
|
|
185
|
+
|
|
186
|
+
pattern = Regexp.new(FailureCase.decode_bytes(FailureCase.section(source, "source")), options)
|
|
187
|
+
raise ArgumentError, "regexp encoding differs from the recorded encoding" unless pattern.encoding.name == source.fetch("encoding")
|
|
188
|
+
|
|
189
|
+
outcomes = differential_outcomes(pattern, input, {}, {})
|
|
190
|
+
abort "differential replay skipped: host and vendored Unicode results differ" unless outcomes
|
|
191
|
+
expected, actual = outcomes
|
|
192
|
+
abort differential_mismatch(pattern, input, expected, actual) unless expected == actual
|
|
193
|
+
when "fuzz"
|
|
194
|
+
recorded_spec = FailureCase.section(record, "spec")
|
|
195
|
+
path = recorded_spec.fetch("path")
|
|
196
|
+
spec = VERIFICATION_SPECS.find { |candidate| relative_spec(candidate) == path }
|
|
197
|
+
raise ArgumentError, "unknown fuzz lexer specification: #{path.inspect}" unless spec
|
|
198
|
+
options = FUZZ_OPTIONS.transform_keys(&:to_s).transform_values(&:to_s)
|
|
199
|
+
raise ArgumentError, "unsupported fuzz options" unless record.fetch("options") == options
|
|
200
|
+
|
|
201
|
+
warn "Fuzz lexer specification has changed: #{path}" unless Digest::SHA256.file(spec).hexdigest == recorded_spec.fetch("sha256")
|
|
202
|
+
with_fuzz_lexers(spec) do |runtime_lexer, generated_lexer|
|
|
203
|
+
expected = lexer_outcome(runtime_lexer, input, **FUZZ_OPTIONS)
|
|
204
|
+
actual = lexer_outcome(generated_lexer, input, **FUZZ_OPTIONS)
|
|
205
|
+
abort fuzz_mismatch(spec, input, expected, actual) unless expected == actual
|
|
206
|
+
end
|
|
207
|
+
else
|
|
208
|
+
raise ArgumentError, "unknown verification task: #{task.inspect}"
|
|
209
|
+
end
|
|
210
|
+
puts "verification: #{task} case #{record.fetch('case')} passed"
|
|
211
|
+
end
|
|
212
|
+
|
|
126
213
|
def load_runtime(spec)
|
|
127
214
|
class_name = runtime_class_name(spec)
|
|
128
215
|
existing = constantize(class_name)
|
|
@@ -179,6 +266,12 @@ module FlexrVerification
|
|
|
179
266
|
reference = inputs.map { |input| reference_lexer.new(input, error_mode: :panic).tokens }
|
|
180
267
|
raise "acceleration token mismatch in #{spec}" unless accelerated == reference
|
|
181
268
|
|
|
269
|
+
remove_constant(runtime_class_name(spec))
|
|
270
|
+
whole_token_lexer = load_runtime(spec)
|
|
271
|
+
whole_token_lexer.accel(:strscan)
|
|
272
|
+
whole_tokens = inputs.map { |input| whole_token_lexer.new(input.dup.freeze, error_mode: :panic).tokens }
|
|
273
|
+
raise "whole-token acceleration mismatch in #{spec}" unless whole_tokens == reference
|
|
274
|
+
|
|
182
275
|
lexer.compile!.machines.each_value do |machine|
|
|
183
276
|
Flexr::Automaton::Accel.extract(machine.dfa).each do |region|
|
|
184
277
|
256.times do |byte|
|
|
@@ -426,50 +519,41 @@ task "bench:matrix" do
|
|
|
426
519
|
end
|
|
427
520
|
|
|
428
521
|
namespace :test do
|
|
522
|
+
desc "Compare Flexr pattern acceptance with Ruby's regexp engine"
|
|
429
523
|
task :differential do
|
|
430
524
|
patterns = [/[a-z]+/, /a(?:b|c)?/, /[0-9]{1,3}/, /[^\n]+/, /foo/,
|
|
431
525
|
/[[:alpha:]]+/, /[[:alnum:]]+/, /\p{L}+/, /\p{Nd}+/]
|
|
432
526
|
cases = Integer(ENV.fetch("FLEXR_DIFFERENTIAL_CASES", "1000000"), 10)
|
|
433
|
-
|
|
527
|
+
seed = Integer(ENV.fetch("FLEXR_SEED", "17"), 10)
|
|
528
|
+
random = Random.new(seed)
|
|
434
529
|
unicode_inputs = ["", "a", "あ", "é", "ß", "Ω", "١", " ", "aあ", "éΩ", [0x18db8].pack("U")].freeze
|
|
435
530
|
compiled = {}
|
|
436
531
|
host_patterns = {}
|
|
437
532
|
independent_cases = 0
|
|
438
533
|
version_mismatches = 0
|
|
439
|
-
cases.times do
|
|
534
|
+
cases.times do |index|
|
|
440
535
|
pattern = patterns[random.rand(patterns.length)]
|
|
441
536
|
input = if random.rand(3).zero?
|
|
442
537
|
random.rand(2).zero? ? unicode_inputs.sample(random: random) : FlexrVerification.random_unicode_string(random)
|
|
443
538
|
else
|
|
444
539
|
Array.new(random.rand(10)) { random.rand(32..126) }.pack("C*")
|
|
445
540
|
end
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
false
|
|
451
|
-
end
|
|
452
|
-
if Flexr.reference_pattern?(pattern)
|
|
453
|
-
reference = Flexr::Unicode::ReferenceRegexp.compiled(
|
|
454
|
-
pattern, encoding: pattern.encoding, options: pattern.options, unicode: false
|
|
455
|
-
)
|
|
456
|
-
match = reference.match(input, 0)
|
|
457
|
-
vendored_expected = if match
|
|
458
|
-
match.begin(0).zero? && match[0].bytesize == input.bytesize
|
|
459
|
-
else
|
|
460
|
-
false
|
|
461
|
-
end
|
|
462
|
-
unless vendored_expected == host_expected
|
|
463
|
-
version_mismatches += 1
|
|
464
|
-
next
|
|
465
|
-
end
|
|
541
|
+
outcomes = FlexrVerification.differential_outcomes(pattern, input, compiled, host_patterns)
|
|
542
|
+
unless outcomes
|
|
543
|
+
version_mismatches += 1
|
|
544
|
+
next
|
|
466
545
|
end
|
|
467
546
|
independent_cases += 1
|
|
468
|
-
actual =
|
|
469
|
-
next if
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
547
|
+
expected, actual = outcomes
|
|
548
|
+
next if expected == actual
|
|
549
|
+
|
|
550
|
+
FlexrVerification::FailureCase.abort_with_record(
|
|
551
|
+
FlexrVerification.differential_mismatch(pattern, input, expected, actual),
|
|
552
|
+
root: FlexrVerification::ROOT, task: "test:differential", seed: seed, case: index + 1, input: input,
|
|
553
|
+
pattern: { source: FlexrVerification::FailureCase.encode_bytes(pattern.source), options: pattern.options,
|
|
554
|
+
encoding: pattern.encoding.name },
|
|
555
|
+
backends: { expected: "ruby_regexp", actual: "table" }, expected: expected, actual: actual
|
|
556
|
+
)
|
|
473
557
|
end
|
|
474
558
|
abort "differential did not exercise an independent host oracle" if independent_cases.zero?
|
|
475
559
|
|
|
@@ -478,49 +562,52 @@ namespace :test do
|
|
|
478
562
|
end
|
|
479
563
|
end
|
|
480
564
|
|
|
565
|
+
desc "Compare runtime and generated lexers on randomized inputs"
|
|
481
566
|
task :fuzz do
|
|
482
567
|
cases = Integer(ENV.fetch("FLEXR_FUZZ_CASES", "10000"), 10)
|
|
483
|
-
|
|
568
|
+
seed = Integer(ENV.fetch("FLEXR_SEED", "17"), 10)
|
|
569
|
+
random = Random.new(seed)
|
|
484
570
|
FlexrVerification::VERIFICATION_SPECS.each do |spec|
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
Array.new(random.rand(64)) { random.rand(32..126) }.pack("C*")).force_encoding(Encoding::UTF_8)
|
|
571
|
+
FlexrVerification.with_fuzz_lexers(spec) do |runtime_lexer, generated_lexer|
|
|
572
|
+
cases.times do |index|
|
|
573
|
+
input = case random.rand(4)
|
|
574
|
+
when 0
|
|
575
|
+
Array.new(random.rand(128)) { random.rand(0..127) }.pack("C*").force_encoding(Encoding::UTF_8)
|
|
576
|
+
when 1
|
|
577
|
+
FlexrVerification.random_unicode_string(random, max_codepoints: 32)
|
|
578
|
+
when 2
|
|
579
|
+
Array.new(random.rand(128)) { random.rand(0..255) }.pack("C*").force_encoding(Encoding::UTF_8)
|
|
580
|
+
else
|
|
581
|
+
(FlexrVerification.random_unicode_string(random, max_codepoints: 16) +
|
|
582
|
+
Array.new(random.rand(64)) { random.rand(32..126) }.pack("C*")).force_encoding(Encoding::UTF_8)
|
|
583
|
+
end
|
|
584
|
+
expected = FlexrVerification.lexer_outcome(runtime_lexer, input, **FlexrVerification::FUZZ_OPTIONS)
|
|
585
|
+
actual = FlexrVerification.lexer_outcome(generated_lexer, input, **FlexrVerification::FUZZ_OPTIONS)
|
|
586
|
+
next if expected == actual
|
|
587
|
+
|
|
588
|
+
FlexrVerification::FailureCase.abort_with_record(
|
|
589
|
+
FlexrVerification.fuzz_mismatch(spec, input, expected, actual),
|
|
590
|
+
root: FlexrVerification::ROOT, task: "fuzz", seed: seed, case: index + 1, input: input,
|
|
591
|
+
spec: { path: FlexrVerification.relative_spec(spec), sha256: Digest::SHA256.file(spec).hexdigest },
|
|
592
|
+
backends: { runtime: runtime_lexer.__flexr_config.backend, generated: generated_lexer.__flexr_config.backend },
|
|
593
|
+
options: FlexrVerification::FUZZ_OPTIONS, expected: expected, actual: actual
|
|
594
|
+
)
|
|
510
595
|
end
|
|
511
|
-
runtime_outcome = FlexrVerification.lexer_outcome(runtime_lexer, input, error_mode: :panic)
|
|
512
|
-
generated_outcome = FlexrVerification.lexer_outcome(generated_lexer, input, error_mode: :panic)
|
|
513
|
-
next if runtime_outcome == generated_outcome
|
|
514
|
-
|
|
515
|
-
abort "fuzz mode mismatch: #{spec} input=#{input.inspect} " \
|
|
516
|
-
"runtime=#{runtime_outcome.inspect} generated=#{generated_outcome.inspect}"
|
|
517
596
|
end
|
|
518
|
-
ensure
|
|
519
|
-
FileUtils.rm_f(generated_path) if generated_path
|
|
520
597
|
end
|
|
521
598
|
puts "fuzz: #{cases} inputs per example passed"
|
|
522
599
|
end
|
|
523
600
|
|
|
601
|
+
namespace :verification do
|
|
602
|
+
desc "Replay one saved mismatch (FLEXR_FAILURE_CASE=path/to/case.json)"
|
|
603
|
+
task :replay do
|
|
604
|
+
path = ENV.fetch("FLEXR_FAILURE_CASE")
|
|
605
|
+
FlexrVerification.replay_failure(FlexrVerification::FailureCase.read(path))
|
|
606
|
+
rescue ArgumentError, KeyError, JSON::ParserError, SystemCallError, EncodingError, RegexpError, TypeError => e
|
|
607
|
+
abort "Cannot replay verification failure: #{e.message}"
|
|
608
|
+
end
|
|
609
|
+
end
|
|
610
|
+
|
|
524
611
|
namespace :examples do
|
|
525
612
|
task :check do
|
|
526
613
|
FlexrVerification::EXAMPLES.each do |spec|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schema": 1,
|
|
3
3
|
"spec": "examples/json/lexer.flexr.rb",
|
|
4
|
-
"source_sha256": "
|
|
5
|
-
"source_bytes":
|
|
4
|
+
"source_sha256": "74d57259c5f67f4f6bf64cb870d4165095864fb61c58c9b8bff2d2d88da8b186",
|
|
5
|
+
"source_bytes": 733,
|
|
6
6
|
"input_sha256": "f15489cc8fa286cd365fb167b3f99d3d216dc90c0de6279fe9f36c8d2215d7a7",
|
|
7
7
|
"input_bytes": 140000,
|
|
8
8
|
"tokens": 50000,
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
# Generated by flexr. DO NOT EDIT.
|
|
3
3
|
# source: examples/calculator/lexer.flexr.rb
|
|
4
4
|
# spec-digest: <normalized>
|
|
5
|
-
# artifact-schema:
|
|
6
|
-
# runtime-abi:
|
|
5
|
+
# artifact-schema: 2
|
|
6
|
+
# runtime-abi: 2
|
|
7
7
|
# unicode: 15.1.0
|
|
8
8
|
# backend: table
|
|
9
9
|
# compiled: true
|
|
@@ -14,7 +14,7 @@ require "flexr"
|
|
|
14
14
|
|
|
15
15
|
module CalculatorExample
|
|
16
16
|
class Lexer < Flexr::Lexer
|
|
17
|
-
Flexr::Generated.install_compiled!(self, { artifact: {schema_version:
|
|
17
|
+
Flexr::Generated.install_compiled!(self, { artifact: {schema_version: 2, compiler_version: "<compiler-version>", runtime_abi_version: 2, unicode_version: "15.1.0"}, rules: [{ index: 0, patterns: [/[ \t\r\n]+/], pattern_conditions: [[0, 0, false, false]], trailing: nil, action: :skip, states: [:initial], bol_only: false, end_anchor: nil }, { index: 1, patterns: [/==/], pattern_conditions: [[1, 0, false, false]], trailing: nil, action: :__flexr_generated_method, states: [:initial], bol_only: false, end_anchor: nil }, { index: 2, patterns: [/=/], pattern_conditions: [[2, 0, false, false]], trailing: nil, action: :__flexr_generated_method, states: [:initial], bol_only: false, end_anchor: nil }, { index: 3, patterns: [/if/], pattern_conditions: [[3, 0, false, false]], trailing: nil, action: :__flexr_generated_method, states: [:initial], bol_only: false, end_anchor: nil }, { index: 4, patterns: [/[a-z_][a-z0-9_]*/], pattern_conditions: [[4, 0, false, false]], trailing: nil, action: :__flexr_generated_method, states: [:initial], bol_only: false, end_anchor: nil }, { index: 5, patterns: [/[0-9]+/], pattern_conditions: [[5, 0, false, false]], trailing: nil, action: :__flexr_generated_method, states: [:initial], bol_only: false, end_anchor: nil }, { index: 6, patterns: [/\+/], pattern_conditions: [[6, 0, false, false]], trailing: nil, action: :__flexr_generated_method, states: [:initial], bol_only: false, end_anchor: nil }], backend: :table, token_kind: :array, encoding: Encoding::UTF_8, declared_tokens: [:EQ, :ASSIGN, :IF, :IDENT, :INTEGER, :PLUS], options: {}, eof_rules: { }, states: [], inclusive_states: {initial: true}, compiled: { machines: { :initial => { state_name: :initial, dfa: {accepts: [[], [[0, 0, false, false]], [[6, 0, false, false]], [[5, 0, false, false]], [[2, 0, false, false]], [[4, 0, false, false]], [[4, 0, false, false]], [[1, 0, false, false]], [[3, 0, false, false], [4, 0, false, false]]], ec: [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 2, 2, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 14, 15, 15, 15, 15, 15, 16, 17, 17, 18, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20], class_count: 21, state_count: 9, start: 0, rule_ids: [0, 1, 2, 3, 4, 5, 6], packed: {base: [0, 1, 0, 1, 1, 11, 22, 0, 33], default: [nil, nil, nil, nil, nil, nil, nil, nil, nil], next: [nil, 1, 1, 1, 1, 1, 1, 2, nil, 3, 3, 4, 7, 5, nil, 5, 5, 5, 6, 5, 5, nil, nil, nil, 5, nil, 5, 5, 5, 5, 5, 5, nil, nil, nil, 5, nil, 5, 8, 5, 5, 5, 5, nil, nil, nil, 5, nil, 5, 5, 5, 5, 5], check: [nil, 0, 1, 0, 1, 0, 1, 0, nil, 0, 3, 0, 4, 0, nil, 0, 0, 0, 0, 0, 5, nil, nil, nil, 5, nil, 5, 5, 5, 5, 5, 6, nil, nil, nil, 6, nil, 6, 6, 6, 6, 6, 8, nil, nil, nil, 8, nil, 8, 8, 8, 8, 8]}} } }, states: [:initial], stats: {initial: {states: 9, classes: 21, accepting_states: 8}}, diagnostics: [] } })
|
|
18
18
|
def scan_one
|
|
19
19
|
if @__flexr_generated_scan_state != @state
|
|
20
20
|
machine = self.class.__flexr_compiled.machines.fetch(@state)
|
|
@@ -248,17 +248,17 @@ module CalculatorExample
|
|
|
248
248
|
case rule.index
|
|
249
249
|
when 0
|
|
250
250
|
when 1
|
|
251
|
-
|
|
251
|
+
emit :EQ
|
|
252
252
|
when 2
|
|
253
|
-
|
|
253
|
+
emit :ASSIGN
|
|
254
254
|
when 3
|
|
255
|
-
|
|
255
|
+
emit :IF
|
|
256
256
|
when 4
|
|
257
|
-
|
|
257
|
+
emit :IDENT
|
|
258
258
|
when 5
|
|
259
|
-
|
|
259
|
+
emit :INTEGER, text.to_i
|
|
260
260
|
when 6
|
|
261
|
-
|
|
261
|
+
emit :PLUS
|
|
262
262
|
else
|
|
263
263
|
instance_exec(&rule.action)
|
|
264
264
|
end
|
|
@@ -266,11 +266,11 @@ module CalculatorExample
|
|
|
266
266
|
|
|
267
267
|
|
|
268
268
|
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
269
|
+
|
|
270
|
+
|
|
271
|
+
|
|
272
|
+
|
|
273
|
+
|
|
274
|
+
|
|
275
275
|
end
|
|
276
276
|
end
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
# Generated by flexr. DO NOT EDIT.
|
|
3
3
|
# source: examples/graphql/lexer.flexr.rb
|
|
4
4
|
# spec-digest: <normalized>
|
|
5
|
-
# artifact-schema:
|
|
6
|
-
# runtime-abi:
|
|
5
|
+
# artifact-schema: 2
|
|
6
|
+
# runtime-abi: 2
|
|
7
7
|
# unicode: 15.1.0
|
|
8
8
|
# backend: table
|
|
9
9
|
# compiled: true
|
|
@@ -14,7 +14,7 @@ require "flexr"
|
|
|
14
14
|
|
|
15
15
|
module GraphqlExample
|
|
16
16
|
class Lexer < Flexr::Lexer
|
|
17
|
-
Flexr::Generated.install_compiled!(self, { artifact: {schema_version:
|
|
17
|
+
Flexr::Generated.install_compiled!(self, { artifact: {schema_version: 2, compiler_version: "<compiler-version>", runtime_abi_version: 2, unicode_version: "15.1.0"}, rules: [{ index: 0, patterns: [/[ \t\r\n,]+/], pattern_conditions: [[0, 0, false, false]], trailing: nil, action: :skip, states: [:initial], bol_only: false, end_anchor: nil }, { index: 1, patterns: [/#[^\n]*/], pattern_conditions: [[1, 0, false, false]], trailing: nil, action: :skip, states: [:initial], bol_only: false, end_anchor: nil }, { index: 2, patterns: [/[A-Za-z_][A-Za-z_0-9]*/], pattern_conditions: [[2, 0, false, false]], trailing: nil, action: [:emit, :NAME], states: [:initial], bol_only: false, end_anchor: nil }, { index: 3, patterns: [/-?(?:0|[1-9][0-9]*)(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?/], pattern_conditions: [[3, 0, false, false]], trailing: nil, action: [:emit, :NUMBER], states: [:initial], bol_only: false, end_anchor: nil }, { index: 4, patterns: [/"(?:\\.|[^"\\\r\n])*"/], pattern_conditions: [[4, 0, false, false]], trailing: nil, action: [:emit, :STRING], states: [:initial], bol_only: false, end_anchor: nil }, { index: 5, patterns: [/\.\.\./], pattern_conditions: [[5, 0, false, false]], trailing: nil, action: [:emit, :SPREAD], states: [:initial], bol_only: false, end_anchor: nil }, { index: 6, patterns: [/\{/], pattern_conditions: [[6, 0, false, false]], trailing: nil, action: [:emit, :LBRACE], states: [:initial], bol_only: false, end_anchor: nil }, { index: 7, patterns: [/\}/], pattern_conditions: [[7, 0, false, false]], trailing: nil, action: [:emit, :RBRACE], states: [:initial], bol_only: false, end_anchor: nil }, { index: 8, patterns: [/\(/], pattern_conditions: [[8, 0, false, false]], trailing: nil, action: [:emit, :LPAREN], states: [:initial], bol_only: false, end_anchor: nil }, { index: 9, patterns: [/\)/], pattern_conditions: [[9, 0, false, false]], trailing: nil, action: [:emit, :RPAREN], states: [:initial], bol_only: false, end_anchor: nil }, { index: 10, patterns: [/\[/], pattern_conditions: [[10, 0, false, false]], trailing: nil, action: [:emit, :LBRACKET], states: [:initial], bol_only: false, end_anchor: nil }, { index: 11, patterns: [/\]/], pattern_conditions: [[11, 0, false, false]], trailing: nil, action: [:emit, :RBRACKET], states: [:initial], bol_only: false, end_anchor: nil }, { index: 12, patterns: [/:/], pattern_conditions: [[12, 0, false, false]], trailing: nil, action: [:emit, :COLON], states: [:initial], bol_only: false, end_anchor: nil }, { index: 13, patterns: [/=/], pattern_conditions: [[13, 0, false, false]], trailing: nil, action: [:emit, :EQUAL], states: [:initial], bol_only: false, end_anchor: nil }, { index: 14, patterns: [/!/], pattern_conditions: [[14, 0, false, false]], trailing: nil, action: [:emit, :BANG], states: [:initial], bol_only: false, end_anchor: nil }, { index: 15, patterns: [/\$/], pattern_conditions: [[15, 0, false, false]], trailing: nil, action: [:emit, :DOLLAR], states: [:initial], bol_only: false, end_anchor: nil }, { index: 16, patterns: [/@/], pattern_conditions: [[16, 0, false, false]], trailing: nil, action: [:emit, :AT], states: [:initial], bol_only: false, end_anchor: nil }, { index: 17, patterns: [/\|/], pattern_conditions: [[17, 0, false, false]], trailing: nil, action: [:emit, :PIPE], states: [:initial], bol_only: false, end_anchor: nil }, { index: 18, patterns: [/&/], pattern_conditions: [[18, 0, false, false]], trailing: nil, action: [:emit, :AMP], states: [:initial], bol_only: false, end_anchor: nil }], backend: :table, token_kind: :array, encoding: Encoding::UTF_8, declared_tokens: [:NAME, :STRING, :NUMBER, :SPREAD, :LBRACE, :RBRACE, :LPAREN, :RPAREN, :LBRACKET, :RBRACKET, :COLON, :EQUAL, :BANG, :DOLLAR, :AT, :PIPE, :AMP], options: {}, eof_rules: { }, states: [], inclusive_states: {initial: true}, compiled: { machines: { :initial => { state_name: :initial, dfa: {accepts: [[], [[0, 0, false, false]], [[14, 0, false, false]], [], [[1, 0, false, false]], [[15, 0, false, false]], [[18, 0, false, false]], [[8, 0, false, false]], [[9, 0, false, false]], [], [], [[3, 0, false, false]], [[3, 0, false, false]], [[12, 0, false, false]], [[13, 0, false, false]], [[16, 0, false, false]], [[2, 0, false, false]], [[10, 0, false, false]], [[11, 0, false, false]], [[6, 0, false, false]], [[17, 0, false, false]], [[7, 0, false, false]], [[4, 0, false, false]], [], [], [], [], [], [], [], [], [], [], [[5, 0, false, false]], [[3, 0, false, false]], [], [[3, 0, false, false]]], ec: [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 3, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 23, 23, 23, 23, 23, 23, 23, 23, 24, 25, 25, 26, 27, 27, 28, 29, 29, 29, 29, 30, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 33, 34, 35, 36, 37, 38, 38, 38, 38, 39, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 41, 42, 43, 44, 44, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 46, 46, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 49, 49, 49, 49, 49, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50], class_count: 51, state_count: 37, start: 0, rule_ids: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18], packed: {base: [0, 43, 0, 44, 9, 0, 0, 0, 0, 28, 1, 33, 44, 0, 0, 0, 73, 0, 0, 0, 0, 0, 0, 69, 15, 17, 20, 23, 24, 25, 5, 53, 62, 0, 98, 64, 75], default: [nil, nil, nil, 3, 4, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, 3, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil], next: [nil, 1, 1, nil, 1, nil, 1, 2, 3, 4, 5, nil, 6, nil, 7, 8, nil, nil, 1, 9, 10, 30, 11, 12, 13, 33, 14, nil, 15, 16, 16, 16, 17, nil, 18, nil, 16, nil, 16, 16, 16, 19, 20, 21, 1, 1, nil, 1, nil, 1, 11, 12, 22, 31, nil, nil, 27, 28, 29, nil, 3, 1, 24, 32, 31, 25, 12, 12, 4, 27, 28, nil, 32, nil, 32, 34, 34, 23, nil, 35, nil, 35, nil, 32, 36, 36, 36, 36, nil, nil, nil, 24, 25, 26, nil, 16, 16, 36, 36, nil, nil, nil, 16, 16, 16, nil, nil, nil, nil, 16, nil, 16, 16, 16, nil, nil, 24, 25, 26, nil, 34, 34, nil, nil, nil, nil, nil, nil, 32, nil, nil, nil, nil, nil, nil, nil, nil, 32], check: [nil, 0, 0, nil, 0, nil, 0, 0, 0, 0, 0, 4, 0, nil, 0, 0, nil, nil, 0, 0, 0, 10, 0, 0, 0, 30, 0, nil, 0, 0, 0, 0, 0, nil, 0, nil, 0, nil, 0, 0, 0, 0, 0, 0, 1, 1, 3, 1, 3, 1, 9, 9, 3, 11, 4, 4, 4, 4, 4, 4, 24, 1, 25, 11, 12, 26, 12, 12, 27, 28, 29, 23, 11, nil, 12, 31, 31, 3, nil, 32, nil, 32, nil, 12, 32, 32, 35, 35, nil, 3, 3, 3, 3, 3, 3, 16, 16, 36, 36, nil, nil, nil, 16, 16, 16, nil, nil, nil, nil, 16, nil, 16, 16, 16, 23, 23, 23, 23, 23, 23, 34, 34, nil, nil, nil, nil, nil, nil, 34, nil, nil, nil, nil, nil, nil, nil, nil, 34]}} } }, states: [:initial], stats: {initial: {states: 37, classes: 51, accepting_states: 22}}, diagnostics: [] } })
|
|
18
18
|
def scan_one
|
|
19
19
|
if @__flexr_generated_scan_state != @state
|
|
20
20
|
machine = self.class.__flexr_compiled.machines.fetch(@state)
|