Sha256: 6be2bd531f8729a3b4d278782307fd82efdab569999fd4daee531efd4c47f806

Contents?: true

Size: 579 Bytes

Versions: 7

Compression:

Stored size: 579 Bytes

Contents

module Sexpr
  module Matcher
    class Reference
      include Matcher

      attr_reader :rule_name
      attr_reader :grammar

      def initialize(rule_name, grammar)
        @rule_name = rule_name
        @grammar   = grammar
      end

      def rule
        @rule ||= @grammar[@rule_name]
      end

      def match?(sexp)
        rule && rule.match?(sexp)
      end

      def eat(sexp)
        rule && rule.eat(sexp)
      end

      def inspect
        "(ref #{rule_name}, #{rule.inspect})"
      end

    end # class Reference
  end # module Matcher
end # module Sexpr

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
sexpr-1.1.0 lib/sexpr/matcher/reference.rb
sexpr-1.0.0 lib/sexpr/matcher/reference.rb
sexpr-0.6.0 lib/sexpr/matcher/reference.rb
sexpr-0.5.1 lib/sexpr/matcher/reference.rb
sexpr-0.5.0 lib/sexpr/matcher/reference.rb
sexpr-0.4.0 lib/sexpr/matcher/reference.rb
sexpr-0.3.0 lib/sexpr/matcher/reference.rb