class BELParser::Language::Semantics::SemanticTerm

AST node for Term is a semantic AST.

Public Class Methods

new(children = [], **properties) click to toggle source
# File lib/bel_parser/language/semantics_ast.rb, line 257
def initialize(children = [], **properties)
  super(:term, children, properties)
end

Public Instance Methods

arguments() click to toggle source
# File lib/bel_parser/language/semantics_ast.rb, line 269
def arguments
  children[1..-1]
end
function() click to toggle source
# File lib/bel_parser/language/semantics_ast.rb, line 261
def function
  children[0]
end
match(parse_node, spec, will_match_partial = false) click to toggle source
# File lib/bel_parser/language/semantics_ast.rb, line 273
def match(parse_node, spec, will_match_partial = false)
  return nil_node_warning(
    parse_node,
    spec,
    BELParser::Parsers::AST::Term) if parse_node.nil?
  return type_warning(
    parse_node,
    spec,
    BELParser::Parsers::AST::Term,
    parse_node) if parse_node.type != type

  # Allowed empty.
  if arguments.empty? || variadic_arguments?
    success(parse_node, spec)
  # Partial match on arity.
  elsif will_match_partial && parse_node.arguments.length < arguments.length
    success(parse_node, spec)
  # Or, check full arity
  elsif arguments.length == parse_node.arguments.length
    success(parse_node, spec)
  # Mismatch, warning
  else
    argument_length_warning(
      parse_node,
      spec,
      self,
      parse_node)
  end
end
variadic_arguments?() click to toggle source
# File lib/bel_parser/language/semantics_ast.rb, line 265
def variadic_arguments?
  children[1].type == :variadic_arguments
end