ibex 0.2.0 → 0.4.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/README.md +100 -272
- data/docs/architecture.md +187 -35
- data/docs/bison-import.md +103 -0
- data/docs/comparison-policy.md +127 -0
- data/docs/configuration-model.md +59 -0
- data/docs/configuration-report.md +28 -0
- data/docs/conflict-explanation-reviews/v1/records/README.md +28 -0
- data/docs/conflict-explanation-study.md +62 -0
- data/docs/construction-profiling.md +157 -0
- data/docs/cst-migration.md +3 -4
- data/docs/cst.md +24 -0
- data/docs/decisions/0000-template.md +24 -0
- data/docs/decisions/0001-separate-ir-pipeline.md +34 -0
- data/docs/decisions/0002-opaque-user-code-boundary.md +32 -0
- data/docs/decisions/0003-self-hosted-grammar-frontend.md +32 -0
- data/docs/decisions/0004-shared-semantic-and-lossless-source-model.md +33 -0
- data/docs/decisions/0005-contained-grammar-composition.md +34 -0
- data/docs/decisions/0006-bounded-structural-grammar-lowering.md +32 -0
- data/docs/decisions/0007-shared-parser-construction-pipeline.md +33 -0
- data/docs/decisions/0008-versioned-runtime-package-boundary.md +36 -0
- data/docs/decisions/0009-isolated-parser-sessions.md +34 -0
- data/docs/decisions/0010-committed-runtime-observation.md +34 -0
- data/docs/decisions/0011-versioned-semantic-action-boundary.md +37 -0
- data/docs/decisions/0012-bounded-nonexecuting-analysis.md +37 -0
- data/docs/decisions/0013-transactional-generation-publication.md +37 -0
- data/docs/decisions/0014-versioned-generated-lexer.md +35 -0
- data/docs/decisions/0015-worker-isolated-browser-analysis.md +32 -0
- data/docs/decisions/0016-red-green-concrete-syntax.md +34 -0
- data/docs/decisions/0017-persistent-syntax-artifacts.md +35 -0
- data/docs/decisions/0018-conservative-incremental-syntax-reuse.md +38 -0
- data/docs/decisions/0019-runtime-syntax-session-boundary.md +51 -0
- data/docs/decisions/0020-grammar-ir-parser-contract.md +65 -0
- data/docs/decisions/0021-data-only-parser-table-sidecar.md +50 -0
- data/docs/decisions/0022-manifest-bound-verification-report.md +77 -0
- data/docs/decisions/0023-syntax-only-repair-results.md +48 -0
- data/docs/decisions/0024-direct-ielr-construction.md +42 -0
- data/docs/decisions/README.md +74 -0
- data/docs/declarative-configuration.md +274 -0
- data/docs/development.md +196 -2
- data/docs/direct-ielr-decision.md +120 -0
- data/docs/direct-multi-entry-decision.md +82 -0
- data/docs/editor-setup.md +2 -1
- data/docs/error-ux-review-rubric-v1.md +117 -0
- data/docs/error-ux-reviews/v1/records/README.md +22 -0
- data/docs/error-ux-round2-review-status-v1.json +27 -0
- data/docs/error-ux-round2-reviews/v1/records/README.md +30 -0
- data/docs/error-ux-round2-v1.json +1617 -0
- data/docs/error-ux-round2.md +111 -0
- data/docs/error-ux.md +54 -0
- data/docs/getting-started.md +80 -0
- data/docs/grammar-reference.md +184 -13
- data/docs/ielr-design.md +43 -0
- data/docs/ielr.md +92 -0
- data/docs/impact.md +101 -0
- data/docs/ja/bison-import.md +51 -0
- data/docs/ja/stable-api.md +53 -0
- data/docs/lexer-construction-profile.md +109 -0
- data/docs/lexer-migration.md +5 -0
- data/docs/maturity.md +129 -0
- data/docs/project-site-strategy.md +54 -0
- data/docs/racc-migration-evidence.md +45 -0
- data/docs/racc-migration.md +11 -0
- data/docs/release-readiness.md +126 -68
- data/docs/repair-semantics.md +123 -0
- data/docs/runtime-abi-evolution.md +310 -0
- data/docs/stability.md +145 -34
- data/docs/status.md +43 -0
- data/docs/syntax-sessions.md +183 -0
- data/docs/table-artifact.md +125 -0
- data/docs/test-interactions.md +219 -0
- data/docs/verification-report.md +137 -0
- data/docs/verifier-trust-boundary.md +199 -0
- data/docs/workloads.md +132 -0
- data/lib/ibex/analysis/digraph.rb +128 -0
- data/lib/ibex/analysis/sets.rb +14 -0
- data/lib/ibex/analysis.rb +1 -0
- data/lib/ibex/bison_import/importer.rb +516 -0
- data/lib/ibex/bison_import/tokenizer.rb +260 -0
- data/lib/ibex/bison_import.rb +200 -0
- data/lib/ibex/bounded_subprocess.rb +171 -0
- data/lib/ibex/cli/ambiguity.rb +14 -5
- data/lib/ibex/cli/analysis.rb +134 -0
- data/lib/ibex/cli/bison_import.rb +121 -0
- data/lib/ibex/cli/config.rb +128 -0
- data/lib/ibex/cli/diagnostics.rb +31 -11
- data/lib/ibex/cli/documentation.rb +11 -8
- data/lib/ibex/cli/equiv.rb +169 -0
- data/lib/ibex/cli/error_messages.rb +11 -4
- data/lib/ibex/cli/explain.rb +14 -5
- data/lib/ibex/cli/fix.rb +203 -0
- data/lib/ibex/cli/formatting.rb +11 -10
- data/lib/ibex/cli/fuzz.rb +200 -0
- data/lib/ibex/cli/fuzz_regressions.rb +145 -0
- data/lib/ibex/cli/generation_artifacts.rb +53 -2
- data/lib/ibex/cli/generation_error_messages.rb +1 -1
- data/lib/ibex/cli/grammar_tests.rb +32 -14
- data/lib/ibex/cli/impact.rb +393 -0
- data/lib/ibex/cli/ir_tools.rb +5 -61
- data/lib/ibex/cli/outputs.rb +60 -33
- data/lib/ibex/cli/reduce.rb +202 -0
- data/lib/ibex/cli/reduce_reporting.rb +71 -0
- data/lib/ibex/cli/samples.rb +49 -23
- data/lib/ibex/cli/verify.rb +116 -0
- data/lib/ibex/cli/watch.rb +6 -5
- data/lib/ibex/cli.rb +362 -56
- data/lib/ibex/codegen/action_locations.rb +1 -1
- data/lib/ibex/codegen/action_method_source.rb +5 -6
- data/lib/ibex/codegen/action_source.rb +3 -2
- data/lib/ibex/codegen/ambiguity.rb +5 -4
- data/lib/ibex/codegen/explain.rb +123 -55
- data/lib/ibex/codegen/generated_action_abi.rb +10 -5
- data/lib/ibex/codegen/rbs.rb +15 -7
- data/lib/ibex/codegen/report.rb +25 -13
- data/lib/ibex/codegen/ruby.rb +28 -64
- data/lib/ibex/codegen/ruby_actions.rb +9 -6
- data/lib/ibex/codegen/ruby_syntax.rb +15 -9
- data/lib/ibex/configuration/analysis_grammar.rb +35 -0
- data/lib/ibex/configuration/explanation.rb +421 -0
- data/lib/ibex/configuration/inspector.rb +232 -0
- data/lib/ibex/configuration.rb +580 -0
- data/lib/ibex/coverage/collector.rb +21 -11
- data/lib/ibex/coverage/event_stream.rb +13 -7
- data/lib/ibex/coverage/report.rb +26 -18
- data/lib/ibex/coverage/runtime_event_validator.rb +30 -21
- data/lib/ibex/delta_reducer.rb +99 -0
- data/lib/ibex/diff.rb +141 -0
- data/lib/ibex/equiv/machine.rb +135 -0
- data/lib/ibex/equiv.rb +373 -0
- data/lib/ibex/fix.rb +557 -0
- data/lib/ibex/frontend/ast.rb +22 -2
- data/lib/ibex/frontend/bootstrap_parser.rb +6 -13
- data/lib/ibex/frontend/diagnostic.rb +1 -1
- data/lib/ibex/frontend/formatter.rb +72 -26
- data/lib/ibex/frontend/generated_parser.rb +147 -117
- data/lib/ibex/frontend/generated_parser_base.rb +7 -3
- data/lib/ibex/frontend/generated_parser_includes.rb +1 -11
- data/lib/ibex/frontend/generation.rb +1 -1
- data/lib/ibex/frontend/parser/declarations.rb +17 -2
- data/lib/ibex/frontend/parser_configuration_support.rb +56 -0
- data/lib/ibex/frontend/regenerator.rb +1 -0
- data/lib/ibex/frontend/resolution.rb +2 -1
- data/lib/ibex/frontend/resolver.rb +1 -1
- data/lib/ibex/frontend/rule_documentation.rb +2 -1
- data/lib/ibex/frontend/source_cursor.rb +2 -2
- data/lib/ibex/frontend/source_span.rb +9 -1
- data/lib/ibex/frontend/token_adapter/declaration_state.rb +38 -6
- data/lib/ibex/frontend/token_adapter.rb +10 -0
- data/lib/ibex/frontend.rb +1 -0
- data/lib/ibex/fuzz.rb +219 -0
- data/lib/ibex/generation_input.rb +1 -1
- data/lib/ibex/generation_manifest.rb +36 -25
- data/lib/ibex/generation_transaction.rb +1 -1
- data/lib/ibex/generation_transaction_recovery.rb +4 -4
- data/lib/ibex/generation_transaction_validation.rb +2 -2
- data/lib/ibex/grammar_tests.rb +1 -1
- data/lib/ibex/impact/action_impact.rb +148 -0
- data/lib/ibex/impact/automaton_impact.rb +57 -0
- data/lib/ibex/impact/coverage_impact.rb +53 -0
- data/lib/ibex/impact/graph.rb +132 -0
- data/lib/ibex/impact/propagation.rb +147 -0
- data/lib/ibex/impact/report.rb +273 -0
- data/lib/ibex/impact/seeds.rb +69 -0
- data/lib/ibex/impact/severity.rb +139 -0
- data/lib/ibex/impact.rb +16 -0
- data/lib/ibex/ir/automaton_ir.rb +61 -19
- data/lib/ibex/ir/grammar_ir.rb +76 -45
- data/lib/ibex/ir/lexer_ir.rb +5 -5
- data/lib/ibex/ir/parser_contract.rb +135 -0
- data/lib/ibex/ir/serialize.rb +203 -76
- data/lib/ibex/ir/validator/automaton.rb +64 -34
- data/lib/ibex/ir/validator/base.rb +51 -33
- data/lib/ibex/ir/validator/grammar.rb +113 -83
- data/lib/ibex/ir/validator/lexer.rb +2 -2
- data/lib/ibex/ir/validator.rb +2 -1
- data/lib/ibex/ir.rb +16 -3
- data/lib/ibex/lalr/build_metrics.rb +50 -2
- data/lib/ibex/lalr/builder.rb +191 -56
- data/lib/ibex/lalr/conflict_search.rb +15 -4
- data/lib/ibex/lalr/counterexample.rb +19 -14
- data/lib/ibex/lalr/direct_lookaheads.rb +110 -57
- data/lib/ibex/lalr/goto_follows.rb +229 -0
- data/lib/ibex/lalr/ielr/annotator.rb +214 -0
- data/lib/ibex/lalr/ielr/bits.rb +28 -0
- data/lib/ibex/lalr/ielr/inadequacy.rb +47 -0
- data/lib/ibex/lalr/ielr/item_lookaheads.rb +78 -0
- data/lib/ibex/lalr/ielr/pipeline.rb +75 -0
- data/lib/ibex/lalr/ielr/split_stability.rb +78 -0
- data/lib/ibex/lalr/ielr/split_state.rb +20 -0
- data/lib/ibex/lalr/ielr/state_splitter.rb +258 -0
- data/lib/ibex/lalr/ielr_partition.rb +22 -8
- data/lib/ibex/lalr/inadequacy_report.rb +50 -0
- data/lib/ibex/lalr/lookahead_propagation.rb +111 -0
- data/lib/ibex/lalr/lr0_collection.rb +121 -0
- data/lib/ibex/lalr/unreachable_states.rb +80 -0
- data/lib/ibex/lalr.rb +52 -1
- data/lib/ibex/location.rb +3 -3
- data/lib/ibex/lsp/document_handlers.rb +9 -7
- data/lib/ibex/lsp/initialization_handlers.rb +9 -7
- data/lib/ibex/lsp/navigation_handlers.rb +25 -11
- data/lib/ibex/lsp/parser_configuration_assistance.rb +149 -0
- data/lib/ibex/lsp/position_codec.rb +6 -2
- data/lib/ibex/lsp/request_handlers.rb +3 -2
- data/lib/ibex/lsp/request_support.rb +14 -7
- data/lib/ibex/lsp/server.rb +13 -11
- data/lib/ibex/lsp/symbol_index.rb +13 -13
- data/lib/ibex/lsp/symbol_index_builder.rb +30 -20
- data/lib/ibex/lsp/symbol_occurrence.rb +8 -2
- data/lib/ibex/lsp/transport.rb +13 -3
- data/lib/ibex/lsp/workspace.rb +5 -4
- data/lib/ibex/lsp/workspace_analyzer.rb +1 -1
- data/lib/ibex/lsp.rb +1 -0
- data/lib/ibex/messages/en.yml +28 -0
- data/lib/ibex/messages/ja.yml +28 -0
- data/lib/ibex/messages.rb +68 -0
- data/lib/ibex/metrics.rb +175 -0
- data/lib/ibex/normalize/declarations.rb +2 -0
- data/lib/ibex/normalize/diagnostics.rb +63 -38
- data/lib/ibex/normalize/expander.rb +5 -4
- data/lib/ibex/normalize/expression.rb +8 -6
- data/lib/ibex/normalize/grammar_builder.rb +26 -0
- data/lib/ibex/normalize/inline_expansion.rb +100 -49
- data/lib/ibex/normalize/lexer.rb +3 -3
- data/lib/ibex/normalize/parameter_ebnf_lowering.rb +11 -10
- data/lib/ibex/normalize/parameter_lowering.rb +40 -23
- data/lib/ibex/normalize/parameters.rb +31 -4
- data/lib/ibex/normalize/parser_configuration.rb +70 -0
- data/lib/ibex/normalize.rb +10 -20
- data/lib/ibex/racc_migration/report.rb +6 -3
- data/lib/ibex/rake_task.rb +1 -1
- data/lib/ibex/samples.rb +43 -13
- data/lib/ibex/table_artifact/builder.rb +266 -0
- data/lib/ibex/table_artifact/cst_projection.rb +70 -0
- data/lib/ibex/table_artifact/document.rb +39 -0
- data/lib/ibex/table_artifact/executor.rb +187 -0
- data/lib/ibex/table_artifact/serializer.rb +57 -0
- data/lib/ibex/table_artifact/validator/metadata.rb +179 -0
- data/lib/ibex/table_artifact/validator/support.rb +86 -0
- data/lib/ibex/table_artifact/validator/tables.rb +238 -0
- data/lib/ibex/table_artifact/validator.rb +253 -0
- data/lib/ibex/table_artifact.rb +88 -0
- data/lib/ibex/table_simulation/result.rb +6 -2
- data/lib/ibex/table_simulation/step.rb +3 -1
- data/lib/ibex/tables.rb +14 -0
- data/lib/ibex/verifiable_generation_bundle.rb +86 -0
- data/lib/ibex/verification_report/builder.rb +159 -0
- data/lib/ibex/verification_report/canonical_ir.rb +123 -0
- data/lib/ibex/verification_report/logical_path.rb +68 -0
- data/lib/ibex/verification_report/validator.rb +329 -0
- data/lib/ibex/verification_report.rb +69 -0
- data/lib/ibex/verify/action_correspondence.rb +138 -0
- data/lib/ibex/verify/language_witness.rb +295 -0
- data/lib/ibex/verify/reference_collection.rb +190 -0
- data/lib/ibex/verify/result.rb +73 -0
- data/lib/ibex/verify/verifier.rb +598 -0
- data/lib/ibex/verify.rb +15 -0
- data/lib/ibex/version.rb +1 -1
- data/lib/ibex/watch/runner.rb +10 -1
- data/lib/ibex/watch/source_snapshot.rb +13 -8
- data/lib/ibex.rb +11 -0
- data/schema/{automaton-ir-v1.schema.json → automaton-ir-definitions.schema.json} +6 -6
- data/schema/{automaton-ir-v2.schema.json → automaton-ir.schema.json} +14 -7
- data/schema/bison-import-v1.schema.json +106 -0
- data/schema/conflict-explanation-review-v1.schema.json +196 -0
- data/schema/conflict-explanation-study-v1.schema.json +528 -0
- data/schema/construction-profile-v1.schema.json +779 -0
- data/schema/diff-v1.schema.json +41 -0
- data/schema/direct-ielr-decision-v1.schema.json +200 -0
- data/schema/equiv-v1.schema.json +64 -0
- data/schema/error-ux-review-v1.schema.json +609 -0
- data/schema/error-ux-round2-review-v1.schema.json +191 -0
- data/schema/error-ux-round2-v1.schema.json +519 -0
- data/schema/explain-v1.schema.json +63 -1
- data/schema/fix-v1.schema.json +64 -0
- data/schema/fix-v2.schema.json +66 -0
- data/schema/fix-v3.schema.json +101 -0
- data/schema/fuzz-regression-v1.schema.json +79 -0
- data/schema/fuzz-v1.schema.json +114 -0
- data/schema/{grammar-ir-v2.schema.json → grammar-ir-extensions.schema.json} +20 -65
- data/schema/{grammar-ir-v1.schema.json → grammar-ir-foundation.schema.json} +3 -3
- data/schema/grammar-ir.schema.json +271 -0
- data/schema/ielr-benchmark-v1.schema.json +85 -0
- data/schema/impact-v1.schema.json +208 -0
- data/schema/lexer-profile-v1.schema.json +491 -0
- data/schema/metrics-v1.schema.json +60 -0
- data/schema/reduce-v1.schema.json +22 -0
- data/schema/reduce-v2.schema.json +63 -0
- data/schema/table-artifact-v1.schema.json +377 -0
- data/schema/verification-report-v1.schema.json +222 -0
- data/schema/verify-v1.schema.json +42 -0
- data/sig/ibex/analysis/digraph.rbs +19 -0
- data/sig/ibex/analysis/sets.rbs +10 -0
- data/sig/ibex/bison_import/importer.rbs +140 -0
- data/sig/ibex/bison_import/tokenizer.rbs +91 -0
- data/sig/ibex/bison_import.rbs +95 -0
- data/sig/ibex/bounded_subprocess.rbs +76 -0
- data/sig/ibex/cli/ambiguity.rbs +6 -0
- data/sig/ibex/cli/analysis.rbs +43 -0
- data/sig/ibex/cli/bison_import.rbs +32 -0
- data/sig/ibex/cli/config.rbs +35 -0
- data/sig/ibex/cli/diagnostics.rbs +16 -3
- data/sig/ibex/cli/documentation.rbs +5 -1
- data/sig/ibex/cli/equiv.rbs +49 -0
- data/sig/ibex/cli/error_messages.rbs +6 -0
- data/sig/ibex/cli/explain.rbs +6 -0
- data/sig/ibex/cli/fix.rbs +53 -0
- data/sig/ibex/cli/formatting.rbs +5 -1
- data/sig/ibex/cli/fuzz.rbs +47 -0
- data/sig/ibex/cli/fuzz_regressions.rbs +40 -0
- data/sig/ibex/cli/generation_artifacts.rbs +21 -2
- data/sig/ibex/cli/generation_error_messages.rbs +2 -2
- data/sig/ibex/cli/grammar_tests.rbs +15 -3
- data/sig/ibex/cli/impact.rbs +95 -0
- data/sig/ibex/cli/ir_tools.rbs +7 -19
- data/sig/ibex/cli/outputs.rbs +9 -3
- data/sig/ibex/cli/reduce.rbs +60 -0
- data/sig/ibex/cli/reduce_reporting.rbs +27 -0
- data/sig/ibex/cli/samples.rbs +8 -0
- data/sig/ibex/cli/verify.rbs +28 -0
- data/sig/ibex/cli/watch.rbs +2 -2
- data/sig/ibex/cli.rbs +79 -5
- data/sig/ibex/codegen/action_method_source.rbs +4 -4
- data/sig/ibex/codegen/explain.rbs +45 -25
- data/sig/ibex/codegen/generated_action_abi.rbs +14 -10
- data/sig/ibex/codegen/rbs.rbs +12 -10
- data/sig/ibex/codegen/report.rbs +12 -12
- data/sig/ibex/codegen/ruby.rbs +18 -15
- data/sig/ibex/codegen/ruby_actions.rbs +6 -6
- data/sig/ibex/codegen/ruby_syntax.rbs +10 -8
- data/sig/ibex/configuration/analysis_grammar.rbs +13 -0
- data/sig/ibex/configuration/explanation.rbs +195 -0
- data/sig/ibex/configuration/inspector.rbs +53 -0
- data/sig/ibex/configuration.rbs +242 -0
- data/sig/ibex/coverage/collector.rbs +16 -14
- data/sig/ibex/coverage/event_stream.rbs +12 -10
- data/sig/ibex/coverage/report.rbs +20 -18
- data/sig/ibex/coverage/runtime_event_validator.rbs +38 -36
- data/sig/ibex/delta_reducer.rbs +38 -0
- data/sig/ibex/diff.rbs +47 -0
- data/sig/ibex/equiv/machine.rbs +54 -0
- data/sig/ibex/equiv.rbs +129 -0
- data/sig/ibex/fix.rbs +138 -0
- data/sig/ibex/frontend/ast.rbs +33 -7
- data/sig/ibex/frontend/bootstrap_parser.rbs +2 -0
- data/sig/ibex/frontend/diagnostic.rbs +2 -2
- data/sig/ibex/frontend/formatter.rbs +38 -30
- data/sig/ibex/frontend/generated_parser.rbs +87 -77
- data/sig/ibex/frontend/generated_parser_base.rbs +4 -2
- data/sig/ibex/frontend/parser/declarations.rbs +3 -0
- data/sig/ibex/frontend/parser_configuration_support.rbs +27 -0
- data/sig/ibex/frontend/resolution.rbs +3 -2
- data/sig/ibex/frontend/source_cursor.rbs +2 -2
- data/sig/ibex/frontend/source_span.rbs +5 -2
- data/sig/ibex/frontend/token_adapter/declaration_state.rbs +13 -1
- data/sig/ibex/frontend/token_adapter.rbs +6 -0
- data/sig/ibex/fuzz.rbs +71 -0
- data/sig/ibex/generation_input.rbs +2 -2
- data/sig/ibex/generation_manifest.rbs +35 -32
- data/sig/ibex/generation_transaction_recovery.rbs +2 -2
- data/sig/ibex/generation_transaction_validation.rbs +2 -2
- data/sig/ibex/grammar_tests.rbs +2 -2
- data/sig/ibex/impact/action_impact.rbs +58 -0
- data/sig/ibex/impact/automaton_impact.rbs +37 -0
- data/sig/ibex/impact/coverage_impact.rbs +28 -0
- data/sig/ibex/impact/graph.rbs +67 -0
- data/sig/ibex/impact/propagation.rbs +56 -0
- data/sig/ibex/impact/report.rbs +107 -0
- data/sig/ibex/impact/seeds.rbs +36 -0
- data/sig/ibex/impact/severity.rbs +55 -0
- data/sig/ibex/impact.rbs +6 -0
- data/sig/ibex/ir/automaton_ir.rbs +30 -11
- data/sig/ibex/ir/grammar_ir.rbs +41 -27
- data/sig/ibex/ir/lexer_ir.rbs +8 -8
- data/sig/ibex/ir/parser_contract.rbs +69 -0
- data/sig/ibex/ir/serialize.rbs +63 -28
- data/sig/ibex/ir/validator/automaton.rbs +47 -44
- data/sig/ibex/ir/validator/base.rbs +35 -31
- data/sig/ibex/ir/validator/grammar.rbs +78 -67
- data/sig/ibex/ir/validator/lexer.rbs +4 -4
- data/sig/ibex/ir.rbs +9 -3
- data/sig/ibex/lalr/build_metrics.rbs +42 -2
- data/sig/ibex/lalr/builder.rbs +75 -24
- data/sig/ibex/lalr/conflict_search.rbs +5 -2
- data/sig/ibex/lalr/counterexample.rbs +17 -14
- data/sig/ibex/lalr/direct_lookaheads.rbs +35 -28
- data/sig/ibex/lalr/goto_follows.rbs +89 -0
- data/sig/ibex/lalr/ielr/annotator.rbs +67 -0
- data/sig/ibex/lalr/ielr/bits.rbs +14 -0
- data/sig/ibex/lalr/ielr/inadequacy.rbs +24 -0
- data/sig/ibex/lalr/ielr/item_lookaheads.rbs +35 -0
- data/sig/ibex/lalr/ielr/pipeline.rbs +17 -0
- data/sig/ibex/lalr/ielr/split_stability.rbs +27 -0
- data/sig/ibex/lalr/ielr/split_state.rbs +14 -0
- data/sig/ibex/lalr/ielr/state_splitter.rbs +76 -0
- data/sig/ibex/lalr/ielr_partition.rbs +17 -5
- data/sig/ibex/lalr/inadequacy_report.rbs +21 -0
- data/sig/ibex/lalr/lookahead_propagation.rbs +38 -0
- data/sig/ibex/lalr/lr0_collection.rbs +50 -0
- data/sig/ibex/lalr/unreachable_states.rbs +25 -0
- data/sig/ibex/lalr.rbs +11 -1
- data/sig/ibex/location.rbs +6 -6
- data/sig/ibex/lsp/document_handlers.rbs +8 -8
- data/sig/ibex/lsp/initialization_handlers.rbs +12 -12
- data/sig/ibex/lsp/navigation_handlers.rbs +15 -12
- data/sig/ibex/lsp/parser_configuration_assistance.rbs +49 -0
- data/sig/ibex/lsp/position_codec.rbs +8 -4
- data/sig/ibex/lsp/request_handlers.rbs +4 -4
- data/sig/ibex/lsp/request_support.rbs +8 -8
- data/sig/ibex/lsp/server.rbs +16 -16
- data/sig/ibex/lsp/symbol_index.rbs +20 -21
- data/sig/ibex/lsp/symbol_index_builder.rbs +9 -8
- data/sig/ibex/lsp/symbol_occurrence.rbs +11 -5
- data/sig/ibex/lsp/transport.rbs +18 -6
- data/sig/ibex/lsp/workspace.rbs +3 -2
- data/sig/ibex/lsp/workspace_analyzer.rbs +1 -1
- data/sig/ibex/messages.rbs +26 -0
- data/sig/ibex/metrics.rbs +50 -0
- data/sig/ibex/normalize/diagnostics.rbs +4 -4
- data/sig/ibex/normalize/expander.rbs +2 -2
- data/sig/ibex/normalize/expression.rbs +10 -8
- data/sig/ibex/normalize/grammar_builder.rbs +11 -0
- data/sig/ibex/normalize/inline_expansion.rbs +59 -50
- data/sig/ibex/normalize/lexer.rbs +4 -4
- data/sig/ibex/normalize/parameter_ebnf_lowering.rbs +15 -14
- data/sig/ibex/normalize/parameter_lowering.rbs +18 -18
- data/sig/ibex/normalize/parameters.rbs +13 -8
- data/sig/ibex/normalize/parser_configuration.rbs +23 -0
- data/sig/ibex/normalize.rbs +11 -5
- data/sig/ibex/racc_migration/report.rbs +8 -6
- data/sig/ibex/rake_task.rbs +1 -1
- data/sig/ibex/samples.rbs +13 -4
- data/sig/ibex/table_artifact/builder.rbs +93 -0
- data/sig/ibex/table_artifact/cst_projection.rbs +20 -0
- data/sig/ibex/table_artifact/document.rbs +27 -0
- data/sig/ibex/table_artifact/executor.rbs +66 -0
- data/sig/ibex/table_artifact/serializer.rbs +25 -0
- data/sig/ibex/table_artifact/validator/metadata.rbs +52 -0
- data/sig/ibex/table_artifact/validator/support.rbs +46 -0
- data/sig/ibex/table_artifact/validator/tables.rbs +63 -0
- data/sig/ibex/table_artifact/validator.rbs +66 -0
- data/sig/ibex/table_artifact.rbs +32 -0
- data/sig/ibex/table_simulation/result.rbs +8 -4
- data/sig/ibex/table_simulation/step.rbs +4 -2
- data/sig/ibex/tables.rbs +10 -9
- data/sig/ibex/verifiable_generation_bundle.rbs +24 -0
- data/sig/ibex/verification_report/builder.rbs +53 -0
- data/sig/ibex/verification_report/canonical_ir.rbs +41 -0
- data/sig/ibex/verification_report/logical_path.rbs +34 -0
- data/sig/ibex/verification_report/validator.rbs +114 -0
- data/sig/ibex/verification_report.rbs +44 -0
- data/sig/ibex/verify/action_correspondence.rbs +50 -0
- data/sig/ibex/verify/language_witness.rbs +112 -0
- data/sig/ibex/verify/reference_collection.rbs +63 -0
- data/sig/ibex/verify/result.rbs +52 -0
- data/sig/ibex/verify/verifier.rbs +170 -0
- data/sig/ibex/verify.rbs +6 -0
- data/sig/ibex/watch/runner.rbs +12 -2
- data/sig/ibex/watch/source_snapshot.rbs +13 -9
- metadata +254 -12
- data/lib/ibex/ir/migration.rb +0 -120
- data/sig/ibex/ir/migration.rbs +0 -34
data/lib/ibex/codegen/report.rb
CHANGED
|
@@ -12,23 +12,25 @@ module Ibex
|
|
|
12
12
|
# Array[String] lines,
|
|
13
13
|
# IR::AutomatonState state,
|
|
14
14
|
# IR::Grammar grammar,
|
|
15
|
-
# Array[
|
|
15
|
+
# Array[LALR::search_counterexample] examples,
|
|
16
16
|
# Hash[Integer, String] labels
|
|
17
17
|
# ) -> void
|
|
18
18
|
# private def self.append_state: (
|
|
19
19
|
# Array[String] lines,
|
|
20
20
|
# IR::AutomatonState state,
|
|
21
21
|
# IR::Grammar grammar,
|
|
22
|
-
# Array[
|
|
22
|
+
# Array[LALR::search_counterexample] examples,
|
|
23
23
|
# Hash[Integer, String] labels
|
|
24
24
|
# ) -> void
|
|
25
|
-
# private def append_counterexample: (Array[String] lines,
|
|
25
|
+
# private def append_counterexample: (Array[String] lines, LALR::search_counterexample example,
|
|
26
|
+
# IR::Grammar grammar,
|
|
26
27
|
# Hash[Integer, String] labels) -> void
|
|
27
|
-
# private def self.append_counterexample: (Array[String] lines,
|
|
28
|
+
# private def self.append_counterexample: (Array[String] lines, LALR::search_counterexample example,
|
|
29
|
+
# IR::Grammar grammar,
|
|
28
30
|
# Hash[Integer, String] labels) -> void
|
|
29
|
-
# private def append_tree: (Array[String] lines,
|
|
31
|
+
# private def append_tree: (Array[String] lines, Object? tree, String indentation, IR::Grammar grammar,
|
|
30
32
|
# Hash[Integer, String] labels) -> void
|
|
31
|
-
# private def self.append_tree: (Array[String] lines,
|
|
33
|
+
# private def self.append_tree: (Array[String] lines, Object? tree, String indentation, IR::Grammar grammar,
|
|
32
34
|
# Hash[Integer, String] labels) -> void
|
|
33
35
|
# private def format_item: (IR::AutomatonItem item, IR::Grammar grammar, Hash[Integer, String] labels) -> String
|
|
34
36
|
# private def self.format_item: (IR::AutomatonItem item, IR::Grammar grammar,
|
|
@@ -37,14 +39,14 @@ module Ibex
|
|
|
37
39
|
# private def self.format_action: (IR::parser_action action) -> String
|
|
38
40
|
# private def symbol_name: (Hash[Integer, String] labels, Integer id) -> String
|
|
39
41
|
# private def self.symbol_name: (Hash[Integer, String] labels, Integer id) -> String
|
|
40
|
-
# private def tree_label: (IR::Grammar grammar, Hash[Integer, String] labels,
|
|
41
|
-
# private def self.tree_label: (IR::Grammar grammar, Hash[Integer, String] labels,
|
|
42
|
+
# private def tree_label: (IR::Grammar grammar, Hash[Integer, String] labels, Object? value) -> Object?
|
|
43
|
+
# private def self.tree_label: (IR::Grammar grammar, Hash[Integer, String] labels, Object? value) -> Object?
|
|
42
44
|
# private def display_conflict: (IR::conflict conflict, IR::Grammar grammar,
|
|
43
|
-
# Hash[Integer, String] labels) -> Hash[Symbol,
|
|
45
|
+
# Hash[Integer, String] labels) -> Hash[Symbol, Object?]
|
|
44
46
|
# private def self.display_conflict: (IR::conflict conflict, IR::Grammar grammar,
|
|
45
|
-
# Hash[Integer, String] labels) -> Hash[Symbol,
|
|
46
|
-
# private def format_value: (
|
|
47
|
-
# private def self.format_value: (
|
|
47
|
+
# Hash[Integer, String] labels) -> Hash[Symbol, Object?]
|
|
48
|
+
# private def format_value: (Object? value) -> String
|
|
49
|
+
# private def self.format_value: (Object? value) -> String
|
|
48
50
|
|
|
49
51
|
# @rbs (IR::Automaton automaton, ?max_tokens: Integer, ?max_configurations: Integer) -> String
|
|
50
52
|
def render(automaton, max_tokens: LALR::Counterexample::DEFAULT_MAX_TOKENS,
|
|
@@ -88,10 +90,20 @@ module Ibex
|
|
|
88
90
|
|
|
89
91
|
# @rbs skip
|
|
90
92
|
def append_counterexample(lines, example, grammar, labels)
|
|
91
|
-
label = example[:unifying]
|
|
93
|
+
label = if example[:unifying]
|
|
94
|
+
"unifying counterexample"
|
|
95
|
+
elsif example[:inconclusive]
|
|
96
|
+
"inconclusive reachability witness"
|
|
97
|
+
else
|
|
98
|
+
"nonunifying witness"
|
|
99
|
+
end
|
|
92
100
|
sentence = example[:sentence].map { |name| tree_label(grammar, labels, name) }
|
|
93
101
|
sentence = sentence.dup.insert(example[:lookahead_index], "•").join(" ")
|
|
94
102
|
lines << " #{label}: #{sentence}"
|
|
103
|
+
if example[:inconclusive]
|
|
104
|
+
search = example.fetch(:search)
|
|
105
|
+
lines << " search exhausted after #{search.fetch(:explored)} configurations; no classification was made"
|
|
106
|
+
end
|
|
95
107
|
example[:interpretations].each do |interpretation|
|
|
96
108
|
lines << " #{interpretation[:kind]} derivation:"
|
|
97
109
|
append_tree(lines, interpretation[:tree], " ", grammar, labels)
|
data/lib/ibex/codegen/ruby.rb
CHANGED
|
@@ -24,58 +24,6 @@ module Ibex
|
|
|
24
24
|
include RubyAST
|
|
25
25
|
include RubySyntax
|
|
26
26
|
|
|
27
|
-
EMBEDDED_RUNTIME_SOURCES = %w[
|
|
28
|
-
../runtime/version.rb
|
|
29
|
-
../runtime/table_format.rb
|
|
30
|
-
../runtime/location_span.rb
|
|
31
|
-
../runtime/cst/kind.rb
|
|
32
|
-
../runtime/cst/annotation.rb
|
|
33
|
-
../runtime/cst/green/trivia.rb
|
|
34
|
-
../runtime/cst/green/token.rb
|
|
35
|
-
../runtime/cst/green/node.rb
|
|
36
|
-
../runtime/cst/green/cache.rb
|
|
37
|
-
../runtime/cst/green/builder.rb
|
|
38
|
-
../runtime/cst/source_text.rb
|
|
39
|
-
../runtime/cst/syntax_token.rb
|
|
40
|
-
../runtime/cst/syntax_node.rb
|
|
41
|
-
../runtime/cst/cursor.rb
|
|
42
|
-
../runtime/cst/typed_node.rb
|
|
43
|
-
../runtime/cst/parse_result.rb
|
|
44
|
-
../runtime/cst/editing.rb
|
|
45
|
-
../runtime/cst/text_edit.rb
|
|
46
|
-
../runtime/cst/rewriter.rb
|
|
47
|
-
../runtime/cst/editor.rb
|
|
48
|
-
../runtime/cst/diff.rb
|
|
49
|
-
../runtime/cst/serialized_tree.rb
|
|
50
|
-
../runtime/cst/validator.rb
|
|
51
|
-
../runtime/cst/serialize.rb
|
|
52
|
-
../runtime/cst/incremental/token_memo.rb
|
|
53
|
-
../runtime/cst/incremental/relexer.rb
|
|
54
|
-
../runtime/cst/incremental/parse_memo.rb
|
|
55
|
-
../runtime/cst/incremental/lexed_syntax.rb
|
|
56
|
-
../runtime/cst/incremental/blender.rb
|
|
57
|
-
../runtime/cst/incremental/session.rb
|
|
58
|
-
../runtime/cst.rb
|
|
59
|
-
../runtime/ast_data.rb
|
|
60
|
-
../runtime/resource_limits.rb
|
|
61
|
-
../runtime/event_sanitizer.rb
|
|
62
|
-
../runtime/event.rb
|
|
63
|
-
../runtime/observation.rb
|
|
64
|
-
../runtime/repair.rb
|
|
65
|
-
../runtime/repair_priority_queue.rb
|
|
66
|
-
../runtime/repair_search.rb
|
|
67
|
-
../runtime/parser_sync_recovery.rb
|
|
68
|
-
../runtime/parser.rb
|
|
69
|
-
../runtime/lexer_input.rb
|
|
70
|
-
../runtime/generated_lexer.rb
|
|
71
|
-
../runtime/jsonl_tracer.rb
|
|
72
|
-
../runtime/event_jsonl_tracer.rb
|
|
73
|
-
../tables/compact.rb
|
|
74
|
-
../tables/compact_actions.rb
|
|
75
|
-
../tables/compact_productions.rb
|
|
76
|
-
].freeze #: Array[String]
|
|
77
|
-
private_constant :EMBEDDED_RUNTIME_SOURCES
|
|
78
|
-
|
|
79
27
|
# @rbs @automaton: IR::Automaton
|
|
80
28
|
# @rbs @grammar: IR::Grammar
|
|
81
29
|
# @rbs @table_format: Symbol
|
|
@@ -100,6 +48,7 @@ module Ibex
|
|
|
100
48
|
cst_trivia: :leading, runtime_require: "ibex/runtime", error_messages: {})
|
|
101
49
|
@automaton = automaton
|
|
102
50
|
@grammar = automaton.grammar
|
|
51
|
+
reject_foreign_actions
|
|
103
52
|
@table_format = table.to_sym
|
|
104
53
|
@embedded = embedded
|
|
105
54
|
@line_convert = line_convert
|
|
@@ -146,22 +95,37 @@ module Ibex
|
|
|
146
95
|
|
|
147
96
|
private
|
|
148
97
|
|
|
98
|
+
# @rbs () -> void
|
|
99
|
+
def reject_foreign_actions
|
|
100
|
+
production = @grammar.productions.find do |entry|
|
|
101
|
+
entry.action&.code&.include?(foreign_action_sentinel)
|
|
102
|
+
end
|
|
103
|
+
return unless production
|
|
104
|
+
|
|
105
|
+
location = production.action&.location
|
|
106
|
+
rendered = location ? "#{location[:file]}:#{location[:line]}:#{location[:column]}" : "(codegen):1:1"
|
|
107
|
+
raise Ibex::Error,
|
|
108
|
+
"#{rendered}: cannot generate Ruby from imported C semantic actions; use analysis commands only"
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
# Kept local so the generic generator does not load the optional Bison
|
|
112
|
+
# importer and its IR validation graph.
|
|
113
|
+
# @rbs () -> String
|
|
114
|
+
def foreign_action_sentinel
|
|
115
|
+
"__ibex_foreign_action_c__"
|
|
116
|
+
end
|
|
117
|
+
|
|
149
118
|
# @rbs (Array[String] lines) -> void
|
|
150
119
|
def append_runtime(lines)
|
|
151
120
|
if @embedded
|
|
152
|
-
|
|
121
|
+
require "ibex/runtime/embedded_source"
|
|
122
|
+
lines << Runtime::EmbeddedSource.render
|
|
153
123
|
elsif @runtime_require
|
|
154
124
|
lines << "require #{@runtime_require.inspect}"
|
|
155
125
|
end
|
|
156
126
|
lines << ""
|
|
157
127
|
end
|
|
158
128
|
|
|
159
|
-
# @rbs (String relative_path) -> String
|
|
160
|
-
def embedded_source(relative_path)
|
|
161
|
-
path = File.expand_path(relative_path, File.dirname(__FILE__))
|
|
162
|
-
File.read(path).lines.reject { |line| line.start_with?("# frozen_string_literal:") }.join.rstrip
|
|
163
|
-
end
|
|
164
|
-
|
|
165
129
|
# @rbs (Array[String] lines) -> void
|
|
166
130
|
def append_tables(lines)
|
|
167
131
|
table_set = Tables.build(@automaton, format: @table_format)
|
|
@@ -250,12 +214,12 @@ module Ibex
|
|
|
250
214
|
@grammar.conversions.empty?
|
|
251
215
|
end
|
|
252
216
|
|
|
253
|
-
# @rbs () ->
|
|
217
|
+
# @rbs () -> CSTMetadata::metadata
|
|
254
218
|
def cst_metadata
|
|
255
219
|
@cst_metadata ||= CSTMetadata.new(@grammar, trivia_policy: @cst_trivia).build
|
|
256
220
|
end
|
|
257
221
|
|
|
258
|
-
# @rbs (
|
|
222
|
+
# @rbs (Object? value) -> String
|
|
259
223
|
def deep_frozen_literal(value)
|
|
260
224
|
case value
|
|
261
225
|
when Array
|
|
@@ -272,7 +236,7 @@ module Ibex
|
|
|
272
236
|
end
|
|
273
237
|
end
|
|
274
238
|
|
|
275
|
-
# @rbs (
|
|
239
|
+
# @rbs (Object? table) -> String
|
|
276
240
|
def table_literal(table)
|
|
277
241
|
if table.is_a?(Tables::CompactActions)
|
|
278
242
|
return "Ibex::Tables::CompactActions.packed(#{packed_integers_literal(table.offsets)}, " \
|
|
@@ -286,12 +250,12 @@ module Ibex
|
|
|
286
250
|
"row_count: #{table.row_count}, dense_width: #{table.dense_width})"
|
|
287
251
|
end
|
|
288
252
|
|
|
289
|
-
# @rbs (Array[
|
|
253
|
+
# @rbs (Array[untyped] values) -> String
|
|
290
254
|
def packed_integers_literal(values)
|
|
291
255
|
Tables::PackedIntegers.encode(values).inspect
|
|
292
256
|
end
|
|
293
257
|
|
|
294
|
-
# @rbs (Array[
|
|
258
|
+
# @rbs (Array[untyped] values) -> String
|
|
295
259
|
def packed_signed_integers_literal(values)
|
|
296
260
|
Tables::PackedIntegers.encode_signed(values).inspect
|
|
297
261
|
end
|
|
@@ -48,16 +48,19 @@ module Ibex
|
|
|
48
48
|
append_composed_orchestrator(lines, production, plan)
|
|
49
49
|
end
|
|
50
50
|
|
|
51
|
-
# @rbs (Array[String] lines, IR::Production production,
|
|
51
|
+
# @rbs (Array[String] lines, IR::Production production, IR::action_composition_step step, Integer index) -> void
|
|
52
52
|
def append_composed_fragment_method(lines, production, step, index)
|
|
53
53
|
source = action_method_source.composed_fragment_method_source(production, step, index)
|
|
54
54
|
if @line_convert
|
|
55
55
|
location = step.fetch(:loc)
|
|
56
56
|
lines << " class_eval(#{source.dump}, #{location[:file].inspect}, #{location[:line]})"
|
|
57
|
-
elsif action_method_source.column_sensitive?(step.fetch(:code))
|
|
58
|
-
lines << source
|
|
59
57
|
else
|
|
60
|
-
|
|
58
|
+
code = step.fetch(:code) #: String
|
|
59
|
+
if action_method_source.column_sensitive?(code)
|
|
60
|
+
lines << source
|
|
61
|
+
else
|
|
62
|
+
source.lines.each { |line| lines << " #{line.rstrip}" }
|
|
63
|
+
end
|
|
61
64
|
end
|
|
62
65
|
lines << ""
|
|
63
66
|
end
|
|
@@ -67,7 +70,7 @@ module Ibex
|
|
|
67
70
|
action_method_source.composed_fragment_name(production, index)
|
|
68
71
|
end
|
|
69
72
|
|
|
70
|
-
# @rbs (Array[String] lines, IR::Production production,
|
|
73
|
+
# @rbs (Array[String] lines, IR::Production production, IR::action_composition_plan plan) -> void
|
|
71
74
|
def append_composed_orchestrator(lines, production, plan)
|
|
72
75
|
lines << " private def _ibex_action_#{production.id}" \
|
|
73
76
|
"(val, _values, _ibex_locations, _ibex_location_stack, _ibex_location, " \
|
|
@@ -80,7 +83,7 @@ module Ibex
|
|
|
80
83
|
lines.push(" _ibex_composed_values.last", " end", "")
|
|
81
84
|
end
|
|
82
85
|
|
|
83
|
-
# @rbs (Array[String] lines, IR::Production production,
|
|
86
|
+
# @rbs (Array[String] lines, IR::Production production, IR::action_composition_step step, Integer index) -> void
|
|
84
87
|
def append_composed_step(lines, production, step, index)
|
|
85
88
|
inputs = step.fetch(:inputs)
|
|
86
89
|
lines << " _ibex_step_values = _ibex_composed_values.values_at(#{inputs.join(', ')})"
|
|
@@ -5,6 +5,9 @@ module Ibex
|
|
|
5
5
|
module Codegen
|
|
6
6
|
# Generates typed Red syntax views from @node metadata.
|
|
7
7
|
module RubySyntax
|
|
8
|
+
# @rbs!
|
|
9
|
+
# type syntax_definition = Hash[Symbol, untyped]
|
|
10
|
+
|
|
8
11
|
private
|
|
9
12
|
|
|
10
13
|
# @rbs (Array[String] lines) -> void
|
|
@@ -18,11 +21,12 @@ module Ibex
|
|
|
18
21
|
lines.push(" end", "")
|
|
19
22
|
end
|
|
20
23
|
|
|
21
|
-
# @rbs () -> Hash[String,
|
|
24
|
+
# @rbs () -> Hash[String, syntax_definition]
|
|
22
25
|
def syntax_node_definitions
|
|
23
26
|
# @type self: Ruby
|
|
24
|
-
|
|
25
|
-
|
|
27
|
+
metadata = cst_metadata #: CSTMetadata::metadata
|
|
28
|
+
slots = metadata.fetch(:slots)
|
|
29
|
+
definitions = {} #: Hash[String, syntax_definition]
|
|
26
30
|
@grammar.productions.each do |production|
|
|
27
31
|
node = production.node
|
|
28
32
|
next unless node
|
|
@@ -36,7 +40,7 @@ module Ibex
|
|
|
36
40
|
definitions
|
|
37
41
|
end
|
|
38
42
|
|
|
39
|
-
# @rbs (Hash[String,
|
|
43
|
+
# @rbs (Hash[String, CSTMetadata::field_slot] left, Hash[String, CSTMetadata::field_slot] right) -> Hash[String, CSTMetadata::field_slot]
|
|
40
44
|
def merge_syntax_fields(left, right)
|
|
41
45
|
left.to_h do |name, left_slot|
|
|
42
46
|
right_slot = right.fetch(name)
|
|
@@ -48,7 +52,7 @@ module Ibex
|
|
|
48
52
|
end.freeze
|
|
49
53
|
end
|
|
50
54
|
|
|
51
|
-
# @rbs (Array[String] lines,
|
|
55
|
+
# @rbs (Array[String] lines, syntax_definition definition) -> void
|
|
52
56
|
def append_syntax_node(lines, definition)
|
|
53
57
|
name = definition.fetch(:name)
|
|
54
58
|
fields = definition.fetch(:fields)
|
|
@@ -65,12 +69,13 @@ module Ibex
|
|
|
65
69
|
lines.push(" end", "")
|
|
66
70
|
end
|
|
67
71
|
|
|
68
|
-
# @rbs (Array[String] lines, Hash[String,
|
|
72
|
+
# @rbs (Array[String] lines, Hash[String, CSTMetadata::field_slot] fields) -> void
|
|
69
73
|
def append_repetition_accessors(lines, fields)
|
|
70
74
|
repeated = fields.select { |_field, slot| slot.is_a?(Hash) && slot[:extraction] }
|
|
71
75
|
repeated.each do |field, slot|
|
|
72
|
-
|
|
73
|
-
|
|
76
|
+
typed_slot = slot #: Hash[Symbol, untyped]
|
|
77
|
+
index = typed_slot.fetch(:index) #: Integer
|
|
78
|
+
separated = typed_slot.fetch(:extraction) == :separated_list
|
|
74
79
|
lines << " def each_#{field}_element = list_items(#{index}, separated: #{separated})"
|
|
75
80
|
next unless separated
|
|
76
81
|
|
|
@@ -80,8 +85,9 @@ module Ibex
|
|
|
80
85
|
return unless repeated.one?
|
|
81
86
|
|
|
82
87
|
field, slot = repeated.first
|
|
88
|
+
typed_slot = slot #: Hash[Symbol, untyped]
|
|
83
89
|
lines << " alias each_element each_#{field}_element"
|
|
84
|
-
return unless
|
|
90
|
+
return unless typed_slot.fetch(:extraction) == :separated_list
|
|
85
91
|
|
|
86
92
|
lines << " alias each_separator each_#{field}_separator"
|
|
87
93
|
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
# rbs_inline: enabled
|
|
3
|
+
|
|
4
|
+
module Ibex
|
|
5
|
+
module Configuration
|
|
6
|
+
# Produces an immutable Grammar IR view suitable for an explicitly
|
|
7
|
+
# noncanonical analysis algorithm. The source-owned contract remains the
|
|
8
|
+
# authority; callers must report the override through Configuration::Value.
|
|
9
|
+
module AnalysisGrammar
|
|
10
|
+
module_function
|
|
11
|
+
|
|
12
|
+
# @rbs (IR::Grammar grammar, Symbol algorithm) -> IR::Grammar
|
|
13
|
+
def for_algorithm(grammar, algorithm)
|
|
14
|
+
contract = grammar.parser_contract
|
|
15
|
+
return grammar unless contract&.algorithm&.explicit
|
|
16
|
+
return grammar if contract.algorithm.value == algorithm
|
|
17
|
+
|
|
18
|
+
analysis_contract = IR::ParserContract.new(
|
|
19
|
+
algorithm: IR::ParserContract::Entry.new(:algorithm),
|
|
20
|
+
entries: contract.entries, cst_trivia: contract.cst_trivia
|
|
21
|
+
)
|
|
22
|
+
IR::Grammar.new(
|
|
23
|
+
class_name: grammar.class_name, superclass: grammar.superclass, start: grammar.start,
|
|
24
|
+
expect: grammar.expect, options: grammar.options, symbols: grammar.symbols,
|
|
25
|
+
productions: grammar.productions, user_code: grammar.user_code, conversions: grammar.conversions,
|
|
26
|
+
warnings: grammar.warnings, expect_rr: grammar.expect_rr, user_code_chunks: grammar.user_code_chunks,
|
|
27
|
+
source_provenance: grammar.source_provenance,
|
|
28
|
+
parser_parameters: grammar.parser_parameters, value_printers: grammar.value_printers,
|
|
29
|
+
grammar_tests: grammar.grammar_tests, recovery: grammar.recovery, lexer: grammar.lexer,
|
|
30
|
+
mode: grammar.mode, starts: grammar.starts, parser_contract: analysis_contract
|
|
31
|
+
)
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|