Class Parser
Parser recognizes the following tokens:
- _123 -> Number
- _REG -> All registers
- _REGADDR -> All 32-bit registers
- 1 -> Number as well
- _ABC -> Random label, used indirectly (ie, used as a field)
- #_ABC -> Random label, used for the value (ie, pointer to the field)
Inheritance
System.Object
Parser
Assembly: XSharp.dll
Syntax
public class Parser : object
Constructors
|
Improve this Doc
View Source
Parser(String, Boolean, Boolean)
Create a new Parser instance and immediately consume the given aData
string. On return the Tokens property is available for enumeration.
Declaration
public Parser(string aData, bool aIncludeWhiteSpace, bool aAllowPatterns)
Parameters
Type |
Name |
Description |
System.String |
aData |
The text to be parsed. WARNING : This is expected to be a single full line
of text. The parser can be create with a special "pattern recognition" mode.
|
System.Boolean |
aIncludeWhiteSpace |
|
System.Boolean |
aAllowPatterns |
True if aData is a pattern and thus the parsing
should be performed specifically.
|
Fields
|
Improve this Doc
View Source
Delimiters
Declaration
public static readonly string[] Delimiters
Field Value
Type |
Description |
System.String[] |
|
|
Improve this Doc
View Source
mAllowPatterns
true if the parser supports patterns recognition.
Declaration
protected bool mAllowPatterns
Field Value
Type |
Description |
System.Boolean |
|
|
Improve this Doc
View Source
mAllWhitespace
true while every token encountered until so far by this parser are whitespace
tokens.
Declaration
protected bool mAllWhitespace
Field Value
Type |
Description |
System.Boolean |
|
|
Improve this Doc
View Source
mComma
Declaration
protected static readonly char[] mComma
Field Value
Type |
Description |
System.Char[] |
|
|
Improve this Doc
View Source
mData
Initial text provided as a constructor parameter.
Declaration
Field Value
Type |
Description |
System.String |
|
|
Improve this Doc
View Source
mIncludeWhiteSpace
true if whitespace tokens should be kept and propagated to the next parsing
stage.
Declaration
protected bool mIncludeWhiteSpace
Field Value
Type |
Description |
System.Boolean |
|
|
Improve this Doc
View Source
mKeywords
Declaration
public static string[] mKeywords
Field Value
Type |
Description |
System.String[] |
|
|
Improve this Doc
View Source
mSpace
Declaration
protected static readonly char[] mSpace
Field Value
Type |
Description |
System.Char[] |
|
|
Improve this Doc
View Source
mStart
Index in mData of the first yet unconsumed character.
Declaration
Field Value
Type |
Description |
System.Int32 |
|
|
Improve this Doc
View Source
mTokens
Tokens retrieved so far by the parser.
Declaration
protected TokenList mTokens
Field Value
|
Improve this Doc
View Source
Operators
Declaration
public static readonly string[] Operators
Field Value
Type |
Description |
System.String[] |
|
|
Improve this Doc
View Source
RegisterPatterns
Declaration
public static readonly string[] RegisterPatterns
Field Value
Type |
Description |
System.String[] |
|
|
Improve this Doc
View Source
Registers
Declaration
public static readonly Dictionary<string, XSRegisters.Register> Registers
Field Value
|
Improve this Doc
View Source
Registers16
Declaration
public static readonly Dictionary<string, XSRegisters.Register> Registers16
Field Value
|
Improve this Doc
View Source
Registers32
Declaration
public static readonly Dictionary<string, XSRegisters.Register> Registers32
Field Value
|
Improve this Doc
View Source
Registers8
Declaration
public static readonly Dictionary<string, XSRegisters.Register> Registers8
Field Value
|
Improve this Doc
View Source
RegistersAddr
Declaration
public static readonly Dictionary<string, XSRegisters.Register> RegistersAddr
Field Value
|
Improve this Doc
View Source
RegistersIdx
Declaration
public static readonly Dictionary<string, XSRegisters.Register> RegistersIdx
Field Value
Properties
|
Improve this Doc
View Source
Tokens
Get a list of tokens that has been built at class instanciation.
Declaration
public TokenList Tokens { get; }
Property Value
Methods
|
Improve this Doc
View Source
IsAlphaNum(Char)
Declaration
protected bool IsAlphaNum(char aChar)
Parameters
Type |
Name |
Description |
System.Char |
aChar |
|
Returns
Type |
Description |
System.Boolean |
|
|
Improve this Doc
View Source
NextToken(TokenList, ref Int32)
Parse next token from currently parsed line, starting at given position and
add the retrieved token at end of given token list.
Declaration
protected void NextToken(TokenList aList, ref int rPos)
Parameters
Type |
Name |
Description |
TokenList |
aList |
The token list where to add the newly recognized token.
|
System.Int32 |
rPos |
The index in current source code line of the first not yet consumed
character. On return this parameter will be updated to account for characters that would
have been consumed.
|
|
Improve this Doc
View Source
Parse()
Consume text that has been provided to the class constructor, splitting it into
a list of tokens.
Declaration
protected TokenList Parse()
Returns
Type |
Description |
TokenList |
The resulting tokens list.
|