Sha256: dded352280614331b74d6b8778cc0f15fc81a389010ad2c3b6edc6424dfc206d

Contents?: true

Size: 848 Bytes

Versions: 3

Compression:

Stored size: 848 Bytes

Contents

# frozen_string_literal: true

module Lrama
  class Diagnostics
    def initialize(grammar, states, logger)
      @grammar = grammar
      @states = states
      @logger = logger
    end

    def run(diagnostic)
      if diagnostic
        diagnose_conflict
        diagnose_parameterizing_redefined
      end
    end

    private

    def diagnose_conflict
      if @states.sr_conflicts_count != 0
        @logger.warn("shift/reduce conflicts: #{@states.sr_conflicts_count} found")
      end

      if  @states.rr_conflicts_count != 0
        @logger.warn("reduce/reduce conflicts: #{@states.rr_conflicts_count} found")
      end
    end

    def diagnose_parameterizing_redefined
      @grammar.parameterizing_rule_resolver.redefined_rules.each do |rule|
        @logger.warn("parameterizing rule redefined: #{rule}")
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
lrama-0.7.0 lib/lrama/diagnostics.rb
lrama-0.6.11 lib/lrama/diagnostics.rb
lrama-0.6.10 lib/lrama/diagnostics.rb