jfun.parsec
Class OperatorTable<E>

java.lang.Object
  extended by jfun.parsec.OperatorTable<E>
All Implemented Interfaces:
java.io.Serializable

public final class OperatorTable<E>
extends java.lang.Object
implements java.io.Serializable

This class is used to describe operator information. Operators have precedences. the higher the precedence number, the higher the precedence. For the same precedence, prefix > postfix > left infix > right infix > non-associative infix.

Author:
Ben Yu Nov 21, 2004
See Also:
Serialized Form

Constructor Summary
OperatorTable()
           
 
Method Summary
 OperatorTable<E> infixl(Parser<? extends Map2<? super E,? super E,? extends E>> p, int precedence)
          Adds a infix left-associative binary operator.
 OperatorTable<E> infixn(Parser<? extends Map2<? super E,? super E,? extends E>> p, int precedence)
          Adds a infix non-associative binary operator.
 OperatorTable<E> infixr(Parser<? extends Map2<? super E,? super E,? extends E>> p, int precedence)
          Adds a infix right-associative binary operator.
 OperatorTable<E> postfix(Parser<? extends Map<? super E,? extends E>> p, int precedence)
          Adds a postfix unary operator.
 OperatorTable<E> prefix(Parser<? extends Map<? super E,? extends E>> p, int precedence)
          Adds a prefix unary operator.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OperatorTable

public OperatorTable()
Method Detail

prefix

public OperatorTable<E> prefix(Parser<? extends Map<? super E,? extends E>> p,
                               int precedence)
Adds a prefix unary operator.

Parameters:
p - the parser for the operator.
precedence - the precedence number.
Returns:
this.

postfix

public OperatorTable<E> postfix(Parser<? extends Map<? super E,? extends E>> p,
                                int precedence)
Adds a postfix unary operator.

Parameters:
p - the parser for the operator.
precedence - the precedence number.
Returns:
this.

infixl

public OperatorTable<E> infixl(Parser<? extends Map2<? super E,? super E,? extends E>> p,
                               int precedence)
Adds a infix left-associative binary operator.

Parameters:
p - the parser for the operator.
precedence - the precedence number.
Returns:
this.

infixr

public OperatorTable<E> infixr(Parser<? extends Map2<? super E,? super E,? extends E>> p,
                               int precedence)
Adds a infix right-associative binary operator.

Parameters:
p - the parser for the operator.
precedence - the precedence number.
Returns:
this.

infixn

public OperatorTable<E> infixn(Parser<? extends Map2<? super E,? super E,? extends E>> p,
                               int precedence)
Adds a infix non-associative binary operator.

Parameters:
p - the parser for the operator.
precedence - the precedence number.
Returns:
this.