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.36 lib/bel_parser/language/signature.rb
bel_parser-1.0.0.alpha.35-java lib/bel_parser/language/signature.rb
bel_parser-1.0.0.alpha.35 lib/bel_parser/language/signature.rb
bel_parser-1.0.0.alpha.34-java lib/bel_parser/language/signature.rb
bel_parser-1.0.0.alpha.34 lib/bel_parser/language/signature.rb
bel_parser-1.0.0.alpha.32-java lib/bel_parser/language/signature.rb
bel_parser-1.0.0.alpha.32 lib/bel_parser/language/signature.rb
bel_parser-1.0.0.alpha.31-java lib/bel_parser/language/signature.rb
bel_parser-1.0.0.alpha.31 lib/bel_parser/language/signature.rb
bel_parser-1.0.0.alpha.30-java lib/bel_parser/language/signature.rb
bel_parser-1.0.0.alpha.30 lib/bel_parser/language/signature.rb
bel_parser-1.0.0.alpha.29-java lib/bel_parser/language/signature.rb
bel_parser-1.0.0.alpha.29 lib/bel_parser/language/signature.rb
bel_parser-1.0.0.alpha.28-java lib/bel_parser/language/signature.rb
bel_parser-1.0.0.alpha.28 lib/bel_parser/language/signature.rb
bel_parser-1.0.0.alpha.27-java lib/bel_parser/language/signature.rb
bel_parser-1.0.0.alpha.27 lib/bel_parser/language/signature.rb
bel_parser-1.0.0.alpha.26 lib/bel_parser/language/signature.rb
bel_parser-1.0.0.alpha.25 lib/bel_parser/language/signature.rb
bel_parser-1.0.0.alpha.24 lib/bel_parser/language/signature.rb