Detailed Description

Base class of all operators (+,- etc) and a global lookup for finding an operator instance from its text. When the system starts, all operators are automatically discovered by looking for any Operator classes. You can essentially create your own by simply deriving the Operator class.

Inheritance diagram for Nitro.Operator:
Nitro.OperatorAdd Nitro.OperatorAddTo Nitro.OperatorBitwiseAnd Nitro.OperatorBitwiseOr Nitro.OperatorBitwiseXOr Nitro.OperatorDecrement Nitro.OperatorDivide Nitro.OperatorDivideInTo Nitro.OperatorGreaterThan Nitro.OperatorGreaterThanOrEql Nitro.OperatorIncrement Nitro.OperatorLessThan Nitro.OperatorLessThanOrEql Nitro.OperatorLogicAnd Nitro.OperatorLogicEql Nitro.OperatorLogicNotEql Nitro.OperatorLogicOr Nitro.OperatorLShift Nitro.OperatorModulo Nitro.OperatorModuloInTo Nitro.OperatorMultiply Nitro.OperatorMultiplyInTo Nitro.OperatorNot Nitro.OperatorRShift Nitro.OperatorSet Nitro.OperatorSubtract Nitro.OperatorSubtractFrom

Public Member Functions

 Operator (string pattern, int priority)
 Creates a new operator with the given text and priority. More...
 
Operation ToOperation (CompiledFragment left, CompiledFragment right, CompiledMethod method)
 Converts the the given fragments into a compiled operation by first checking the fragments are ok for this operator. More...
 

Static Public Member Functions

static void Add (Operator newOperator)
 Adds a useable operator to the global lookup. More...
 
static bool IsOperator (char character)
 Is the given character an operator or the start of one? More...
 

Public Attributes

int Priority
 The priority of this operator over others. Essentially implements bodmas. More...
 
bool LeftOnly
 True if this operator only uses the content to its left. e.g. LEFT++. More...
 
bool RightOnly
 True if this operator only uses the content to its right. e.g. !RIGHT. More...
 
string Pattern
 The operator text pattern, for example '+' More...
 
bool LeftAndRight =true
 True if this operator uses the content on both the left and right of it. e.g. LEFT+RIGHT. More...
 

Static Public Attributes

static Dictionary< char, int > Starts =new Dictionary<char,int>()
 The first character of an operator (as some have 2 or more; e.g. +=, &&) More...
 
static Dictionary< string,
Operator
FullOperators =new Dictionary<string,Operator>()
 A lookup for an operators text to the operator instance. e.g. '+' to the add operator. More...
 

Protected Member Functions

virtual Operation Compile (CompiledFragment left, CompiledFragment right, CompiledMethod method)
 Converts the given fragments into a compiled operation. Overidden by the actual operators. More...
 

Constructor & Destructor Documentation

Nitro.Operator.Operator ( string  pattern,
int  priority 
)
inline

Creates a new operator with the given text and priority.

Parameters
patternThe operators text, such as "+" or "++".
priorityThe priority over other operators. The higher this value, the

Member Function Documentation

static void Nitro.Operator.Add ( Operator  newOperator)
inlinestatic

Adds a useable operator to the global lookup.

Parameters
newOperatorThe operator to add.
static bool Nitro.Operator.IsOperator ( char  character)
inlinestatic

Is the given character an operator or the start of one?

Operation Nitro.Operator.ToOperation ( CompiledFragment  left,
CompiledFragment  right,
CompiledMethod  method 
)
inline

Converts the the given fragments into a compiled operation by first checking the fragments are ok for this operator.

Parameters
leftThe fragment to the left of the operator.
rightThe fragment to the right of the operation.
methodThe method the operation will be compiled into.

Member Data Documentation

Dictionary<string,Operator> Nitro.Operator.FullOperators =new Dictionary<string,Operator>()
static

A lookup for an operators text to the operator instance. e.g. '+' to the add operator.

bool Nitro.Operator.LeftAndRight =true

True if this operator uses the content on both the left and right of it. e.g. LEFT+RIGHT.

bool Nitro.Operator.LeftOnly

True if this operator only uses the content to its left. e.g. LEFT++.

string Nitro.Operator.Pattern

The operator text pattern, for example '+'

int Nitro.Operator.Priority

The priority of this operator over others. Essentially implements bodmas.

bool Nitro.Operator.RightOnly

True if this operator only uses the content to its right. e.g. !RIGHT.

Dictionary<char,int> Nitro.Operator.Starts =new Dictionary<char,int>()
static

The first character of an operator (as some have 2 or more; e.g. +=, &&)