Class: Ibex::Verify::Verifier

Inherits:
Object
  • Object
show all
Defined in:
lib/ibex/verify/verifier.rb

Overview

Checks Automaton IR semantics against an independently derived collection. rubocop:disable Metrics/ClassLength -- V1-V9 share one violation and item-identity model.

Constant Summary collapse

DEFAULT_CHECKS =

: Array

%w[V1 V3 V4 V6 V7 V8].freeze
STRICT_CHECKS =

: Array

%w[V2 V5 V9].freeze
ERROR_ACTION =

: IR::error_action

{ type: :error }.freeze

Instance Method Summary collapse

Constructor Details

#initialize(automaton, strict: false, max_states: 100_000, max_items: 1_000_000) ⇒ Verifier

Returns a new instance of Verifier.



14
15
16
17
18
19
20
21
22
# File 'lib/ibex/verify/verifier.rb', line 14

def initialize(automaton, strict: false, max_states: 100_000, max_items: 1_000_000)
  @automaton = automaton
  @grammar = automaton.grammar
  @strict = strict
  @max_states = max_states
  @max_items = max_items
  @violations = [] #: Array[Violation]
  @sets = Analysis::Sets.new(@grammar)
end

Instance Method Details

#verifyObject



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/ibex/verify/verifier.rb', line 25

def verify
  @violations.clear
  verify_grammar_digest
  verify_item_collection
  verify_transitions_and_actions
  verify_table_formats
  verify_reachability_and_productivity
  verify_epsilon_termination
  verify_conflict_determinism
  verify_ielr_adequacy if @strict
  Result.new(
    algorithm: @automaton.algorithm, strict: @strict,
    checks: DEFAULT_CHECKS + (@strict ? STRICT_CHECKS : []),
    violations: @violations,
    bounds: { max_states: @max_states, max_items: @max_items }
  )
end