Class: Ibex::Runtime::SyntaxRepairer
- Inherits:
-
Object
- Object
- Ibex::Runtime::SyntaxRepairer
- Defined in:
- lib/json5/generated_parser.rb
Overview
Executes one fresh syntax-only repair attempt without mutating its source SyntaxSession. Generated lexer actions retain the acknowledged trust profile; parser production actions remain suppressed.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(parser_class, source, baseline, execution_profile:, resource_limits:, limits:, cancellation:, policy:, token_text:) ⇒ SyntaxRepairer
constructor
A new instance of SyntaxRepairer.
Constructor Details
#initialize(parser_class, source, baseline, execution_profile:, resource_limits:, limits:, cancellation:, policy:, token_text:) ⇒ SyntaxRepairer
Returns a new instance of SyntaxRepairer.
5296 5297 5298 5299 5300 5301 5302 5303 5304 5305 5306 5307 |
# File 'lib/json5/generated_parser.rb', line 5296 def initialize(parser_class, source, baseline, execution_profile:, resource_limits:, limits:, cancellation:, policy:, token_text:) @parser_class = parser_class @source = source @baseline = baseline @execution_profile = execution_profile @resource_limits = resource_limits @limits = limits @cancellation = cancellation @policy = validate_policy(policy) @token_text = validate_token_text(token_text) end |
Instance Method Details
#call ⇒ Object
5310 5311 5312 5313 5314 5315 5316 5317 5318 5319 5320 5321 5322 5323 5324 5325 5326 5327 5328 5329 5330 5331 |
# File 'lib/json5/generated_parser.rb', line 5310 def call cancellation_checkpoint! parser = @parser_class.__send__(:new, resource_limits: @resource_limits) captures = install_capture(parser) parser.repair_policy = @policy parser.observe { |_event| cancellation_checkpoint! } parsed = parser.__send__(:parse_syntax_with_cache, @source, CST::NodeCache.new) cancellation_checkpoint! diagnostics = immutable_diagnostics(parsed.diagnostics) return unavailable(:repair_source_not_consumed, parsed, diagnostics) unless @source.text.start_with?(parsed.syntax_root.to_source) outcomes = parser.__send__(:syntax_repair_search_results) return bounded_failure(:exhausted, :search_exhausted, parsed, diagnostics) if outcomes.any? { |outcome| outcome.status == :exhausted } return bounded_failure(:not_found, :no_repair_plan, parsed, diagnostics) if captures.empty? return unavailable(:multiple_repair_segments, parsed, diagnostics) unless captures.one? build_selected(captures.fetch(0), parsed, diagnostics) rescue ResourceLimitError => e raise SyntaxSessionResourceLimitError.new(resource: e.resource, limit: e.limit, observed: e.observed), cause: e end |