Class: BELParser::Language::Semantics::MultipleSubjectObject
- Inherits:
-
Object
- Object
- BELParser::Language::Semantics::MultipleSubjectObject
- Includes:
- SemanticsFunction
- Defined in:
- lib/bel_parser/language/semantics/multiple_subject_object.rb
Overview
MultipleSubjectObject implements a SemanticsFunction that maps a Parsers::AST::Statement to a SemanticsWarning if the subject term is referenced as an argument of the object list term.
Class Method Summary collapse
Class Method Details
.map(stmt_node, spec, _namespaces) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/bel_parser/language/semantics/multiple_subject_object.rb', line 14 def self.map(stmt_node, spec, _namespaces) return nil unless stmt_node.is_a?(BELParser::Parsers::AST::Statement) return nil if stmt_node.relationship.string_literal.nil? rel = spec.relationship(stmt_node.relationship.string_literal.to_sym) return nil unless rel return nil unless rel.listable? list_func = spec.function(:list) return nil unless list_func return nil unless stmt_node.object.term? map_subject_object(stmt_node, rel, spec) end |
.map_subject_object(stmt_node, rel, spec) ⇒ Object
28 29 30 31 32 33 34 35 |
# File 'lib/bel_parser/language/semantics/multiple_subject_object.rb', line 28 def self.map_subject_object(stmt_node, rel, spec) sub_term = stmt_node.subject.term list_term = stmt_node.object.child if list_term.arguments.any? { |arg| sub_term == arg.child } MultipleSubjectObjectWarning.new(stmt_node, spec, rel) end end |