module Operator

Copyright © 2016 Freescale Semiconductor Inc.

Public Instance Methods

arity() click to toggle source

@return [Fixnum] number of arguments required

# File lib/re_duxml/evaluate/operator.rb, line 90
def arity
  nodes.find do |n|
    return n.text.to_i if n.name == 'arity'
  end
  2
end
grouping?() click to toggle source

@return [Boolean]

# File lib/re_duxml/evaluate/operator.rb, line 4
def grouping?
  nodes.find do |n|
    return true if n.name == 'pair'
  end
  false
end
inverse() click to toggle source
# File lib/re_duxml/evaluate/operator.rb, line 63
def inverse
  nodes.find do |n|
    return @logic[n.text] if n.name == 'inverse'
  end
  nil
end
pair() click to toggle source
# File lib/re_duxml/evaluate/operator.rb, line 55
def pair
  return nil unless grouping?
  nodes.find do |n|
    return @logic[n.text] if n.name == 'pair'
  end
  raise Exception
end
parent=(logic) click to toggle source
# File lib/re_duxml/evaluate/operator.rb, line 11
def parent=(logic)
  @logic = logic
end
position() click to toggle source

@return [Symbol] :prefix, :infix (default), or :postfix

# File lib/re_duxml/evaluate/operator.rb, line 41
def position
  nodes.find do |n|
    return n.text.to_sym if n.name == 'position'
  end
  :infix
end
print() click to toggle source
regexp() click to toggle source

@return [Regexp] expression to find operator in string

# File lib/re_duxml/evaluate/operator.rb, line 82
def regexp
  nodes.find do |n|
    return Regexp.new(n.text) if %w(regexp symbol ).include?(n.name)
  end
  # TODO exception here?
end
reverse() click to toggle source
# File lib/re_duxml/evaluate/operator.rb, line 48
def reverse
  nodes.find do |n|
    return @logic[n.text] if n.name == 'reverse'
  end
  nil
end
right_associative?() click to toggle source

@return [Boolean]

# File lib/re_duxml/evaluate/operator.rb, line 16
def right_associative?
  nodes.find do |n|
    return n.text == 'true' if n.name == 'right_associative'
  end
  false
end
ruby() click to toggle source

@return [String] name of ruby method corresponding to this operator

# File lib/re_duxml/evaluate/operator.rb, line 24
def ruby
  nodes.find do |n|
    return n.text if n.name == 'ruby'
  end
  symbol
end
symbol() click to toggle source

@return [String] literal for operator e.g. '+'

# File lib/re_duxml/evaluate/operator.rb, line 32
def symbol
  return nil unless self.respond_to?(:nodes)
  nodes.find do |n|
    return n.text if n.name == 'symbol'
  end
  raise Exception
end
to_s() click to toggle source
# File lib/re_duxml/evaluate/operator.rb, line 70
def to_s
  symbol
end