Skip to content
This repository has been archived by the owner on Nov 3, 2023. It is now read-only.

Commit

Permalink
Merge pull request #1 from lee-m/master
Browse files Browse the repository at this point in the history
Make error/warning numbers and message text more consistent with VBC
  • Loading branch information
rolfbjarne committed Oct 2, 2011
2 parents f78cf92 + 0089fde commit 15aef2b
Show file tree
Hide file tree
Showing 20 changed files with 186 additions and 45 deletions.
9 changes: 7 additions & 2 deletions vbnc/vbnc/source/Expressions/InvocationOrIndexExpression.vb
Expand Up @@ -368,8 +368,13 @@ Public Class InvocationOrIndexExpression
Return False
End If

If CecilHelper.GetArrayRank(ArrayType) <> m_ArgumentList.Count Then
Helper.AddError(Me, "Array dimensions are not correct.")
Dim arrayRank As Integer = CecilHelper.GetArrayRank(ArrayType)

If m_ArgumentList.Count > arrayRank Then
Compiler.Report.ShowMessage(Messages.VBNC30106, Location)
Return False
ElseIf m_ArgumentList.Count < arrayRank Then
Compiler.Report.ShowMessage(Messages.VBNC30105, Location)
Return False
End If

Expand Down
21 changes: 10 additions & 11 deletions vbnc/vbnc/source/General/Messages.vb
Expand Up @@ -674,7 +674,7 @@ Public Enum Messages
<Message(MessageLevel.Error)> VBNC30098 = 30098

''' <summary>
''' VBNC = "This 'Exit Select' statement is not contained within a 'Select' statement."
''' VBNC = "'Exit Select' can only appear inside a 'Select' statement."
''' VB = "'Exit Select' can only appear inside a 'Select' statement."
''' </summary>
''' <remarks></remarks>
Expand All @@ -695,14 +695,14 @@ Public Enum Messages
<Message(MessageLevel.Error)> VBNC30103 = 30103

''' <summary>
''' VBNC = "CHANGEME"
''' VBNC = "Number of indices is less than the number of dimensions of the indexed array."
''' VB = "Number of indices is less than the number of dimensions of the indexed array."
''' </summary>
''' <remarks></remarks>
<Message(MessageLevel.Error)> VBNC30105 = 30105

''' <summary>
''' VBNC = "CHANGEME"
''' VBNC = "Number of indices exceeds the number of dimensions of the indexed array."
''' VB = "Number of indices exceeds the number of dimensions of the indexed array."
''' </summary>
''' <remarks></remarks>
Expand Down Expand Up @@ -1213,7 +1213,7 @@ Public Enum Messages
<Message(MessageLevel.Error)> VBNC30215 = 30215

''' <summary>
''' VBNC = "CHANGEME"
''' VBNC = "String constant expected."
''' VB = "String constant expected."
''' </summary>
''' <remarks></remarks>
Expand Down Expand Up @@ -1360,14 +1360,14 @@ Public Enum Messages
<Message(MessageLevel.Error)> VBNC30247 = 30247

''' <summary>
''' VBNC = "CHANGEME"
''' VB = "'If', 'ElseIf', 'Else', 'End If', or 'Const' expected."
''' VBNC = "'If', 'ElseIf', 'Else', 'End If', 'Const', or 'Region' expected."
''' VB = "'If', 'ElseIf', 'Else', 'End If', 'Const', or 'Region' expected."
''' </summary>
''' <remarks></remarks>
<Message(MessageLevel.Error)> VBNC30248 = 30248

''' <summary>
''' VBNC = "CHANGEME"
''' VBNC = "'=' expected."
''' VB = "'=' expected."
''' </summary>
''' <remarks></remarks>
Expand Down Expand Up @@ -2102,14 +2102,14 @@ Public Enum Messages
<Message(MessageLevel.Error)> VBNC30442 = 30442

''' <summary>
''' VBNC = "CHANGEME"
''' VBNC = "'Get' is already declared."
''' VB = "'Get' is already declared."
''' </summary>
''' <remarks></remarks>
<Message(MessageLevel.Error)> VBNC30443 = 30443

''' <summary>
''' VBNC = "CHANGEME"
''' VBNC = "'Set' is already declared."
''' VB = "'Set' is already declared."
''' </summary>
''' <remarks></remarks>
Expand Down Expand Up @@ -4643,7 +4643,7 @@ Public Enum Messages
<Message(MessageLevel.Error)> VBNC31086 = 31086

''' <summary>
''' VBNC = "A variable can't declare array modifiers both on the variable name and on the type."
''' VBNC = "Array modifiers cannot be specified on both a variable and its type."
''' VB = "Array modifiers cannot be specified on both a variable and its type."
''' </summary>
''' <remarks></remarks>
Expand Down Expand Up @@ -6946,4 +6946,3 @@ Public Enum Messages
<Message(MessageLevel.Error)> VBNC99999 = 99999

End Enum

26 changes: 22 additions & 4 deletions vbnc/vbnc/source/General/Scanner.vb
Expand Up @@ -206,18 +206,22 @@ Public Class Scanner
Me.EatLine(False)
Return
End If

'All errors are reported against the line that the #Const directive appears on
Dim constDirectiveLoc As New Span(m_CodeFileIndex, m_CurrentLine)

Me.NextUnconditionally()

If m_Current.IsIdentifier = False Then
Compiler.Report.ShowMessage(Messages.VBNC30203, GetCurrentLocation())
Compiler.Report.ShowMessage(Messages.VBNC30203, constDirectiveLoc)
Me.EatLine(False)
Return
End If
name = m_Current.Identifier
Me.NextUnconditionally()

If m_Current <> KS.Equals Then
Helper.AddError(Compiler, GetCurrentLocation, "Expected '='")
Compiler.Report.ShowMessage(Messages.VBNC30249, constDirectiveLoc)
Return
End If
Me.NextUnconditionally()
Expand Down Expand Up @@ -344,10 +348,14 @@ Public Class Scanner
Me.EatLine(False)
Return
End If

'Save the location of the #Region token to use as the location of any missing string literal
Dim regionLoc As Span = GetCurrentLocation()

Me.NextUnconditionally()

If Not m_Current.IsStringLiteral Then
Helper.AddError(Me, "Expected string literal")
Compiler.Report.ShowMessage(Messages.VBNC30217, regionLoc)
EatLine(False)
Return
End If
Expand Down Expand Up @@ -471,7 +479,17 @@ Public Class Scanner
End If

If TokensSeenOnLine = 1 AndAlso m_Current = KS.Numeral Then

Me.NextUnconditionally()

If m_Current.IsEndOfFile Then
ResetCurrentConstants()
Return m_Current
ElseIf m_Current.IsEndOfLine Then
EatLine(True)
Return Me.Next()
End If

If m_Current = KS.If Then
ParseIf()
ElseIf m_Current = KS.Else Then
Expand All @@ -487,7 +505,7 @@ Public Class Scanner
ElseIf m_Current = KS.End Then
ParseEnd()
Else
Helper.AddError(Me.Compiler, Me.GetCurrentLocation, "Expected 'If', 'ElseIf', 'Else', 'Const' or 'Region'.")
Compiler.Report.ShowMessage(Messages.VBNC30248, GetCurrentLocation())
EatLine(False)
End If
ElseIf IfdOut Then
Expand Down
2 changes: 1 addition & 1 deletion vbnc/vbnc/source/Members/VariableDeclaration.vb
Expand Up @@ -175,7 +175,7 @@ Public MustInherit Class VariableDeclaration

If m_VariableIdentifier IsNot Nothing AndAlso m_VariableIdentifier.HasArrayNameModifier Then
If CecilHelper.IsArray(m_VariableType) Then
result = Helper.AddError(Me, "Cannot specify array modifier on both type name and on variable name.") AndAlso result
result = Compiler.Report.ShowMessage(Messages.VBNC31087, Location) AndAlso result
Else
If m_VariableIdentifier.ArrayNameModifier.IsArraySizeInitializationModifier Then
m_VariableType = m_VariableIdentifier.ArrayNameModifier.AsArraySizeInitializationModifier.CreateArrayType(m_VariableType)
Expand Down
8 changes: 5 additions & 3 deletions vbnc/vbnc/source/Parser/Parser.vb
Expand Up @@ -3634,14 +3634,14 @@ Public Class Parser
m_Attributes = ParseAttributes(result)
If PropertyGetDeclaration.IsMe(tm) Then
If m_Get IsNot Nothing Then
Helper.AddError(Compiler, tm.CurrentLocation, "Found more than one Get Property.")
Compiler.Report.ShowMessage(Messages.VBNC30443, tm.CurrentLocation)
End If
m_Get = ParsePropertyGetMember(result, New ParseAttributableInfo(Compiler, m_Attributes), m_Signature, m_ImplementsClause, m_Modifiers.Mask)
If m_Get Is Nothing Then Helper.ErrorRecoveryNotImplemented(tm.CurrentLocation)
m_Attributes = Nothing
ElseIf PropertySetDeclaration.IsMe(tm) Then
If m_Set IsNot Nothing Then
Helper.AddError(Compiler, tm.CurrentLocation, "Found more than one Set Property.")
Compiler.Report.ShowMessage(Messages.VBNC30444, tm.CurrentLocation)
End If
m_Set = ParsePropertySetMember(result, New ParseAttributableInfo(Compiler, m_Attributes), m_Signature, m_ImplementsClause, m_Modifiers.Mask)
If m_Set Is Nothing Then Helper.ErrorRecoveryNotImplemented(tm.CurrentLocation)
Expand Down Expand Up @@ -5173,17 +5173,19 @@ Public Class Parser
''' <remarks></remarks>
Private Function ParseExitStatement(ByVal Parent As ParsedObject) As ExitStatement
Dim m_ExitWhat As KS
Dim exitLocation As Span

tm.AcceptIfNotInternalError(KS.Exit)
If tm.CurrentToken.Equals(KS.Sub, KS.Function, KS.Property, KS.Do, KS.For, KS.Try, KS.While, KS.Select) Then
m_ExitWhat = tm.CurrentToken.Keyword
exitLocation = tm.CurrentLocation
tm.NextToken()
Else
Compiler.Report.ShowMessage(Messages.VBNC30240, tm.CurrentLocation)
Return Nothing
End If

Return New ExitStatement(Parent, m_ExitWhat)
Return New ExitStatement(Parent, m_ExitWhat, exitLocation)
End Function

''' <summary>
Expand Down
27 changes: 13 additions & 14 deletions vbnc/vbnc/source/Resources/Errors.resx
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Expand Down Expand Up @@ -112,10 +112,10 @@
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="warning" xml:space="preserve">
<value>'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Expand Down Expand Up @@ -404,7 +404,7 @@
<value>CHANGEME</value>
</data>
<data name="30099" xml:space="preserve">
<value>This 'Exit Select' statement is not contained within a 'Select' statement.</value>
<value>'Exit Select' can only appear inside a 'Select' statement.</value>
</data>
<data name="30101" xml:space="preserve">
<value>CHANGEME</value>
Expand All @@ -413,10 +413,10 @@
<value>CHANGEME</value>
</data>
<data name="30105" xml:space="preserve">
<value>CHANGEME</value>
<value>Number of indices is less than the number of dimensions of the indexed array.</value>
</data>
<data name="30106" xml:space="preserve">
<value>CHANGEME</value>
<value>Number of indices exceeds the number of dimensions of the indexed array.</value>
</data>
<data name="30107" xml:space="preserve">
<value>CHANGEME</value>
Expand Down Expand Up @@ -635,7 +635,7 @@
<value>Expected 'Sub' or 'Function'</value>
</data>
<data name="30217" xml:space="preserve">
<value>CHANGEME</value>
<value>String constant expected.</value>
</data>
<data name="30218" xml:space="preserve">
<value>CHANGEME</value>
Expand Down Expand Up @@ -698,10 +698,10 @@
<value>CHANGEME</value>
</data>
<data name="30248" xml:space="preserve">
<value>CHANGEME</value>
<value>'If', 'ElseIf', 'Else', 'End If', 'Const', or 'Region' expected.</value>
</data>
<data name="30249" xml:space="preserve">
<value>CHANGEME</value>
<value>'=' expected.</value>
</data>
<data name="30251" xml:space="preserve">
<value>Type '{0}' has no constructors.</value>
Expand Down Expand Up @@ -1016,10 +1016,10 @@
<value>CHANGEME</value>
</data>
<data name="30443" xml:space="preserve">
<value>CHANGEME</value>
<value>'Get' is already declared.</value>
</data>
<data name="30444" xml:space="preserve">
<value>CHANGEME</value>
<value>'Set' is already declared.</value>
</data>
<data name="30445" xml:space="preserve">
<value>CHANGEME</value>
Expand Down Expand Up @@ -2105,7 +2105,7 @@
<value>CHANGEME</value>
</data>
<data name="31087" xml:space="preserve">
<value>A variable can't declare array modifiers both on the variable name and on the type.</value>
<value>Array modifiers cannot be specified on both a variable and its type.</value>
</data>
<data name="31088" xml:space="preserve">
<value>CHANGEME</value>
Expand Down Expand Up @@ -3091,5 +3091,4 @@
<data name="99999" xml:space="preserve">
<value>{0}</value>
</data>
</root>

</root>
20 changes: 10 additions & 10 deletions vbnc/vbnc/source/Resources/Source.xml
Expand Up @@ -474,7 +474,7 @@
</Message>
<Message id="30099" level="Error">
<Comment>NC</Comment>
<VBNCValue>This 'Exit Select' statement is not contained within a 'Select' statement.</VBNCValue>
<VBNCValue>'Exit Select' can only appear inside a 'Select' statement.</VBNCValue>
<VBValue>'Exit Select' can only appear inside a 'Select' statement.</VBValue>
</Message>
<Message id="30101" level="Error">
Expand All @@ -489,12 +489,12 @@
</Message>
<Message id="30105" level="Error">
<Comment>NC</Comment>
<VBNCValue>CHANGEME</VBNCValue>
<VBNCValue>Number of indices is less than the number of dimensions of the indexed array.</VBNCValue>
<VBValue>Number of indices is less than the number of dimensions of the indexed array.</VBValue>
</Message>
<Message id="30106" level="Error">
<Comment>NC</Comment>
<VBNCValue>CHANGEME</VBNCValue>
<VBNCValue>Number of indices exceeds the number of dimensions of the indexed array.</VBNCValue>
<VBValue>Number of indices exceeds the number of dimensions of the indexed array.</VBValue>
</Message>
<Message id="30107" level="Error">
Expand Down Expand Up @@ -859,7 +859,7 @@
</Message>
<Message id="30217" level="Error">
<Comment>NC</Comment>
<VBNCValue>CHANGEME</VBNCValue>
<VBNCValue>String constant expected.</VBNCValue>
<VBValue>String constant expected.</VBValue>
</Message>
<Message id="30218" level="Error">
Expand Down Expand Up @@ -964,12 +964,12 @@
</Message>
<Message id="30248" level="Error">
<Comment>NC</Comment>
<VBNCValue>CHANGEME</VBNCValue>
<VBValue>'If', 'ElseIf', 'Else', 'End If', or 'Const' expected.</VBValue>
<VBNCValue>'If', 'ElseIf', 'Else', 'End If', 'Const', or 'Region' expected.</VBNCValue>
<VBValue>'If', 'ElseIf', 'Else', 'End If', 'Const', or 'Region' expected.</VBValue>
</Message>
<Message id="30249" level="Error">
<Comment>NC</Comment>
<VBNCValue>CHANGEME</VBNCValue>
<VBNCValue>'=' expected.</VBNCValue>
<VBValue>'=' expected.</VBValue>
</Message>
<Message id="30251" level="Error">
Expand Down Expand Up @@ -1494,12 +1494,12 @@
</Message>
<Message id="30443" level="Error">
<Comment>NC</Comment>
<VBNCValue>CHANGEME</VBNCValue>
<VBNCValue>'Get' is already declared.</VBNCValue>
<VBValue>'Get' is already declared.</VBValue>
</Message>
<Message id="30444" level="Error">
<Comment>NC</Comment>
<VBNCValue>CHANGEME</VBNCValue>
<VBNCValue>'Set' is already declared.</VBNCValue>
<VBValue>'Set' is already declared.</VBValue>
</Message>
<Message id="30445" level="Error">
Expand Down Expand Up @@ -3309,7 +3309,7 @@
</Message>
<Message id="31087" level="Error">
<Comment>NC</Comment>
<VBNCValue>A variable can't declare array modifiers both on the variable name and on the type.</VBNCValue>
<VBNCValue>Array modifiers cannot be specified on both a variable and its type.</VBNCValue>
<VBValue>Array modifiers cannot be specified on both a variable and its type.</VBValue>
</Message>
<Message id="31088" level="Error">
Expand Down
5 changes: 5 additions & 0 deletions vbnc/vbnc/source/Statements/ExitStatement.vb
Expand Up @@ -38,6 +38,11 @@ Public Class ExitStatement
m_ExitWhat = ExitWhat
End Sub

Sub New(ByVal Parent As ParsedObject, ByVal ExitWhat As KS, Location As Span)
MyBase.New(Parent, Location)
m_ExitWhat = ExitWhat
End Sub

Friend Overrides Function GenerateCode(ByVal Info As EmitInfo) As Boolean
Dim result As Boolean = True

Expand Down

0 comments on commit 15aef2b

Please sign in to comment.