• Home
  • Install
  • Cosmos Website
  • Articles
  • Cosmos
  • X#
  • IL2CPU
Show / Hide Table of Contents
  • XSharp
    • AsmGenerator
    • AsmGenerator.FlagBool
    • Compiler
    • Compiler.Block
    • Compiler.BlockList
    • Compiler.BlockType
    • Extensions
    • Parser
    • Parser.CharType
    • Token
    • TokenList
    • TokenPatterns
    • TokenPatterns.Block
    • TokenPatterns.Blocks
    • TokenPatterns.CodeFunc
    • TokenPatterns.Pattern
    • TokenType
    • XS
    • XS.FPU
    • XS.SSE
    • XS.SSE2
    • XS.SSE3
    • XSRegisters
    • XSRegisters.Register
    • XSRegisters.Register16
    • XSRegisters.Register32
    • XSRegisters.Register8
    • XSRegisters.RegisterFPU
    • XSRegisters.RegisterSegment
    • XSRegisters.RegisterSize
    • XSRegisters.RegisterXMM
  • XSharp.Assembler
    • Assembler
    • AssemblerMethod
    • BaseAssemblerElement
    • Comment
    • DataEndIfDefined
    • DataIfDefined
    • DataIfNotDefined
    • DataMember
    • Define
    • ElementReference
    • Else
    • EndIfDefined
    • IDefine
    • IEndIfDefined
    • IfDefined
    • IfNotDefined
    • IIfDefined
    • IIfNotDefined
    • InfraExtensions
    • Instruction
    • Label
    • LiteralAssemblerCode
    • OpCodeAttribute
    • TypeComparer
  • XSharp.Assembler.x86
    • Add
    • AddWithCarry
    • And
    • Call
    • ClearInterruptFlag
    • ClrCarryFlag
    • ClrDirFlag
    • CmpXchg
    • Compare
    • ConditionalJump
    • ConditionalMove
    • ConditionalTestEnum
    • ConvByteToWord
    • CpuId
    • DebugNoop
    • Dec
    • Divide
    • ExternalLabel
    • Halt
    • IDivide
    • IInstructionWithArgument
    • IInstructionWithCondition
    • IInstructionWithDestination
    • IInstructionWithPrefix
    • IInstructionWithSize
    • IInstructionWithSource
    • Imul
    • INC
    • InfraExtensions
    • InFromDX
    • Instruction
    • Instruction.InstructionSize
    • Instruction.InstructionSizes
    • Instruction.OperandMemoryKinds
    • InstructionPrefixes
    • InstructionWithDestination
    • InstructionWithDestinationAndSize
    • InstructionWithDestinationAndSource
    • InstructionWithDestinationAndSourceAndArgument
    • InstructionWithDestinationAndSourceAndSize
    • InstructionWithSize
    • INT
    • INT1
    • INT3
    • Interrupt
    • IRET
    • Jump
    • JumpBase
    • JumpToSegment
    • Lea
    • Lgdt
    • Lidt
    • LoadStatusFlags
    • Mov
    • MoveCR
    • MoveD
    • MoveSignExtend
    • MoveToDR6
    • MoveZeroExtend
    • Movs
    • Multiply
    • Neg
    • Noop
    • Not
    • Or
    • OutToDX
    • Pop
    • Popad
    • Popfd
    • Push
    • Pushad
    • Pushfd
    • Rdmsr
    • Rdtsc
    • Registers
    • RegistersEnum
    • Return
    • RotateLeft
    • RotateRight
    • RotateThroughCarryRight
    • Scas
    • SetByteOnCondition
    • ShiftLeft
    • ShiftLeftArithmetic
    • ShiftLeftDouble
    • ShiftRight
    • ShiftRightArithmetic
    • ShiftRightDouble
    • SignExtendAX
    • Sti
    • Stos
    • Sub
    • SubWithCarry
    • Test
    • Xchg
    • Xor
  • XSharp.Assembler.x86.SSE
    • AddPD
    • AddSD
    • AddSS
    • AndPD
    • AndPS
    • ComparePD
    • ComparePS
    • ComparePseudoOpcodes
    • CompareSD
    • CompareSS
    • ConvertPD2DQAndTruncate
    • ConvertSD2SI
    • ConvertSD2SIAndTruncate
    • ConvertSD2SS
    • ConvertSI2SD
    • ConvertSI2SS
    • ConvertSS2SD
    • ConvertSS2SI
    • ConvertSS2SIAndTruncate
    • DivPD
    • DivPS
    • DivSD
    • DivSS
    • InstructionWithDestinationAndSourceAndPseudoOpcodes
    • MaxSS
    • MinSS
    • MoveAPD
    • MoveAPS
    • MoveDoubleAndDuplicate
    • MoveDoubleAndDupplicate
    • MoveDQA
    • MoveDQU
    • MoveHLPD
    • MoveHLPS
    • MoveHPD
    • MoveHPS
    • MoveLHPS
    • MoveLPD
    • MoveQ
    • MoveSD
    • MoveSS
    • MoveUPD
    • MoveUPS
    • MulPD
    • MulPS
    • MulSD
    • MulSS
    • OrPS
    • Por
    • Psrld
    • Shufps
    • SqrtScalardDouble
    • SSEInit
    • SubPD
    • SubPS
    • SubSD
    • SubSS
    • UnpackLowDouble
    • XorPD
    • XorPS
  • XSharp.Assembler.x86.X86
    • Cmps
  • XSharp.Assembler.x86.X86.SSE
    • AddPS
  • XSharp.Assembler.x86.X86.x87
    • FloatCompareAnd2Pop
    • FloatPushOne
    • FloatPushZero
    • FloatUCompareAnd2Pop
  • XSharp.Assembler.x86.x87
    • FloatABS
    • FloatAdd
    • FloatAddAndPop
    • FloatClearEx
    • FloatCompare
    • FloatCompareAndPop
    • FloatCompareAndSet
    • FloatCompareAndSetAndPop
    • FloatCompareOrderAndSetAndPop
    • FloatCompareOrderSetAndPop
    • FloatConditionalMoveTestEnum
    • FloatCosine
    • FloatDecTopPointer
    • FloatDivide
    • FloatDivideAndPop
    • FloatDivideAndPopReverse
    • FloatDivideReverse
    • FloatFree
    • FloatIncTopPointer
    • FloatInit
    • FloatLoad
    • FloatMul
    • FloatMulAndPop
    • FloatNegate
    • FloatPop
    • FloatPRem
    • FloatPRem1
    • FloatRound
    • FloatSine
    • FloatSqrt
    • FloatStore
    • FloatStoreAndPop
    • FloatSub
    • FloatSubAndPop
    • FloatSubAndPopReverse
    • FloatSubReverse
    • FloatTan
    • FloatTest
    • FloatUCompare
    • FloatUCompareAndPop
    • FloatXchg
    • FXSave
    • FXStore
    • IntAdd
    • IntCompare
    • IntCompareAndPop
    • IntDiv
    • IntDivReverse
    • IntLoad
    • IntMul
    • IntStore
    • IntStoreAndPop
    • IntStoreWithTrunc
    • IntSub
    • IntSubReverse
  • XSharp.Tokens
    • AsKeyword
    • Compare
    • Compare<TLeftValueType, TComparatorType, TRightValueType>
    • CompareConstConst
    • CompareConstInt16
    • CompareConstInt32
    • CompareConstInt8
    • CompareConstVar
    • CompareConstVarAddr
    • CompareInt16Const
    • CompareInt16Int16
    • CompareInt16Var
    • CompareInt32Const
    • CompareInt32Int32
    • CompareInt32Var
    • CompareInt32VarAddr
    • CompareInt8Const
    • CompareInt8Int8
    • CompareInt8Var
    • CompareMem<TLeftValueType, TComparatorType, TRightValueType>
    • CompareReg08Const
    • CompareReg08Reg08
    • CompareReg08Var
    • CompareReg16Const
    • CompareReg16Int16
    • CompareReg16Reg16
    • CompareReg16Var
    • CompareReg32Const
    • CompareReg32Int32
    • CompareReg32Reg32
    • CompareReg32Var
    • CompareReg8Int8
    • CompareRegConst
    • CompareRegVar
    • CompareRegVarAddr
    • CompareVar
    • CompareVarAddrConst
    • CompareVarAddrInt32
    • CompareVarAddrVar
    • CompareVarAddrVarAddr
    • CompareVarConst
    • CompareVarInt16
    • CompareVarInt32
    • CompareVarInt8
    • CompareVarVar
    • CompareVarVarAddr
    • CompareWithMem
    • Const
    • ConstKeyword
    • FunctionKeyword
    • GotoKeyword
    • Identifier
    • If
    • Int08u
    • Int16u
    • Int32u
    • Interrupt
    • NamespaceKeyword
    • NOP
    • Num
    • OpBitwise
    • OpComment
    • OpCompare
    • OpIncDec
    • OpInclude
    • OpLiteral
    • OpMath
    • OpPureComparators
    • OpRotate
    • OpShift
    • PopAll
    • PortKeyword
    • PushAll
    • Reg
    • Reg08
    • Reg16
    • Reg32
    • Repeat
    • Return
    • Size
    • TestKeyword
    • Times
    • Variable
    • VariableAddress
    • VarKeyword
    • While
    • ZeroParamOp
  • XSharp.x86
    • Map
    • OpCode
    • Register
    • Register.Names
  • XSharp.x86.Assemblers
    • Assembler
    • NASM
  • XSharp.x86.Emitters
    • AllEmitters
    • Assignments
    • BitwiseEmitters
    • Branching
    • Comments
    • Emitters
    • IncrementDecrement
    • Math
    • Namespace
    • Ports
    • PushPop
    • ShiftRotate
    • Test
    • ZeroParamOps
  • XSharp.x86.Params
    • Address
    • i08u
    • i16u
    • i32u
    • Identifier
    • List
    • MemoryAddress
    • Num
    • Param
    • Reg
    • Reg08
    • Reg16
    • Reg32
    • RegisterAddress
    • Root
    • Size

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
Namespace: XSharp
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
protected string mData
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
protected int mStart
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
Type Description
TokenList
| 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
Type Description
Dictionary<System.String, XSRegisters.Register>
| Improve this Doc View Source

Registers16

Declaration
public static readonly Dictionary<string, XSRegisters.Register> Registers16
Field Value
Type Description
Dictionary<System.String, XSRegisters.Register>
| Improve this Doc View Source

Registers32

Declaration
public static readonly Dictionary<string, XSRegisters.Register> Registers32
Field Value
Type Description
Dictionary<System.String, XSRegisters.Register>
| Improve this Doc View Source

Registers8

Declaration
public static readonly Dictionary<string, XSRegisters.Register> Registers8
Field Value
Type Description
Dictionary<System.String, XSRegisters.Register>
| Improve this Doc View Source

RegistersAddr

Declaration
public static readonly Dictionary<string, XSRegisters.Register> RegistersAddr
Field Value
Type Description
Dictionary<System.String, XSRegisters.Register>
| Improve this Doc View Source

RegistersIdx

Declaration
public static readonly Dictionary<string, XSRegisters.Register> RegistersIdx
Field Value
Type Description
Dictionary<System.String, XSRegisters.Register>

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
Type Description
TokenList

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.

  • Improve this Doc
  • View Source
☀
☾
In This Article
Back to top
☀
☾