Class: Ibex::LALR::InadequacyReport

Inherits:
Object
  • Object
show all
Defined in:
lib/ibex/lalr/inadequacy_report.rb,
sig/ibex/lalr/inadequacy_report.rbs

Overview

Diagnostic-only report for canonical-vs-LALR action differences. It is intentionally separate from normal construction because it enumerates a canonical LR(1) reference.

Instance Method Summary collapse

Constructor Details

#initialize(canonical, target, max_pairs: nil) ⇒ InadequacyReport

Returns a new instance of InadequacyReport.

RBS:

  • (IR::Automaton canonical, IR::Automaton target, ?max_pairs: Integer) -> void

Parameters:



19
20
21
22
23
# File 'lib/ibex/lalr/inadequacy_report.rb', line 19

def initialize(canonical, target, max_pairs: nil)
  @canonical = canonical
  @target = target
  @max_pairs = max_pairs
end

Instance Method Details

#to_hHash[Symbol, report_value]

RBS:

  • () -> Hash[Symbol, report_value]

Returns:

  • (Hash[Symbol, report_value])


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

def to_h
  result = Verify::ActionCorrespondence.new(@canonical, @target, max_pairs: @max_pairs).verify
  {
    algorithm: @target.algorithm,
    canonical_algorithm: @canonical.algorithm,
    explored_pairs: result.explored,
    truncated: result.truncated,
    differences: result.differences.map do |difference|
      {
        kind: difference.kind, canonical_state: difference.canonical_state,
        target_state: difference.target_state, symbol: difference.symbol,
        canonical: difference.canonical, target: difference.target
      }
    end
  }
end

#to_jsonString

RBS:

  • () -> String

Returns:

  • (String)


44
45
46
# File 'lib/ibex/lalr/inadequacy_report.rb', line 44

def to_json(*)
  "#{JSON.pretty_generate(to_h)}\n"
end