Class TokenPatterns
This class is able to translate a single X# source code line into one or more
target assembler source code and data lines. The class is a group of pattern each of
which defines a transformation function from the X# syntax to the target assembler
syntax.
Inheritance
System.Object
TokenPatterns
Assembly: XSharp.dll
Syntax
public class TokenPatterns : object
Constructors
|
Improve this Doc
View Source
TokenPatterns()
Declaration
Fields
|
Improve this Doc
View Source
Declaration
public bool EmitUserComments
Field Value
Type |
Description |
System.Boolean |
|
|
Improve this Doc
View Source
mBlocks
The set of blocks for the currently assembled function. Each time we begin
assembling a new function this blocks collection is reset to an empty state.
Declaration
protected TokenPatterns.Blocks mBlocks
Field Value
|
Improve this Doc
View Source
mCompareOps
Declaration
protected string[] mCompareOps
Field Value
Type |
Description |
System.String[] |
|
|
Improve this Doc
View Source
mCompares
Declaration
protected List<string> mCompares
Field Value
Type |
Description |
List<System.String> |
|
|
Improve this Doc
View Source
mFuncExitFound
Declaration
protected bool mFuncExitFound
Field Value
Type |
Description |
System.Boolean |
|
|
Improve this Doc
View Source
mFuncName
Declaration
protected string mFuncName
Field Value
Type |
Description |
System.String |
|
|
Improve this Doc
View Source
mInIntHandler
Declaration
protected bool mInIntHandler
Field Value
Type |
Description |
System.Boolean |
|
|
Improve this Doc
View Source
mNamespace
Declaration
protected string mNamespace
Field Value
Type |
Description |
System.String |
|
|
Improve this Doc
View Source
mPatterns
Declaration
protected List<TokenPatterns.Pattern> mPatterns
Field Value
Methods
|
Improve this Doc
View Source
AddPattern(String, TokenPatterns.CodeFunc)
Register a single pattern with its associated transformation handler.
Declaration
protected void AddPattern(string aPattern, TokenPatterns.CodeFunc aCode)
Parameters
Type |
Name |
Description |
System.String |
aPattern |
A single line of X# code that define the pattern optionally using
pattern reserved syntax.
|
TokenPatterns.CodeFunc |
aCode |
The associated code transformation handler.
|
|
Improve this Doc
View Source
AddPattern(String[], TokenPatterns.CodeFunc)
Register a collection of patterns that share a single transformation handler.
Declaration
protected void AddPattern(string[] aPatterns, TokenPatterns.CodeFunc aCode)
Parameters
Type |
Name |
Description |
System.String[] |
aPatterns |
A collection of X# lines of code. Each line of code define a
pattern optionally using the pattern reserved syntax.
|
TokenPatterns.CodeFunc |
aCode |
The code transformation handler that is common abmongst all the
patterns from the collection.
|
|
Improve this Doc
View Source
AddPatterns()
Declaration
protected void AddPatterns()
|
Improve this Doc
View Source
Assemble(String)
Declaration
public void Assemble(string aLine)
Parameters
Type |
Name |
Description |
System.String |
aLine |
|
|
Improve this Doc
View Source
BlockLabel(String)
Builds a label having the given name at current function block level.
Declaration
protected string BlockLabel(string aLabel)
Parameters
Type |
Name |
Description |
System.String |
aLabel |
Local label name at function block level.
|
Returns
Type |
Description |
System.String |
The label name.
|
|
Improve this Doc
View Source
ConstLabel(Token)
Builds a label that is suitable to denote a constant which name is given by the
token.
Declaration
protected string ConstLabel(Token aToken)
Parameters
Type |
Name |
Description |
Token |
aToken |
|
Returns
Type |
Description |
System.String |
|
|
Improve this Doc
View Source
EndFunc()
Terminate assembling current function. If a local to function exit label has not
been explicitly defined a new one is automatically created. This is because some "return"
keyword might have been used in function X# code. This keyword requires an exit label to
be defined at function level. This method also automatically insert an IRET or RET instruction
depending on whether the function is an interrupt handler or a standard function.
Declaration
|
Improve this Doc
View Source
FindMatch(TokenList)
Declaration
protected TokenPatterns.Pattern FindMatch(TokenList aTokens)
Parameters
Returns
|
Improve this Doc
View Source
FuncLabel(String)
Builds a label at function level having the given name.
Declaration
protected string FuncLabel(string aLabel)
Parameters
Type |
Name |
Description |
System.String |
aLabel |
Local label name at function level.
|
Returns
Type |
Description |
System.String |
The label name
|
|
Improve this Doc
View Source
GetJump(String, Boolean)
Declaration
protected ConditionalTestEnum GetJump(string aComparison, bool aInvert = false)
Parameters
Type |
Name |
Description |
System.String |
aComparison |
|
System.Boolean |
aInvert |
|
Returns
|
Improve this Doc
View Source
GetLabel(Token)
Build a label name for the given token. This method enforce the rule for .
and .. prefixes and build the label at appropriate level.
Declaration
protected string GetLabel(Token aToken)
Parameters
Type |
Name |
Description |
Token |
aToken |
|
Returns
Type |
Description |
System.String |
|
|
Improve this Doc
View Source
GetNamespace()
Declaration
protected string GetNamespace()
Returns
Type |
Description |
System.String |
|
|
Improve this Doc
View Source
GetPatternCode(TokenList)
Declaration
public bool GetPatternCode(TokenList aTokens)
Parameters
Returns
Type |
Description |
System.Boolean |
|
|
Improve this Doc
View Source
GetRef(List<Token>, ref Int32, Boolean)
Declaration
protected string GetRef(List<Token> aTokens, ref int rIdx, bool onlySingleTokenRefs = false)
Parameters
Type |
Name |
Description |
List<Token> |
aTokens |
|
System.Int32 |
rIdx |
|
System.Boolean |
onlySingleTokenRefs |
|
Returns
Type |
Description |
System.String |
|
|
Improve this Doc
View Source
GetSimpleRef(Token)
Declaration
protected string GetSimpleRef(Token aToken)
Parameters
Type |
Name |
Description |
Token |
aToken |
|
Returns
Type |
Description |
System.String |
|
|
Improve this Doc
View Source
GroupLabel(String)
Builds a label at namespace level having the given name.
Declaration
protected string GroupLabel(string aLabel)
Parameters
Type |
Name |
Description |
System.String |
aLabel |
Local label name at namespace level.
|
Returns
Type |
Description |
System.String |
The label name
|
|
Improve this Doc
View Source
HandleIf(TokenList, String)
Declaration
protected void HandleIf(TokenList aTokens, string xComparison)
Parameters
Type |
Name |
Description |
TokenList |
aTokens |
|
System.String |
xComparison |
|
|
Improve this Doc
View Source
StartFunc(String)
Start a new function having the given name. The current blocks collection is
reset to an empty state and the function name is saved for later reuse in local to function
labels' name construction.
Declaration
protected void StartFunc(string aName)
Parameters
Type |
Name |
Description |
System.String |
aName |
Function name.
|