Class: Ibex::Runtime::RepairPolicy
- Inherits:
-
Object
- Object
- Ibex::Runtime::RepairPolicy
- Defined in:
- lib/json5/generated_parser.rb
Overview
Explicit bounded cost and search policy for automatic token repair.
Instance Attribute Summary collapse
- #delete_cost ⇒ Object readonly
- #insert_cost ⇒ Object readonly
- #max_configurations ⇒ Object readonly
- #max_cost ⇒ Object readonly
- #max_lookahead ⇒ Object readonly
- #max_stack ⇒ Object readonly
- #replace_cost ⇒ Object readonly
- #success_shifts ⇒ Object readonly
Instance Method Summary collapse
-
#initialize(insert_cost: 1, delete_cost: 1, replace_cost: 2, max_cost: 3, max_configurations: 5_000, max_lookahead: 8, success_shifts: 3, max_stack: 256) ⇒ RepairPolicy
constructor
A new instance of RepairPolicy.
Constructor Details
#initialize(insert_cost: 1, delete_cost: 1, replace_cost: 2, max_cost: 3, max_configurations: 5_000, max_lookahead: 8, success_shifts: 3, max_stack: 256) ⇒ RepairPolicy
Returns a new instance of RepairPolicy.
4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501 4502 4503 4504 4505 |
# File 'lib/json5/generated_parser.rb', line 4487 def initialize(insert_cost: 1, delete_cost: 1, replace_cost: 2, max_cost: 3, max_configurations: 5_000, max_lookahead: 8, success_shifts: 3, max_stack: 256) values = { insert_cost: insert_cost, delete_cost: delete_cost, replace_cost: replace_cost, max_cost: max_cost, max_configurations: max_configurations, max_lookahead: max_lookahead, success_shifts: success_shifts, max_stack: max_stack } invalid = values.find { |_name, value| !value.is_a?(Integer) || !value.positive? } raise ArgumentError, "#{invalid.first} must be a positive integer" if invalid raise ArgumentError, "success_shifts must not exceed max_lookahead" if success_shifts > max_lookahead values.each { |name, value| instance_variable_set(:"@#{name}", value) } freeze end |
Instance Attribute Details
#delete_cost ⇒ Object (readonly)
4476 4477 4478 |
# File 'lib/json5/generated_parser.rb', line 4476 def delete_cost @delete_cost end |
#insert_cost ⇒ Object (readonly)
4475 4476 4477 |
# File 'lib/json5/generated_parser.rb', line 4475 def insert_cost @insert_cost end |
#max_configurations ⇒ Object (readonly)
4479 4480 4481 |
# File 'lib/json5/generated_parser.rb', line 4479 def max_configurations @max_configurations end |
#max_cost ⇒ Object (readonly)
4478 4479 4480 |
# File 'lib/json5/generated_parser.rb', line 4478 def max_cost @max_cost end |
#max_lookahead ⇒ Object (readonly)
4480 4481 4482 |
# File 'lib/json5/generated_parser.rb', line 4480 def max_lookahead @max_lookahead end |
#max_stack ⇒ Object (readonly)
4482 4483 4484 |
# File 'lib/json5/generated_parser.rb', line 4482 def max_stack @max_stack end |
#replace_cost ⇒ Object (readonly)
4477 4478 4479 |
# File 'lib/json5/generated_parser.rb', line 4477 def replace_cost @replace_cost end |
#success_shifts ⇒ Object (readonly)
4481 4482 4483 |
# File 'lib/json5/generated_parser.rb', line 4481 def success_shifts @success_shifts end |