Class: Ibex::Runtime::SyntaxRepairer
- Inherits:
-
Object
- Object
- Ibex::Runtime::SyntaxRepairer
- Defined in:
- lib/ibex/runtime/syntax_repair.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.
230 231 232 233 234 235 236 237 238 239 240 241 |
# File 'lib/ibex/runtime/syntax_repair.rb', line 230 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
244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 |
# File 'lib/ibex/runtime/syntax_repair.rb', line 244 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 |