Skip to content

Commit 6bb2ca6

Browse files
committed
Merge pull request mono#2 from lee-m/master
Correction to recent #Const parsing change to the scanner
2 parents 15aef2b + 999f806 commit 6bb2ca6

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

vbnc/vbnc/source/General/Scanner.vb

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -207,21 +207,18 @@ Public Class Scanner
207207
Return
208208
End If
209209

210-
'All errors are reported against the line that the #Const directive appears on
211-
Dim constDirectiveLoc As New Span(m_CodeFileIndex, m_CurrentLine)
212-
213210
Me.NextUnconditionally()
214211

215212
If m_Current.IsIdentifier = False Then
216-
Compiler.Report.ShowMessage(Messages.VBNC30203, constDirectiveLoc)
213+
Compiler.Report.ShowMessage(Messages.VBNC30203, m_Current.Location)
217214
Me.EatLine(False)
218215
Return
219216
End If
220217
name = m_Current.Identifier
221218
Me.NextUnconditionally()
222219

223220
If m_Current <> KS.Equals Then
224-
Compiler.Report.ShowMessage(Messages.VBNC30249, constDirectiveLoc)
221+
Compiler.Report.ShowMessage(Messages.VBNC30249, m_Current.Location)
225222
Return
226223
End If
227224
Me.NextUnconditionally()
@@ -1348,8 +1345,12 @@ Public Class Scanner
13481345
Case COMMENTCHAR1, COMMENTCHAR2, COMMENTCHAR3 'VB Comment
13491346
EatComment()
13501347
Case nlD, nlA, nl2028, nl2029 'New line
1351-
EatNewLine()
1348+
1349+
'Keep the current line of the end of line token to the current line so we get better
1350+
'location info for errors and warnings
13521351
Result = Token.CreateEndOfLineToken(GetCurrentLocation)
1352+
EatNewLine()
1353+
13531354
Case nl0 'End of file
13541355
Result = Token.CreateEndOfFileToken(GetCurrentLocation)
13551356
Case ":"c ':

vbnc/vbnc/source/Tokens/Token.vb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
Public Structure Token
2121
Public m_TokenType As TokenType
2222
Public m_TokenObject As Object
23+
Public m_Location As Span
2324

2425
Shared Function IsSomething(ByVal Token As Token) As Boolean
2526
'Return Token IsNot Nothing AndAlso Token.IsSomething
@@ -164,6 +165,7 @@ Public Structure Token
164165
End Function
165166

166167
Sub New(ByVal Span As Span)
168+
m_Location = Span
167169
End Sub
168170

169171
Function IdentiferOrKeywordIdentifier() As String
@@ -474,6 +476,13 @@ Public Structure Token
474476
Return "not a symbol"
475477
End Get
476478
End Property
479+
480+
ReadOnly Property Location As Span
481+
Get
482+
Return m_Location
483+
End Get
484+
End Property
485+
477486
End Structure
478487

479488

0 commit comments

Comments
 (0)