Class: Jaina::Parser::Expression::Operator::Abstract Private

Inherits:
Object
  • Object
show all
Includes:
DSL
Defined in:
lib/jaina/parser/expression/operator/abstract.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Since:

  • 0.1.0

Direct Known Subclasses

Grouping, NonTerminal, Terminal

Defined Under Namespace

Modules: DSL

Constant Summary collapse

Error =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Since:

  • 0.1.0

Class.new(StandardError)
InompatibleDirectionComparisonError =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Since:

  • 0.1.0

Class.new(Error)

Constants included from DSL

DSL::IncorrectAssociativityDirectionError, DSL::IncorrectPrecedenceLevelError, DSL::IncorrectTokenError, DSL::LEFT_ASSOC, DSL::RIGHT_ASSOC

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from DSL

included

Constructor Details

#initialize(arguments: [], expressions: []) ⇒ void

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameters:

  • arguments (Hash) (defaults to: [])

    a customizable set of options

  • expressions (Hash) (defaults to: [])

    a customizable set of options

Options Hash (arguments:):

  • (Array<Any>)

Options Hash (expressions:):

Since:

  • 0.1.0



55
56
57
58
# File 'lib/jaina/parser/expression/operator/abstract.rb', line 55

def initialize(arguments: [], expressions: [])
  @arguments   = arguments
  @expressions = expressions
end

Instance Attribute Details

#argumentsArray<Any> (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Array<Any>)

Since:

  • 0.4.0



41
42
43
# File 'lib/jaina/parser/expression/operator/abstract.rb', line 41

def arguments
  @arguments
end

#expressionsArray<Jaina::Parser::Expressions::Operator::Abstract> (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Array<Jaina::Parser::Expressions::Operator::Abstract>)

Since:

  • 0.1.0



47
48
49
# File 'lib/jaina/parser/expression/operator/abstract.rb', line 47

def expressions
  @expressions
end

Class Method Details

.lower?(another_operator) ⇒ Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameters:

Returns:

  • (Boolean)

Raises:

Since:

  • 0.1.0



23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/jaina/parser/expression/operator/abstract.rb', line 23

def lower?(another_operator)
  raise(
    InompatibleDirectionComparisonError,
    "Trying to compare non-comparable terms `#{token}` and `#{another_operator.token}`"
  ) if associativity_direction.nil? || another_operator.associativity_direction.nil?

  if associativity_direction == Jaina::Parser::Expression::Operator::Abstract::DSL::LEFT_ASSOC
    associativity_direction <= another_operator.associativity_direction
  else
    associativity_direction < another_operator.associativity_direction
  end
end

Instance Method Details

#evaluate(context) ⇒ Any

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameters:

  • context (Any)

Returns:

  • (Any)

Since:

  • 0.1.0



65
# File 'lib/jaina/parser/expression/operator/abstract.rb', line 65

def evaluate(context); end

#lower(another_operator) ⇒ Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameters:

Returns:

  • (Boolean)

Since:

  • 0.1.0



72
73
74
# File 'lib/jaina/parser/expression/operator/abstract.rb', line 72

def lower(another_operator)
  self.class.lower(another_operator)
end