Class: RParsec::OperatorTable

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

new() {|this| ...}

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

infixl(op, precedence)

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

infixn(op, precedence)

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

infixr(op, precedence)

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

postfix(op, precedence)

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

prefix(op, precedence)

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

reinit()

Re-initialize the operator table. Internal use only.

[Validate]