Class: BELParser::Script::Syntax::UndefinedAnnotation

Inherits:
Object
  • Object
show all
Extended by:
Language::Syntax::SyntaxFunction, Keyword
Defined in:
lib/bel_parser/script/syntax/undefined_annotation.rb

Constant Summary collapse

TARGET_NODE =
BELParser::Parsers::AST::Set

Constants included from Keyword

Keyword::BEL_VERSION_REGEX, Keyword::BEL_VERSION_STRING, Keyword::CITATION, Keyword::CITATION_REGEX, Keyword::IMPLICIT_ANNOTATIONS, Keyword::SUPPORT, Keyword::SUPPORT_REGEX

Class Method Summary collapse

Methods included from Keyword

is_bel_version?, is_citation?, is_implicit_annotation?, is_support?

Class Method Details

.map(ast_node, script_context) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/bel_parser/script/syntax/undefined_annotation.rb', line 18

def self.map(ast_node, script_context)
  return nil unless ast_node.is_a?(TARGET_NODE)
  name_string = ast_node.name.identifier.string_literal
  annotation_definitions =
    script_context[:annotation_definitions] ||= Concurrent::Hash.new

  return nil if is_implicit_annotation?(name_string)
  return nil if annotation_definitions.key?(name_string)
  UndefinedAnnotationError.new(
    ast_node,
    name_string,
    script_context[:annotation_definitions])
end