Class: BinaryParser::Expression::BinaryOperator
- Inherits:
-
BinaryParser::Expression
- Object
- BinaryParser::Expression
- BinaryParser::Expression::BinaryOperator
- Defined in:
- lib/general_class/expression.rb
Instance Method Summary collapse
- #check_op(op) ⇒ Object
-
#initialize(chl, chr, op) ⇒ BinaryOperator
constructor
A new instance of BinaryOperator.
- #to_rpn ⇒ Object
Methods inherited from BinaryParser::Expression
#%, #*, #+, #-, #/, #binary_op, #coerce, control_var, #control_var?, #eval, immediate, #immediate?, length_var, #length_var?, nextbits_var, #nextbits_var?, #to_exp, value_var, #value_var?, #variable_tokens
Constructor Details
#initialize(chl, chr, op) ⇒ BinaryOperator
Returns a new instance of BinaryOperator.
99 100 101 102 |
# File 'lib/general_class/expression.rb', line 99 def initialize(chl, chr, op) check_op(op) @chl, @chr, @op = to_exp(chl), to_exp(chr), op end |
Instance Method Details
#check_op(op) ⇒ Object
104 105 106 107 108 |
# File 'lib/general_class/expression.rb', line 104 def check_op(op) unless op.is_a?(Token::Operator) raise BadManipulationError, "Argument should be Token::Operator." end end |
#to_rpn ⇒ Object
110 111 112 |
# File 'lib/general_class/expression.rb', line 110 def to_rpn @rpn ||= @chl.to_rpn + @chr.to_rpn + @op.to_rpn end |