⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 token.vb

📁 大名鼎鼎的mono是.NET平台的跨平台(支持linux
💻 VB
📖 第 1 页 / 共 2 页
字号:
    Function IsSymbol() As Boolean        Return m_TokenType = TokenType.Symbol    End Function    ReadOnly Property Symbol() As KS        Get            Return CType(m_TokenData1, KS)        End Get    End Property    ReadOnly Property Keyword() As KS        Get            Return CType(m_TokenData1, KS)        End Get    End Property    Function IsIdentifierOrKeyword() As Boolean        Return IsIdentifier() OrElse IsKeyword()    End Function    Function IsIdentifier() As Boolean        Return m_TokenType = TokenType.Identifier    End Function    ReadOnly Property LiteralValue() As Object        Get            Return m_TokenObject        End Get    End Property    Function IsLiteral() As Boolean        Select Case m_TokenType            Case TokenType.DateLiteral, TokenType.CharLiteral, TokenType.DecimalLiteral, TokenType.DoubleLiteral, TokenType.Int16Literal, TokenType.Int32Literal, TokenType.Int64Literal, TokenType.SingleLiteral, TokenType.StringLiteral, TokenType.UInt16Literal, TokenType.UInt32Literal, TokenType.UInt64Literal                Return True            Case Else                Return False        End Select    End Function    ReadOnly Property IntegralLiteral() As ULong        Get            Return CULng(m_TokenObject)        End Get    End Property    Function IsDateLiteral() As Boolean        Return m_TokenType = TokenType.DateLiteral    End Function    ReadOnly Property DateLiteral() As Date        Get            Return DirectCast(m_TokenObject, Date)        End Get    End Property    Function IsIntegerLiteral() As Boolean        Select Case m_TokenType            Case TokenType.Int16Literal, TokenType.Int32Literal, TokenType.Int64Literal, TokenType.UInt16Literal, TokenType.UInt32Literal, TokenType.UInt64Literal                Return True            Case Else                Return False        End Select    End Function    Function IsCharLiteral() As Boolean        Return m_TokenType = TokenType.CharLiteral    End Function    ReadOnly Property CharLiteral() As Char        Get            Return DirectCast(m_TokenObject, Char)        End Get    End Property    Function IsStringLiteral() As Boolean        Return m_TokenType = TokenType.StringLiteral    End Function    ReadOnly Property StringLiteral() As String        Get            Return DirectCast(m_TokenObject, String)        End Get    End Property    ReadOnly Property DecimalLiteral() As Decimal        Get            Return DirectCast(m_TokenObject, Decimal)        End Get    End Property    Function IsDecimalLiteral() As Boolean        Return m_TokenType = TokenType.DecimalLiteral    End Function    ReadOnly Property Identifier() As String        Get            If IsKeyword() Then                Return Enums.strSpecial(Keyword)            ElseIf IsIdentifier() Then                Return DirectCast(m_TokenObject, String)            Else                Return Nothing            End If        End Get    End Property    ''' <summary>    ''' Compares this token to any of the specified tokens.     ''' Returns true if any token matches.    ''' </summary>    ''' <param name="AnySpecial"></param>    ''' <returns></returns>    ''' <remarks></remarks>    Public Overloads Function Equals(ByVal AnySpecial() As KS) As Boolean        For i As Integer = 0 To VB.UBound(AnySpecial)            If Equals(AnySpecial(i)) = True Then Return True        Next        Return False    End Function    Public Overloads Function Equals(ByVal AnySpecial As ModifierMasks) As Boolean        Return IsKeyword() AndAlso Modifiers.IsKS(Keyword, AnySpecial)    End Function    Public Overloads Function Equals(ByVal a As KS, ByVal b As KS) As Boolean        Return Equals(a) OrElse Equals(b)    End Function    Public Overloads Function Equals(ByVal a As KS, ByVal b As KS, ByVal c As KS) As Boolean        Return Equals(a) OrElse Equals(b) OrElse Equals(c)    End Function    Public Overloads Function Equals(ByVal a As KS, ByVal b As KS, ByVal c As KS, ByVal d As KS) As Boolean        Return Equals(a) OrElse Equals(b) OrElse Equals(c) OrElse Equals(d)    End Function    Public Overloads Function Equals(ByVal a As KS, ByVal b As KS, ByVal c As KS, ByVal d As KS, ByVal e As KS) As Boolean        Return Equals(a) OrElse Equals(b) OrElse Equals(c) OrElse Equals(d) OrElse Equals(e)    End Function    Public Overloads Function Equals(ByVal a As KS, ByVal b As KS, ByVal c As KS, ByVal d As KS, ByVal e As KS, ByVal f As KS) As Boolean        Return Equals(a) OrElse Equals(b) OrElse Equals(c) OrElse Equals(d) OrElse Equals(e) OrElse Equals(f)    End Function    Public Overloads Function Equals(ByVal a As KS, ByVal b As KS, ByVal c As KS, ByVal d As KS, ByVal e As KS, ByVal f As KS, ByVal g As KS) As Boolean        Return Equals(a) OrElse Equals(b) OrElse Equals(c) OrElse Equals(d) OrElse Equals(e) OrElse Equals(f) OrElse Equals(g)    End Function    Public Overloads Function Equals(ByVal a As KS, ByVal b As KS, ByVal c As KS, ByVal d As KS, ByVal e As KS, ByVal f As KS, ByVal g As KS, ByVal h As KS) As Boolean        Return Equals(a) OrElse Equals(b) OrElse Equals(c) OrElse Equals(d) OrElse Equals(e) OrElse Equals(f) OrElse Equals(g) OrElse Equals(h)    End Function    Public Overloads Function Equals(ByVal Special As KS) As Boolean        If m_TokenType = TokenType.Keyword OrElse m_TokenType = TokenType.Symbol Then            Return CInt(m_TokenData1) = CInt(Special)        Else            Return False        End If    End Function    Shared Function IsKeyword(ByVal str As String, ByRef Keyword As KS) As Boolean        Dim special As KS        special = Enums.GetKS(str)        If special <> KS.None Then            Keyword = special            Return True        Else            Return False        End If    End Function    Public Overloads Function Equals(ByVal Identifier As String) As Boolean        Return Me.IsIdentifier AndAlso NameResolution.CompareName(Me.Identifier, Identifier)    End Function    Public Overrides Function Equals(ByVal obj As Object) As Boolean        If TypeOf obj Is Token Then            Return Equals(DirectCast(obj, Token))        Else            Throw New InternalException()        End If    End Function    Overloads Function Equals(ByVal obj As Token) As Boolean        If Me.IsIdentifier AndAlso obj.IsIdentifier Then            Return Me.Equals(obj.Identifier)        ElseIf Me.IsLiteral AndAlso obj.IsLiteral Then            Return Me.LiteralValue.Equals(obj.LiteralValue)        ElseIf Me.IsKeyword AndAlso obj.IsKeyword Then            Return Me.Keyword = obj.Keyword        ElseIf Me.IsSymbol AndAlso obj.IsSymbol Then            Return Me.Symbol = obj.Symbol        Else            Return False        End If    End Function    ReadOnly Property IsEndOfCode() As Boolean        Get            Return m_TokenType = TokenType.EndOfCode        End Get    End Property    ReadOnly Property IsEndOfFile() As Boolean        Get            Return m_TokenType = TokenType.EndOfFile OrElse m_TokenType = TokenType.EndOfCode        End Get    End Property    ReadOnly Property IsEndOfLine() As Boolean        Get            Return m_TokenType = TokenType.EndOfLine OrElse m_TokenType = TokenType.EndOfFile OrElse m_TokenType = TokenType.EndOfCode        End Get    End Property    ReadOnly Property IsEndOfLineOnly() As Boolean        Get            Return m_TokenType = TokenType.EndOfLine        End Get    End Property    Function IsEndOfStatement() As Boolean        Return IsEndOfLineOnly OrElse Equals(KS.Colon)    End Function    Shared Operator =(ByVal Token As Token, ByVal Special As KS) As Boolean        Return Token.Equals(Special)    End Operator    Shared Operator <>(ByVal Token As Token, ByVal Special As KS) As Boolean        Return Not Token.Equals(Special)    End Operator    ReadOnly Property FriendlyString() As String        Get            Return ToString()        End Get    End Property    ReadOnly Property SpecialString() As String        Get            If TypeOf m_TokenObject Is KS Then Return DirectCast(m_TokenObject, KS).ToString()            Return "not a symbol"        End Get    End PropertyEnd Class

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -