parser(members).vb
来自「大名鼎鼎的mono是.NET平台的跨平台(支持linux」· VB 代码 · 共 537 行 · 第 1/2 页
VB
537 行
Dim m_TypeParameters As TypeParameters = Nothing Dim m_ParameterList As New ParameterList(result) If ParseSubSignature(result, m_Identifier, m_TypeParameters, m_ParameterList) = False Then Helper.ErrorRecoveryNotImplemented() End If result.Init(m_Identifier, m_TypeParameters, m_ParameterList) Return result End Function ''' <summary> ''' FunctionSignature ::= SubSignature [ "As" [ Attributes ] TypeName ] ''' </summary> ''' <remarks></remarks> Private Function ParseFunctionSignature(ByVal Parent As ParsedObject) As FunctionSignature Dim result As New FunctionSignature(Parent) Dim m_Identifier As Token = Nothing Dim m_TypeParameters As TypeParameters = Nothing Dim m_ParameterList As New ParameterList(result) Dim m_ReturnTypeAttributes As New Attributes(result) Dim m_TypeName As TypeName = Nothing If ParseSubSignature(result, m_Identifier, m_TypeParameters, m_ParameterList) = False Then Helper.ErrorRecoveryNotImplemented() End If If tm.Accept(KS.As) Then If Attributes.IsMe(tm) Then If ParseAttributes(result, m_ReturnTypeAttributes) = False Then Helper.ErrorRecoveryNotImplemented() End If End If m_TypeName = ParseTypeName(result) If m_TypeName Is Nothing Then Helper.ErrorRecoveryNotImplemented() End If result.Init(m_Identifier, m_TypeParameters, m_ParameterList, m_ReturnTypeAttributes, m_TypeName, New Span(m_Identifier.Location, tm.PeekToken(-1).Location)) Return result End Function ''' <summary> ''' TypeParameters ::= "(" "Of" TypeParameterList ")" ''' CHANGED: Switched name of TypeParameters and TypeParameterList ''' </summary> ''' <remarks></remarks> ''' Private Function ParseTypeParameters(ByVal Parent As ParsedObject) As TypeParameters Dim result As New TypeParameters(Parent) If tm.AcceptIfNotError(KS.LParenthesis) = False Then Helper.ErrorRecoveryNotImplemented() If tm.AcceptIfNotError(KS.Of) = False Then Helper.ErrorRecoveryNotImplemented() Dim m_TypeParameters As New TypeParameterList(result) If ParseList(Of TypeParameter)(m_TypeParameters, New ParseDelegate_Parent(Of TypeParameter)(AddressOf ParseTypeParameter), m_TypeParameters) = False Then Helper.ErrorRecoveryNotImplemented() End If If tm.AcceptIfNotError(KS.RParenthesis) = False Then Helper.ErrorRecoveryNotImplemented() result.Init(m_TypeParameters) Return result End Function ''' <summary> ''' TypeParameter ::= Identifier [ TypeParameterConstraints ] ''' </summary> ''' <remarks></remarks> Private Function ParseTypeParameter(ByVal Parent As ParsedObject) As TypeParameter Dim result As New TypeParameter(Parent) Helper.Assert(TypeOf Parent Is TypeParameterList) Dim m_Identifier As Token = Nothing Dim m_TypeParameterConstraints As TypeParameterConstraints Dim GenericParameterPosition As Integer Dim parentList As TypeParameterList parentList = DirectCast(Parent, TypeParameterList) GenericParameterPosition = parentList.Count + 1 If tm.AcceptIdentifier(m_Identifier) = False Then Helper.ErrorRecoveryNotImplemented() If TypeParameterConstraints.CanBeMe(tm) Then m_TypeParameterConstraints = ParseTypeParameterConstraints(result) If m_TypeParameterConstraints Is Nothing Then Helper.ErrorRecoveryNotImplemented() Else m_TypeParameterConstraints = Nothing End If result.Init(m_Identifier, m_TypeParameterConstraints, GenericParameterPosition) Return result End Function ''' <summary> ''' TypeParameterConstraints ::= As Constraint | As { ConstraintList } ''' </summary> ''' <remarks></remarks> Private Function ParseTypeParameterConstraints(ByVal Parent As ParsedObject) As TypeParameterConstraints Dim result As New TypeParameterConstraints(Parent) tm.AcceptIfNotInternalError(KS.As) Dim m_ConstraintList As New ConstraintList(result) If tm.Accept(KS.LBrace) Then If ParseList(Of Constraint)(m_ConstraintList, New ParseDelegate_Parent(Of Constraint)(AddressOf ParseConstraint), result) = False Then Helper.ErrorRecoveryNotImplemented() End If If tm.AcceptIfNotError(KS.RBrace) = False Then Helper.ErrorRecoveryNotImplemented() Else Dim tmpConstraint As Constraint = Nothing tmpConstraint = ParseConstraint(result) m_ConstraintList = New ConstraintList(result, tmpConstraint) End If result.Init(m_ConstraintList) Return result End Function ''' <summary> ''' Constraint ::= TypeName | "New" ''' LAMESPEC? Using the following: ''' Constraint ::= TypeName | "New" | "Class" | "Structure" ''' </summary> ''' <remarks></remarks> Private Function ParseConstraint(ByVal Parent As ParsedObject) As Constraint Dim result As New Constraint(Parent) Dim m_Special As KS Dim m_TypeName As TypeName = Nothing If tm.CurrentToken.Equals(KS.[New], KS.Class, KS.Structure) Then m_Special = tm.CurrentToken.Keyword tm.NextToken() Else m_TypeName = ParseTypeName(result) If m_TypeName Is Nothing Then Helper.ErrorRecoveryNotImplemented() End If result.Init(m_TypeName, m_Special) Return result End Function ''' <summary> ''' Parameter ::= [ Attributes ] ParameterModifier+ ParameterIdentifier [ "As" TypeName ] [ "=" ConstantExpression ] ''' ParameterModifier ::= "ByVal" | "ByRef" | "Optional" | "ParamArray" ''' ParameterIdentifier ::= Identifier [ ArrayNameModifier ] ''' </summary> ''' <remarks></remarks> Private Function ParseParameter(ByVal Parent As ParsedObject) As Parameter Helper.Assert(TypeOf Parent Is ParameterList) Dim result As New Parameter(DirectCast(Parent, ParameterList)) Dim m_Attributes As New Attributes(result) Dim m_Modifiers As Modifiers Dim m_ParameterIdentifier As ParameterIdentifier Dim m_TypeName As TypeName Dim m_ConstantExpression As Expression If vbnc.Attributes.IsMe(tm) Then ParseAttributes(result, m_Attributes) End If m_Modifiers = ParseModifiers(result, ModifierMasks.ParameterModifiers) m_ParameterIdentifier = ParseParameterIdentifier(result) If m_ParameterIdentifier Is Nothing Then Helper.ErrorRecoveryNotImplemented() If tm.Accept(KS.As) Then m_TypeName = ParseTypeName(result) If m_TypeName Is Nothing Then Helper.ErrorRecoveryNotImplemented() Else m_TypeName = Nothing End If If tm.Accept(KS.Equals) Then m_ConstantExpression = ParseExpression(result) If m_ConstantExpression Is Nothing Then Helper.ErrorRecoveryNotImplemented() Else m_ConstantExpression = Nothing End If result.Init(m_Attributes, m_Modifiers, m_ParameterIdentifier, m_TypeName, m_ConstantExpression) Return result End Function ''' <summary> ''' ParameterIdentifier ::= Identifier [ ArrayNameModifier ] ''' </summary> ''' <remarks></remarks> Private Function ParseParameterIdentifier(ByVal Parent As Parameter) As ParameterIdentifier Dim result As New ParameterIdentifier(Parent) Dim m_Identifier As Token = Nothing Dim m_ArrayNameModifier As ArrayNameModifier = Nothing If tm.AcceptIdentifier(m_Identifier) = False Then Helper.ErrorRecoveryNotImplemented() If vbnc.ArrayNameModifier.CanBeMe(tm) Then m_ArrayNameModifier = ParseArrayNameModifier(result) If m_ArrayNameModifier Is Nothing Then Helper.ErrorRecoveryNotImplemented() End If result.Init(m_Identifier, m_ArrayNameModifier) Return result End Function Private Function ParseImplementsClause(ByVal Parent As ParsedObject) As MemberImplementsClause Dim result As New MemberImplementsClause(Parent) Dim m_ImplementsList As New MemberImplementsList(Parent) tm.AcceptIfNotInternalError(KS.Implements) If ParseList(Of InterfaceMemberSpecifier)(m_ImplementsList, New ParseDelegate_Parent(Of InterfaceMemberSpecifier)(AddressOf ParseInterfaceMemberSpecifier), Parent) = False Then Helper.ErrorRecoveryNotImplemented() End If result.Init(m_ImplementsList) Return result End Function Private Function ParseInterfaceMemberSpecifier(ByVal Parent As ParsedObject) As InterfaceMemberSpecifier Dim result As New InterfaceMemberSpecifier(Parent) Dim m_NonArrayTypeName As NonArrayTypeName = Nothing Dim m_1 As NonArrayTypeName = Nothing Dim m_2 As IdentifierOrKeyword = Nothing m_NonArrayTypeName = ParseNonArrayTypeName(result) If tm.Accept(KS.Dot) Then m_1 = m_NonArrayTypeName m_2 = ParseIdentifierOrKeyword(result) If m_2 Is Nothing Then Helper.ErrorRecoveryNotImplemented() ElseIf m_NonArrayTypeName.IsSimpleTypeName AndAlso m_NonArrayTypeName.AsSimpleTypeName.IsQualifiedIdentifier Then Dim stn As SimpleTypeName = m_NonArrayTypeName.AsSimpleTypeName Dim qi As QualifiedIdentifier = stn.AsQualifiedIdentifier m_1 = m_NonArrayTypeName If Token.IsSomething(qi.Second) Then m_2 = New IdentifierOrKeyword(result, qi.Second) qi.Second = Nothing Else Helper.AddError() End If Else Helper.AddError() End If result.Init(m_1, m_2) Return result End FunctionEnd Class
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?