Skip to content

Commit

Permalink
[VB] Add missing keywords, fix wrong lexer.lang value for VBScript.
Browse files Browse the repository at this point in the history
  • Loading branch information
zufuliu committed Nov 14, 2024
1 parent 4abdff3 commit 3142994
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 26 deletions.
11 changes: 6 additions & 5 deletions src/EditLexers/stlVB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,18 @@

static KEYWORDLIST Keywords_VB = {{
//++Autogenerated -- start of section automatically generated
"AddHandler AddHandler( AddressOf Aggregate Alias And AndAlso Ansi As Assembly Async Auto Await Binary By ByRef ByVal "
"Call Case Catch Class Compare Const Continue Custom Declare Default Delegate Dim DirectCast Distinct Do "
"Each Else ElseIf End Enum Equals Erase Error Event Exit Explicit False Finally For Friend From Function "
"AddHandler AddHandler( AddressOf Aggregate Alias And AndAlso Ansi As Ascending Assembly Async Auto Await "
"Binary By ByRef ByVal Call Case Catch Class Compare Const Continue Custom "
"Declare Default Delegate Descending Dim DirectCast Distinct Do "
"Each Else ElseIf End Enum Equals Erase Error Event Exit Explicit False Finally For Friend From Function Function( "
"Get GetType( GetXMLNamespace( Global GoTo Group Handles "
"If If( Implements Imports In Infer Inherits Interface Into Is IsFalse( IsNot IsTrue( Iterator Join Key "
"Let Lib Like Loop Me Mod Module MustInherit MustOverride My MyBase MyClass "
"NameOf( Namespace Narrowing New Next Not Nothing NotInheritable NotOverridable "
"Of Off On Operator Option Optional Or Order OrElse Out Overloads Overridable Overrides "
"ParamArray Partial Preserve Private Property Protected Public "
"RaiseEvent RaiseEvent( ReadOnly ReDim Rem RemoveHandler RemoveHandler( Resume Return "
"Select Set Set( Shadows Shared Skip Static Step Stop Strict Structure Sub SyncLock "
"Select Set Set( Shadows Shared Skip Static Step Stop Strict Structure Sub Sub( SyncLock "
"Take Text Then Throw To True Try TryCast( TypeOf Unicode Until Using "
"When Where While Widening With WithEvents WriteOnly Xor Yield "

Expand All @@ -31,7 +32,7 @@ static KEYWORDLIST Keywords_VB = {{
"Const Disable Else ElseIf Enable End EndIf ExternalChecksum ExternalSource If Region "

, // 4 attribute
"AttributeUsage( ComClass( Conditional( DllImport( HideModuleName( MarshalAs( MyGroupCollection( Obsolete( "
"AttributeUsage( ComClass( Conditional( DllImport( Extension( HideModuleName( MarshalAs( MyGroupCollection( Obsolete( "
"Serializable( StructLayout( VBFixedArray( VBFixedString( "

, // 5 class
Expand Down
7 changes: 4 additions & 3 deletions src/Styles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1347,8 +1347,6 @@ void Style_DefineIndicator(int index, int indicator, int indicatorStyle) noexcep
// Style_SetLexer()
//
void Style_SetLexer(PEDITLEXER pLexNew, BOOL bLexerChanged) noexcept {
int iValue;

// Select default if nullptr is specified
if (!pLexNew) {
np2LexLangIndex = 0;
Expand Down Expand Up @@ -1491,7 +1489,7 @@ void Style_SetLexer(PEDITLEXER pLexNew, BOOL bLexerChanged) noexcept {
szValue = lexGlobal.Styles[GlobalStyleIndex_DefaultText].szValue;
Style_StrGetFontEx(szValue, defaultTextFontName, COUNTOF(defaultTextFontName), true);

iValue = pLexNew->bUseDefaultCodeStyle ? GlobalStyleIndex_DefaultCode : GlobalStyleIndex_DefaultText;
int iValue = pLexNew->bUseDefaultCodeStyle ? GlobalStyleIndex_DefaultCode : GlobalStyleIndex_DefaultText;
szValue = lexGlobal.Styles[iValue].szValue;
// base font size
if (!Style_StrGetFontSize(szValue, &iBaseFontSize)) {
Expand Down Expand Up @@ -2436,6 +2434,9 @@ static void Style_UpdateLexerLang(LPCEDITLEXER pLex, LPCWSTR lpszExt, LPCWSTR lp
}
break;

case NP2LEX_VBSCRIPT:
np2LexLangIndex = IDM_LEXER_VBS;
break;
case NP2LEX_VISUALBASIC:
if (lstrlen(lpszExt) == 3) {
np2LexLangIndex = IDM_LEXER_VBA;
Expand Down
38 changes: 26 additions & 12 deletions tools/lang/VB.NET.vb
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ Declare Function Lib Alias As
Shared Shadows Static ReadOnly
Delegate Sub Of As
Delegate Function Of As
Dim WithEvents As New With
Dim WithEvents As New ' With {}
Do
End
Continue Do
Exit Do
Do While
Expand Down Expand Up @@ -63,22 +64,26 @@ ElseIf Then
Else
End If
If Then Else
Implements
Imports
Inherits
Interface Of
' Property
' Function
' Sub
' Event
' Interface
' Class
' Structure
Inherits
Property
Function
Sub
Event
Interface
Class
Structure
End Interface
Mid()
Module
End Module
Namespace Global
End Namespace
On Error GoTo Resume Next
On Error GoTo
On Error Resume Next
Public Overloads Shared Shadows Widening Narrowing
Operator As
Return
Expand All @@ -87,7 +92,7 @@ Option Compare Binary Text
Option Explicit On Off
Option Infer On Off
Option Strict On Off
Property
Property As Implements
Get
End Get
Set()
Expand All @@ -98,14 +103,17 @@ RaiseEvent
ReDim Preserve
Rem
RemoveHandler AddressOf
Resume Next
Return
Select Case
Case Else
Case To
End Select
Stop
Structure Of
Implements
End Structure
Sub
Partial Sub
Exit Sub
End Sub
SyncLock
Expand Down Expand Up @@ -134,7 +142,7 @@ From As In
Group By Into
Group Join As In On Equals And Equals Into
Let
Order By
Order By Ascending Descending
Select
Skip While
Take While
Expand All @@ -152,6 +160,10 @@ Or OrElse
TryCast() TypeOf Is IsNot
Xor

' https://learn.microsoft.com/en-us/dotnet/visual-basic/programming-guide/language-features/procedures/lambda-expressions
Function() And
Sub() And

' https://learn.microsoft.com/en-us/dotnet/visual-basic/language-reference/modifiers/
Ansi Assembly Async Auto
ByRef ByVal
Expand Down Expand Up @@ -199,6 +211,8 @@ Variant
<MyGroupCollection()>
<VBFixedArray()>
<VBFixedString()>
' https://learn.microsoft.com/en-us/dotnet/visual-basic/programming-guide/language-features/procedures/extension-methods
<Extension()>

'! directives =======================================================
' https://learn.microsoft.com/en-us/dotnet/visual-basic/reference/language-specification/preprocessing-directives
Expand Down
15 changes: 9 additions & 6 deletions tools/lang/VBA.bas
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@ ChDir
ChDrive
Close
Const As
Date
Declare PtrSafe Sub Lib Alias
Declare PtrSafe Function Lib Alias As
DefBool DefByte DefInt DefLng DefLngLng DefLngPtr
DefCur DefSng DefDbl DefDec DefDate DefStr DefObj DefVar
DeleteSetting
Dim As New WithEvents
Dim WithEvents As New
Do
End
Exit Do
Do While
Loop
Expand Down Expand Up @@ -63,8 +65,8 @@ Kill
Let
Line Input
Load
Lock
Unlock
Lock To
Unlock To
LSet
Mid()
MkDir
Expand All @@ -77,8 +79,8 @@ Open For Access As Len
Option Base
Option Compare Binary Text Database
Option Explicit
Option Private
Print
Option Private Module
Print Spc() Tab()
Private WithEvents As New
Property Get As
Exit Property
Expand All @@ -101,7 +103,8 @@ SavePicture ' VB6
SaveSetting
Seek
Select Case
Case Else
Case Else
Case To
End Select
SendKeys
Set New Nothing
Expand Down

0 comments on commit 3142994

Please sign in to comment.