Sha256: 39ba609e36e3babe0aade74784630b79814cc8b78a900658def0c6042f2fb7d5

Contents?: true

Size: 1.23 KB

Versions: 4

Compression:

Stored size: 1.23 KB

Contents

require 'bel_parser/parsers/ast/node'

module BELParser
  module Language
    module Semantics
      # NestedStatementWithoutObject implements a {SemanticsFunction} that maps a
      # nested {BELParser::Parsers::AST::Statement} to {SemanticsWarning} if
      # the nested statement does not have an object.
      class NestedStatementWithoutObject
        include SemanticsFunction

        private_class_method :new

        def self.map(node, spec, _namespaces)
          return nil unless node.is_a?(BELParser::Parsers::AST::Statement)
          return nil unless node.object? && node.object.statement?

          nested = node.object.child

          unless nested.object?
            NestedStatementWithoutObjectWarning.new(node, spec)
          end
        end
      end

      # Represents a {SemanticsWarning} when a nested
      # {BELParser::Parsers::AST::Statement} does not have an object.
      class NestedStatementWithoutObjectWarning < SemanticsWarning
        attr_reader :non_causal_relationship

        def initialize(stmt_node, spec)
          super(stmt_node, spec)
        end

        def to_s
          <<-MSG.gsub(/ {12}/, '')
            Nested statement does not have an object.
          MSG
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
bel_parser-1.1.3-java lib/bel_parser/language/semantics/nested_statement_without_object.rb
bel_parser-1.1.3 lib/bel_parser/language/semantics/nested_statement_without_object.rb
bel_parser-1.1.2-java lib/bel_parser/language/semantics/nested_statement_without_object.rb
bel_parser-1.1.2 lib/bel_parser/language/semantics/nested_statement_without_object.rb