Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
9eb723d
[Compiler VB Scanner] Peep functionality.
AdamSpeight2008 Oct 24, 2015
b59e3a3
[Compier VB Scanner]
AdamSpeight2008 Oct 24, 2015
1202e1d
Extends usage of Peep in to VB scanner.
AdamSpeight2008 Oct 25, 2015
434ddf8
Reducation in the number of introduced temporary char variables.
AdamSpeight2008 Oct 26, 2015
a9c2975
[Compiler VB Scanner]
AdamSpeight2008 Oct 27, 2015
978d8ab
[Compiler VB Scanner]
AdamSpeight2008 Oct 27, 2015
d493321
[Compiler VB Scanner]
AdamSpeight2008 Oct 27, 2015
2bae2eb
Minor Updates
AdamSpeight2008 Oct 27, 2015
e6edb1c
[Compiler VB Scanner]
AdamSpeight2008 Oct 28, 2015
9e38e83
Reduction in the number of temporary char variables from the use of `…
AdamSpeight2008 Oct 29, 2015
65f9bfe
Reduce the amount of temporary char variables introduced by using `Peep`
AdamSpeight2008 Oct 29, 2015
3fe3023
Merge commit '9e38e83ea8d04cf4dfdcab70aa47aa4f0e2be6ef' into Scanner(…
AdamSpeight2008 Oct 29, 2015
9753a9a
Removing a lot of redundant `Me.` calls
AdamSpeight2008 Oct 31, 2015
0462646
Fixup Import Renamed during `Me.` fix.
AdamSpeight2008 Nov 1, 2015
e2e6762
Commit
AdamSpeight2008 Nov 4, 2015
fd3f652
Changes to add Full width chars
AdamSpeight2008 Nov 7, 2015
42c2733
Updated CharInfo
AdamSpeight2008 Nov 8, 2015
2582945
Merging
AdamSpeight2008 Nov 8, 2015
094b85e
IntegralLiteralCharacterValue modified to return an integer, pushing …
AdamSpeight2008 Nov 8, 2015
759f581
Revert "IntegralLiteralCharacterValue modified to return an integer, …
AdamSpeight2008 Nov 8, 2015
69ae88d
Seperate `BadDate` label into it's own function.
AdamSpeight2008 Nov 8, 2015
014e568
k
AdamSpeight2008 Nov 9, 2015
19e4da3
Revert "k"
AdamSpeight2008 Nov 15, 2015
205082a
Revert "Seperate `BadDate` label into it's own function. Added short-…
AdamSpeight2008 Nov 15, 2015
486b221
Add missing LiteralKinds
AdamSpeight2008 Nov 15, 2015
f768b8e
Readded the seperate BadDate Function
AdamSpeight2008 Nov 15, 2015
7a444b5
16/11
AdamSpeight2008 Nov 16, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 6 additions & 10 deletions src/Compilers/VisualBasic/Portable/Scanner/Blender.vb
Original file line number Diff line number Diff line change
Expand Up @@ -401,11 +401,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Syntax.InternalSyntax
''' The reasons for it not be usable are typically that it intersects affected range.
''' </summary>
Private Function CanReuseNode(node As VisualBasicSyntaxNode) As Boolean
If node Is Nothing Then
Return False
End If

If node.SlotCount = 0 Then
If (node Is Nothing) AndAlso (node.SlotCount = 0) Then
Return False
End If

Expand Down Expand Up @@ -457,7 +453,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Syntax.InternalSyntax
' sometimes nodes contain linebreaks in leading trivia
' if we are in VBAllowLeadingMultilineTrivia state (common case), it is ok.
' otherwise nodes with leading trivia containing linebreaks should be rejected.
If Not Me._currentToken.State = ScannerState.VBAllowLeadingMultilineTrivia AndAlso
If Not _currentToken.State = ScannerState.VBAllowLeadingMultilineTrivia AndAlso
ContainsLeadingLineBreaks(node) Then

Return False
Expand Down Expand Up @@ -551,9 +547,9 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Syntax.InternalSyntax
Private _nextState As PreprocessorState

Public Sub New(state As PreprocessorState, node As VisualBasicSyntaxNode)
Me._state = state
Me._node = node
Me._nextState = Nothing
_state = state
_node = node
_nextState = Nothing
End Sub

Public ReadOnly Property Valid As Boolean
Expand All @@ -564,7 +560,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Syntax.InternalSyntax

Public Function State() As PreprocessorState
If _nextState Is Nothing Then
_nextState = ApplyDirectives(Me._state, Me._node)
_nextState = ApplyDirectives(_state, _node)
End If

Return _nextState
Expand Down
284 changes: 130 additions & 154 deletions src/Compilers/VisualBasic/Portable/Scanner/CharacterInfo.vb

Large diffs are not rendered by default.

64 changes: 32 additions & 32 deletions src/Compilers/VisualBasic/Portable/Scanner/Directives.vb
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,23 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Syntax.InternalSyntax

' SAVE the lookahead state and clear current token
Dim restorePoint = CreateRestorePoint()
Me._isScanningDirective = True
_isScanningDirective = True

' since we do not have lookahead tokens, this just
' resets current token to _lineBufferOffset
Me.GetNextTokenInState(ScannerState.VB)
GetNextTokenInState(ScannerState.VB)

Dim currentNonterminal = Me.GetCurrentSyntaxNode()
Dim currentNonterminal = GetCurrentSyntaxNode()
Dim directiveTrivia = TryCast(currentNonterminal, DirectiveTriviaSyntax)

' if we are lucky to get whole directive statement, we can just reuse it.
If directiveTrivia IsNot Nothing Then
Me.MoveToNextSyntaxNodeInTrivia()
MoveToNextSyntaxNodeInTrivia()

' adjust current token to just after the node
' we need that in case we need to skip some disabled text
'(yes we do tokenize disabled text for compatibility reasons)
Me.GetNextTokenInState(ScannerState.VB)
GetNextTokenInState(ScannerState.VB)

Else
Dim parser As New Parser(Me)
Expand All @@ -61,7 +61,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Syntax.InternalSyntax

' RESTORE lookahead state and current token if there were any
restorePoint.RestoreTokens(includeLookAhead:=True)
Me._isScanningDirective = False
_isScanningDirective = False

Return True
End Function
Expand Down Expand Up @@ -280,11 +280,11 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Syntax.InternalSyntax
haveSeenRegionDirectives As Boolean,
externalSourceDirective As ExternalSourceDirectiveTriviaSyntax)

Me._symbols = symbols
Me._conditionals = conditionals
Me._regionDirectives = regionDirectives
Me._haveSeenRegionDirectives = haveSeenRegionDirectives
Me._externalSourceDirective = externalSourceDirective
_symbols = symbols
_conditionals = conditionals
_regionDirectives = regionDirectives
_haveSeenRegionDirectives = haveSeenRegionDirectives
_externalSourceDirective = externalSourceDirective
End Sub

Friend ReadOnly Property SymbolsMap As ImmutableDictionary(Of String, CConst)
Expand All @@ -294,9 +294,9 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Syntax.InternalSyntax
End Property

Private Function SetSymbol(name As String, value As CConst) As PreprocessorState
Dim symbols = Me._symbols
Dim symbols = _symbols
symbols = symbols.SetItem(name, value)
Return New PreprocessorState(symbols, Me._conditionals, Me._regionDirectives, Me._haveSeenRegionDirectives, Me._externalSourceDirective)
Return New PreprocessorState(symbols, _conditionals, _regionDirectives, _haveSeenRegionDirectives, _externalSourceDirective)
End Function

Friend ReadOnly Property ConditionalStack As ImmutableStack(Of ConditionalState)
Expand All @@ -306,7 +306,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Syntax.InternalSyntax
End Property

Private Function WithConditionals(conditionals As ImmutableStack(Of ConditionalState)) As PreprocessorState
Return New PreprocessorState(Me._symbols, conditionals, Me._regionDirectives, Me._haveSeenRegionDirectives, Me._externalSourceDirective)
Return New PreprocessorState(_symbols, conditionals, _regionDirectives, _haveSeenRegionDirectives, _externalSourceDirective)
End Function

Friend ReadOnly Property RegionDirectiveStack As ImmutableStack(Of RegionDirectiveTriviaSyntax)
Expand All @@ -322,7 +322,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Syntax.InternalSyntax
End Property

Private Function WithRegions(regions As ImmutableStack(Of RegionDirectiveTriviaSyntax)) As PreprocessorState
Return New PreprocessorState(Me._symbols, Me._conditionals, regions, Me._haveSeenRegionDirectives OrElse regions.Count > 0, Me._externalSourceDirective)
Return New PreprocessorState(_symbols, _conditionals, regions, _haveSeenRegionDirectives OrElse regions.Count > 0, _externalSourceDirective)
End Function

Friend ReadOnly Property ExternalSourceDirective As ExternalSourceDirectiveTriviaSyntax
Expand All @@ -332,7 +332,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Syntax.InternalSyntax
End Property

Private Function WithExternalSource(externalSource As ExternalSourceDirectiveTriviaSyntax) As PreprocessorState
Return New PreprocessorState(Me._symbols, Me._conditionals, Me._regionDirectives, Me._haveSeenRegionDirectives, externalSource)
Return New PreprocessorState(_symbols, _conditionals, _regionDirectives, _haveSeenRegionDirectives, externalSource)
End Function

Friend Function InterpretConstDirective(ByRef statement As DirectiveTriviaSyntax) As PreprocessorState
Expand Down Expand Up @@ -411,7 +411,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Syntax.InternalSyntax
Friend Function InterpretElseIfDirective(ByRef statement As DirectiveTriviaSyntax) As PreprocessorState

Dim condition As ConditionalState
Dim conditionals = Me._conditionals
Dim conditionals = _conditionals

If conditionals.Count = 0 Then
statement = Parser.ReportSyntaxError(statement, ERRID.ERR_LbBadElseif)
Expand Down Expand Up @@ -453,7 +453,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Syntax.InternalSyntax
End Function

Friend Function InterpretElseDirective(ByRef statement As DirectiveTriviaSyntax) As PreprocessorState
Dim conditionals = Me._conditionals
Dim conditionals = _conditionals

If conditionals.Count = 0 Then
' If there has been no preceding #If, give an error and pretend that there
Expand Down Expand Up @@ -494,20 +494,20 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Syntax.InternalSyntax

Friend Function IsEquivalentTo(other As PreprocessorState) As Boolean
' for now, we will only consider two are equivalents when there are only regions but no other directives
If Me._conditionals.Count > 0 OrElse
Me._symbols.Count > 0 OrElse
Me._externalSourceDirective IsNot Nothing OrElse
If _conditionals.Count > 0 OrElse
_symbols.Count > 0 OrElse
_externalSourceDirective IsNot Nothing OrElse
other._conditionals.Count > 0 OrElse
other._symbols.Count > 0 OrElse
other._externalSourceDirective IsNot Nothing Then
Return False
End If

If Me._regionDirectives.Count <> other._regionDirectives.Count Then
If _regionDirectives.Count <> other._regionDirectives.Count Then
Return False
End If

If Me._haveSeenRegionDirectives <> other._haveSeenRegionDirectives Then
If _haveSeenRegionDirectives <> other._haveSeenRegionDirectives Then
Return False
End If

Expand All @@ -534,7 +534,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Syntax.InternalSyntax
Dim lengthSkipped As Integer = 0 ' Length of skipped text.

While True
Dim skippedSpan = Me.SkipToNextConditionalLine()
Dim skippedSpan = SkipToNextConditionalLine()

If startSkipped < 0 Then
startSkipped = skippedSpan.Start
Expand All @@ -545,8 +545,8 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Syntax.InternalSyntax

Select Case curToken.Kind
Case SyntaxKind.HashToken
Dim nextKind = Me.PeekToken(1, ScannerState.VB).Kind
Dim nextNextToken = Me.PeekToken(2, ScannerState.VB)
Dim nextKind = PeekToken(1, ScannerState.VB).Kind
Dim nextNextToken = PeekToken(2, ScannerState.VB)

If NestedConditionalsToSkip = 0 AndAlso
((nextKind = SyntaxKind.EndKeyword AndAlso
Expand Down Expand Up @@ -610,7 +610,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Syntax.InternalSyntax
End While

If lengthSkipped > 0 Then
Return New SyntaxList(Of VisualBasicSyntaxNode)(Me.GetDisabledTextAt(New TextSpan(startSkipped, lengthSkipped)))
Return New SyntaxList(Of VisualBasicSyntaxNode)(GetDisabledTextAt(New TextSpan(startSkipped, lengthSkipped)))
Else
Return New SyntaxList(Of VisualBasicSyntaxNode)(Nothing)
End If
Expand All @@ -628,7 +628,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Syntax.InternalSyntax
notClosedIfDirectives = Nothing
notClosedRegionDirectives = Nothing

If Me._scannerPreprocessorState.ConditionalStack.Count > 0 Then
If _scannerPreprocessorState.ConditionalStack.Count > 0 Then
For Each state In _scannerPreprocessorState.ConditionalStack
Dim ifDirective As IfDirectiveTriviaSyntax = state.IfDirective
If ifDirective IsNot Nothing Then
Expand All @@ -645,13 +645,13 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Syntax.InternalSyntax
End If
End If

If Me._scannerPreprocessorState.RegionDirectiveStack.Count > 0 Then
If _scannerPreprocessorState.RegionDirectiveStack.Count > 0 Then
notClosedRegionDirectives = ArrayBuilder(Of RegionDirectiveTriviaSyntax).GetInstance()
notClosedRegionDirectives.AddRange(Me._scannerPreprocessorState.RegionDirectiveStack)
notClosedRegionDirectives.AddRange(_scannerPreprocessorState.RegionDirectiveStack)
End If

haveRegionDirectives = Me._scannerPreprocessorState.HaveSeenRegionDirectives
notClosedExternalSourceDirective = Me._scannerPreprocessorState.ExternalSourceDirective
haveRegionDirectives = _scannerPreprocessorState.HaveSeenRegionDirectives
notClosedExternalSourceDirective = _scannerPreprocessorState.ExternalSourceDirective

Return eof
End Function
Expand Down
8 changes: 4 additions & 4 deletions src/Compilers/VisualBasic/Portable/Scanner/KeywordTable.vb
Original file line number Diff line number Diff line change
Expand Up @@ -280,10 +280,10 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Syntax
isQueryClause As Boolean,
canFollowExpr As Boolean)

Me.kdNew7To8kwd = New7To8
Me.kdOperPrec = Precedence
Me.kdIsQueryClause = isQueryClause
Me.kdCanFollowExpr = canFollowExpr
kdNew7To8kwd = New7To8
kdOperPrec = Precedence
kdIsQueryClause = isQueryClause
kdCanFollowExpr = canFollowExpr
End Sub
End Structure

Expand Down
Loading