Detailed Description

Represents any pair of brackets.

Inheritance diagram for Nitro.BracketFragment:
Nitro.CodeFragment Nitro.BaseFragment

Public Member Functions

 BracketFragment ()
 
 BracketFragment (CodeLexer sr)
 Creates a new BracketFragment. More...
 
 BracketFragment (CodeLexer sr, bool readBracket)
 Creates a new BracketFragment. More...
 
override bool Typeable ()
 Defines if a fragment can be given a :TYPE. E.g. Brackets (for casting, (A):TYPE) and variables can. More...
 
override CompiledFragment Compile (CompiledMethod method)
 Attempts to compile this fragment into the given method. More...
 
bool CompileBody (CompiledMethod method)
 Attempts to compile this bracket to IL, assuming it is the body of a method. More...
 
override AddResult AddTo (CodeFragment to, CodeLexer sr)
 Adds this fragment as a child to the given fragment. It may be overriden by some types of fragment as they may wish to handle it differently. More...
 
override string ToString ()
 
- Public Member Functions inherited from Nitro.CodeFragment
void Error (string message)
 Throws an error, outputting the line number it occured on. More...
 
virtual bool IsMemberAccessor ()
 A value which states if this fragment accesses members (methods/fields) of something. More...
 
virtual int GetLineNumber ()
 Returns the line number this fragment came from. More...
 
void AddToStart (CodeFragment parent)
 Adds this code fragment to the beginning of the given parents child set. More...
 
void AddBefore (CodeFragment frag)
 Adds this code fragment as a child before the given one. More...
 
void AddAfter (CodeFragment frag)
 Adds this code fragment as a child after the given one. More...
 
void Remove ()
 Removes this fragment from its parent. More...
 
void AddChild (CodeFragment child)
 Adds the given fragment as a child of this one. More...
 
int ChildCount ()
 How many children does this fragment have? More...
 
override string ToString ()
 Converts this fragment into a code string. More...
 

Static Public Member Functions

static bool WillHandle (char character)
 Checks if the given character can be handled by a bracket fragment. More...
 
static int IsBracket (char character)
 Checks if the given character is an opening bracket. More...
 
static int IsEndBracket (char character)
 Checks if the given character is an closing bracket. More...
 
static bool AnyBracket (char character)
 Checks if the given character is either an opening or closing bracket. More...
 
- Static Public Member Functions inherited from Nitro.CodeFragment
static int IsOfType (char[] arrayToSearch, char charToFind)
 Returns the index in the given array of the given character if it's found in it. More...
 

Public Attributes

char Bracket =StringReader.NULL
 The opening bracket character. E.g. (,{,[. More...
 
char CloseBracket =StringReader.NULL
 The closing bracket character. E.g. ),},]. More...
 
- Public Attributes inherited from Nitro.CodeFragment
TypeFragment GivenType
 A type (:TYPE) which was explicitly given to this block. More...
 
CodeFragment NextChild
 The child after this one. More...
 
CodeFragment LastChild
 The last child of this fragment, stored as a linked list. More...
 
CodeFragment FirstChild
 The first child of this fragment, stored as a linked list. More...
 
CodeFragment PreviousChild
 The child before this one. More...
 
CodeFragment ParentFragment
 The parent fragment of this, if any. More...
 

Static Public Attributes

static char[] Brackets =new char[]{'(','[','{'}
 The set of opening brackets. More...
 
static char[] EndBrackets =new char[]{')',']','}'}
 The set of closing brackets. More...
 

Additional Inherited Members

- Properties inherited from Nitro.CodeFragment
bool IsParent [get]
 Is this fragment a parent or not? More...
 

Constructor & Destructor Documentation

Nitro.BracketFragment.BracketFragment ( )
inline
Nitro.BracketFragment.BracketFragment ( CodeLexer  sr)
inline

Creates a new BracketFragment.

Parameters
srThe lexer to read the bracket content from.
Nitro.BracketFragment.BracketFragment ( CodeLexer  sr,
bool  readBracket 
)
inline

Creates a new BracketFragment.

Parameters
srThe lexer to read the bracket content from.
readBracketTrue if the brackets should be read off (i.e. the first thing done is read a single character). False otherwise.

Member Function Documentation

override AddResult Nitro.BracketFragment.AddTo ( CodeFragment  to,
CodeLexer  sr 
)
inlinevirtual

Adds this fragment as a child to the given fragment. It may be overriden by some types of fragment as they may wish to handle it differently.

Parameters
toThe parent to add this fragment to.
srThe lexer containing the original text code.

Reimplemented from Nitro.CodeFragment.

static bool Nitro.BracketFragment.AnyBracket ( char  character)
inlinestatic

Checks if the given character is either an opening or closing bracket.

Parameters
characterThe character to check.
Returns
True if the character is an opening or closing bracket; false otherwise.
override CompiledFragment Nitro.BracketFragment.Compile ( CompiledMethod  method)
inlinevirtual

Attempts to compile this fragment into the given method.

Parameters
methodThe method to compile it into.

Reimplemented from Nitro.CodeFragment.

bool Nitro.BracketFragment.CompileBody ( CompiledMethod  method)
inline

Attempts to compile this bracket to IL, assuming it is the body of a method.

Parameters
methodThe method that is being compiled.
Returns
True if the method returns something.
static int Nitro.BracketFragment.IsBracket ( char  character)
inlinestatic

Checks if the given character is an opening bracket.

Parameters
characterThe character to check.
Returns
The index of the bracket if it is one; -1 otherwise. ( is 0, [ is 1, { is 2.
static int Nitro.BracketFragment.IsEndBracket ( char  character)
inlinestatic

Checks if the given character is an closing bracket.

Parameters
characterThe character to check.
Returns
The index of the bracket if it is one; -1 otherwise. ) is 0, ] is 1, } is 2.
override string Nitro.BracketFragment.ToString ( )
inline
override bool Nitro.BracketFragment.Typeable ( )
inlinevirtual

Defines if a fragment can be given a :TYPE. E.g. Brackets (for casting, (A):TYPE) and variables can.

Returns
True if it can, false otherwise.

Reimplemented from Nitro.CodeFragment.

static bool Nitro.BracketFragment.WillHandle ( char  character)
inlinestatic

Checks if the given character can be handled by a bracket fragment.

Parameters
characterThe character to check.
Returns
True if it's an opening bracket; false otherwise.

Member Data Documentation

char Nitro.BracketFragment.Bracket =StringReader.NULL

The opening bracket character. E.g. (,{,[.

char [] Nitro.BracketFragment.Brackets =new char[]{'(','[','{'}
static

The set of opening brackets.

char Nitro.BracketFragment.CloseBracket =StringReader.NULL

The closing bracket character. E.g. ),},].

char [] Nitro.BracketFragment.EndBrackets =new char[]{')',']','}'}
static

The set of closing brackets.