Class: BELParser::Language::Semantics::SemanticIsAminoAcidRange

Inherits:
SemanticASTNode show all
Defined in:
lib/bel_parser/language/semantics_ast.rb

Overview

AST node for IsAminoAcidRange is a semantic AST.

Constant Summary collapse

START_STOP =
/[1-9][0-9]*_[1-9][0-9]*/
UNDETERMINED =
/[1?]_[?*]/
UNKNOWN_START_STOP =
'?'.freeze

Instance Attribute Summary

Attributes inherited from AST::Node

#children, #hash, #type

Instance Method Summary collapse

Methods inherited from SemanticASTNode

#terminal?

Methods inherited from AST::Node

#==, #append, #concat, #dup, #eql?, #inspect, #to_a, #to_ast, #to_bel, #to_s, #to_sexp, #updated

Methods included from Parsers

#serialize

Constructor Details

#initialize(**properties) ⇒ SemanticIsAminoAcidRange

Returns a new instance of SemanticIsAminoAcidRange.



740
741
742
# File 'lib/bel_parser/language/semantics_ast.rb', line 740

def initialize(**properties)
  super(:is_amino_acid_range, [], properties)
end

Instance Method Details

#match(value_node, spec, will_match_partial = false) ⇒ Object



744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
# File 'lib/bel_parser/language/semantics_ast.rb', line 744

def match(value_node, spec, will_match_partial = false)
  ident_or_string = value_node.children[0]
  value =
    case ident_or_string
    when BELParser::Parsers::AST::String
      ident_or_string.string_value
    else
      ident_or_string.string_literal
    end

  case value
  when START_STOP, UNDETERMINED, UNKNOWN_START_STOP
    success(value_node, spec)
  else
    invalid_amino_acid_range_warning(value_node, spec)
  end
end