Sha256: 0b933f6a6e52e981abef93e5424987cb65a600f1ed42cc2fe9a2f63621f481a6

Contents?: true

Size: 829 Bytes

Versions: 116

Compression:

Stored size: 829 Bytes

Contents

module BELParser
  module Language
    # Signature defines the interface for language-specific signatures used
    # to check expression semantics.
    module Signature
      include Comparable

      def semantic_ast
        raise NotImplementedError, "#{__method__} is not implemented."
      end

      def string_form
        raise NotImplementedError, "#{__method__} is not implemented."
      end

      def size
        count = 0
        nodes = [semantic_ast]
        until nodes.empty?
          n = nodes.shift
          if n
            count += 1
            nodes.concat(n.children) if n.respond_to?(:children)
          end
        end
        count
      end

      def <=>(other)
        return 1 if other.nil?
        size <=> other.size
      end

      def to_s
        string_form
      end
    end
  end
end

Version data entries

116 entries across 116 versions & 1 rubygems

Version Path
bel_parser-1.0.0.alpha.46 lib/bel_parser/language/signature.rb
bel_parser-1.0.0.alpha.45-java lib/bel_parser/language/signature.rb
bel_parser-1.0.0.alpha.45 lib/bel_parser/language/signature.rb
bel_parser-1.0.0.alpha.44-java lib/bel_parser/language/signature.rb
bel_parser-1.0.0.alpha.44 lib/bel_parser/language/signature.rb
bel_parser-1.0.0.alpha.43-java lib/bel_parser/language/signature.rb
bel_parser-1.0.0.alpha.43 lib/bel_parser/language/signature.rb
bel_parser-1.0.0.alpha.42-java lib/bel_parser/language/signature.rb
bel_parser-1.0.0.alpha.42 lib/bel_parser/language/signature.rb
bel_parser-1.0.0.alpha.41-java lib/bel_parser/language/signature.rb
bel_parser-1.0.0.alpha.41 lib/bel_parser/language/signature.rb
bel_parser-1.0.0.alpha.40-java lib/bel_parser/language/signature.rb
bel_parser-1.0.0.alpha.40 lib/bel_parser/language/signature.rb
bel_parser-1.0.0.alpha.39-java lib/bel_parser/language/signature.rb
bel_parser-1.0.0.alpha.39 lib/bel_parser/language/signature.rb
bel_parser-1.0.0.alpha.38-java lib/bel_parser/language/signature.rb
bel_parser-1.0.0.alpha.38 lib/bel_parser/language/signature.rb
bel_parser-1.0.0.alpha.37-java lib/bel_parser/language/signature.rb
bel_parser-1.0.0.alpha.37 lib/bel_parser/language/signature.rb
bel_parser-1.0.0.alpha.36-java lib/bel_parser/language/signature.rb