package Expressions.Operators is
type Binary_Operator is abstract new Expression with private;
type A_Binary_Operator is access all Binary_Operator'Class;
function Create_Binary_Operator( token : not null A_Token ) return A_Binary_Operator;
function Get_Precedence( this : not null access Binary_Operator'Class ) return Positive;
procedure Set_Operands( this : not null access Binary_Operator'Class;
left, right : in out A_Expression );
pragma Precondition( left /= null );
pragma Precondition( right /= null );
pragma Postcondition( left = null );
pragma Postcondition( right = null );
function Is_Binary( tokenType : Token_Type ) return Boolean;
type Unary_Operator is abstract new Expression with private;
type A_Unary_Operator is access all Unary_Operator'Class;
function Create_Unary_Operator( token : not null A_Token ) return A_Unary_Operator;
procedure Set_Operand( this : not null access Unary_Operator'Class;
right : in out A_Expression );
pragma Precondition( right /= null );
pragma Postcondition( right = null );
function Is_Unary( tokenType : Token_Type ) return Boolean;
private
type Binary_Operator is abstract new Expression with
record
precedence : Positive;
left : A_Expression;
right : A_Expression;
end record;
procedure Construct( this : access Binary_Operator;
loc : Token_Location;
precedence : Positive );
procedure Delete( this : in out Binary_Operator );
type Add_Op is new Binary_Operator with null record;
function Evaluate( this : access Add_Op;
context : not null A_Eval_Context ) return A_Value;
type And_Op is new Binary_Operator with null record;
function Evaluate( this : access And_Op;
context : not null A_Eval_Context ) return A_Value;
type Divide_Op is new Binary_Operator with null record;
function Evaluate( this : access Divide_Op;
context : not null A_Eval_Context ) return A_Value;
type Equals_Op is new Binary_Operator with null record;
function Evaluate( this : access Equals_Op;
context : not null A_Eval_Context ) return A_Value;
type Greater_Op is new Binary_Operator with null record;
function Evaluate( this : access Greater_Op;
context : not null A_Eval_Context ) return A_Value;
type Greater_Equals_Op is new Binary_Operator with null record;
function Evaluate( this : access Greater_Equals_Op;
context : not null A_Eval_Context ) return A_Value;
type Less_Op is new Binary_Operator with null record;
function Evaluate( this : access Less_Op;
context : not null A_Eval_Context ) return A_Value;
type Less_Equals_Op is new Binary_Operator with null record;
function Evaluate( this : access Less_Equals_Op;
context : not null A_Eval_Context ) return A_Value;
type Mod_Op is new Binary_Operator with null record;
function Evaluate( this : access Mod_Op;
context : not null A_Eval_Context ) return A_Value;
type Multiply_Op is new Binary_Operator with null record;
function Evaluate( this : access Multiply_Op;
context : not null A_Eval_Context ) return A_Value;
type Not_Equals_Op is new Binary_Operator with null record;
function Evaluate( this : access Not_Equals_Op;
context : not null A_Eval_Context ) return A_Value;
type Or_Op is new Binary_Operator with null record;
function Evaluate( this : access Or_Op;
context : not null A_Eval_Context ) return A_Value;
type Subtract_Op is new Binary_Operator with null record;
function Evaluate( this : access Subtract_Op;
context : not null A_Eval_Context ) return A_Value;
type Unary_Operator is abstract new Expression with
record
right : A_Expression;
end record;
procedure Delete( this : in out Unary_Operator );
type Negate_Op is new Unary_Operator with null record;
function Evaluate( this : access Negate_Op;
context : not null A_Eval_Context ) return A_Value;
type Not_Op is new Unary_Operator with null record;
function Evaluate( this : access Not_Op;
context : not null A_Eval_Context ) return A_Value;
end Expressions.Operators;