Class: BELParser::Language::Semantics::NonObjectList
- Inherits:
-
Object
- Object
- BELParser::Language::Semantics::NonObjectList
- Includes:
- SemanticsFunction
- Defined in:
- lib/bel_parser/language/semantics/non_object_list.rb
Overview
NonObjectList implements a SemanticsFunction that maps a Parsers::AST::Object to a SemanticsWarning if the object of a multiple relationship *is not* a 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/non_object_list.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? list_func = spec.function(:list) return nil unless list_func rel = spec.relationship(stmt_node.relationship.string_literal.to_sym) return nil unless rel return nil unless rel.listable? map_object(stmt_node.object, rel, list_func, spec) end |
.map_object(obj_node, rel, list_func, spec) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/bel_parser/language/semantics/non_object_list.rb', line 28 def self.map_object(obj_node, rel, list_func, spec) return NonObjectListWarning.new( obj_node, spec, rel) unless obj_node.term? obj_func = obj_node.child.function.identifier.string_literal NonObjectListWarning.new( obj_node, spec, rel) unless spec.function(obj_func.to_sym) == list_func end |