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.56 lib/bel_parser/language/signature.rb
bel_parser-1.0.0.alpha.55-java lib/bel_parser/language/signature.rb
bel_parser-1.0.0.alpha.55 lib/bel_parser/language/signature.rb
bel_parser-1.0.0.alpha.54-java lib/bel_parser/language/signature.rb
bel_parser-1.0.0.alpha.54 lib/bel_parser/language/signature.rb
bel_parser-1.0.0.alpha.53-java lib/bel_parser/language/signature.rb
bel_parser-1.0.0.alpha.53 lib/bel_parser/language/signature.rb
bel_parser-1.0.0.alpha.52-java lib/bel_parser/language/signature.rb
bel_parser-1.0.0.alpha.52 lib/bel_parser/language/signature.rb
bel_parser-1.0.0.alpha.51-java lib/bel_parser/language/signature.rb
bel_parser-1.0.0.alpha.51 lib/bel_parser/language/signature.rb
bel_parser-1.0.0.alpha.50-java lib/bel_parser/language/signature.rb
bel_parser-1.0.0.alpha.50 lib/bel_parser/language/signature.rb
bel_parser-1.0.0.alpha.49-java lib/bel_parser/language/signature.rb
bel_parser-1.0.0.alpha.49 lib/bel_parser/language/signature.rb
bel_parser-1.0.0.alpha.48-java lib/bel_parser/language/signature.rb
bel_parser-1.0.0.alpha.48 lib/bel_parser/language/signature.rb
bel_parser-1.0.0.alpha.47-java lib/bel_parser/language/signature.rb
bel_parser-1.0.0.alpha.47 lib/bel_parser/language/signature.rb
bel_parser-1.0.0.alpha.46-java lib/bel_parser/language/signature.rb