Class RParsec::OperatorTable
In: rparsec/expressions.rb
Parent: Object

This class holds information about operator precedences and associativities. prefix, postfix, infixl, infixr, infixn can be called to register operators.

Methods

infixl   infixn   infixr   new   postfix   prefix   reinit  

Attributes

operators  [R]  operators attribute is used internally. Do not access it.

Public Class methods

To create an OperatorTable instance. If a block is given, it is invoked to do post-instantiation. For example:

OperatorTable.new do |tbl|

  tbl.infixl(char(?+) >> Plus, 10)
  tbl.infixl(char(?-) >> Minus, 10)
  tbl.infixl(char(?*) >> Mul, 20)
  tbl.infixl(char(?/) >> Div, 20)
  tbl.prefix(char(?-) >> Neg, 50)

end

Public Instance methods

Defines a left associative infix operator that returns a binary Proc object with a precedence associated. Returns self.

Defines a non-associative infix operator that returns a binary Proc object with a precedence associated. Returns self.

Defines a right associative infix operator that returns a binary Proc object with a precedence associated. Returns self.

Defines a postfix operator that returns a unary Proc object with a precedence associated. Returns self.

Defines a prefix operator that returns a unary Proc object with a precedence associated. Returns self.

Re-initialize the operator table. Internal use only.

[Validate]