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
- .map(stmt_node, spec, _namespaces, will_match_partial = false) ⇒ Object
- .map_object(obj_node, rel, list_func, spec) ⇒ Object
Class Method Details
.map(stmt_node, spec, _namespaces, will_match_partial = false) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/bel_parser/language/semantics/non_object_list.rb', line 14 def self.map(stmt_node, spec, _namespaces, will_match_partial = false) return nil unless stmt_node.is_a?(BELParser::Parsers::AST::Statement) return nil unless stmt_node.relationship? return nil unless stmt_node.object? 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
30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/bel_parser/language/semantics/non_object_list.rb', line 30 def self.map_object(obj_node, rel, list_func, spec) return NonObjectListWarning.new( obj_node, spec, rel) unless obj_node.term? return nil unless obj_node.child.function 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 |