Class: BELParser::Language::Semantics::SemanticAminoAcidOf

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

Overview

AST node for AminoAcidOf is a semantic AST.

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(amino_acids, **properties) ⇒ SemanticAminoAcidOf

Returns a new instance of SemanticAminoAcidOf.



713
714
715
716
# File 'lib/bel_parser/language/semantics_ast.rb', line 713

def initialize(amino_acids, **properties)
  properties[:hashed] = Hash[amino_acids.map { |t| [t, true] }]
  super(:amino_acid_of, amino_acids, properties)
end

Instance Method Details

#amino_acidsObject



718
719
720
# File 'lib/bel_parser/language/semantics_ast.rb', line 718

def amino_acids
  children
end

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



722
723
724
725
726
727
728
729
730
731
# File 'lib/bel_parser/language/semantics_ast.rb', line 722

def match(value_node, spec, will_match_partial = false)
  string_literal_sym = value_node.children[0].string_literal.to_sym
  return success(value_node, spec) if @hashed[:*]

  if @hashed.key?(string_literal_sym)
    success(value_node, spec)
  else
    invalid_amino_acid_warning(value_node, spec, @hashed.keys)
  end
end