diff --git a/README.md b/README.md index 4a3e9654..976316af 100644 --- a/README.md +++ b/README.md @@ -1359,14 +1359,14 @@ USS (uss) UXML (uxml) Vala (vala) Vala Header (vapi) -VB for Applications (VBA, vba) +VBA (VBA, vba) Velocity Template Language (vm) Verilog-SystemVerilog (sv, svh, v) VHDL (VHD, vhd, VHDL, vhdl, vhf, vhi, vho, vhs, vht, vhw) vim script (vim) -Visual Basic (BAS, bas, ctl, dsr, frm, FRX, frx, VBHTML, vbhtml, vbp, vbw, cls) -Visual Basic .NET (VB, vb, vbproj) -Visual Basic Script (VBS, vbs) +Visual Basic (BAS, bas, ctl, dsr, Dsr, frm, FRX, frx, vbp, vbw, cls) +Visual Basic .NET (VB, vb, vbproj, vbhtml, VBHTML) +VBScript (VBS, vbs) Visual Fox Pro (SCA, sca) Visual Studio Solution (sln) Visualforce Component (component) diff --git a/Unix/cloc b/Unix/cloc index 11c460f2..d1e94289 100755 --- a/Unix/cloc +++ b/Unix/cloc @@ -9616,17 +9616,18 @@ sub set_constants { # {{{1 'BAS' => 'Visual Basic' , 'ctl' => 'Visual Basic' , 'dsr' => 'Visual Basic' , + 'Dsr' => 'Visual Basic' , 'frm' => 'Visual Basic' , 'frx' => 'Visual Basic' , 'FRX' => 'Visual Basic' , - 'vba' => 'VB for Applications' , - 'VBA' => 'VB for Applications' , - 'vbhtml' => 'Visual Basic' , - 'VBHTML' => 'Visual Basic' , + 'vba' => 'VBA' , + 'VBA' => 'VBA' , + 'vbhtml' => 'Visual Basic .NET' , + 'VBHTML' => 'Visual Basic .NET' , 'vbproj' => 'Visual Basic .NET' , 'vbp' => 'Visual Basic' , # .vbp - autogenerated - 'vbs' => 'Visual Basic Script' , - 'VBS' => 'Visual Basic Script' , + 'vbs' => 'VBScript' , + 'VBS' => 'VBScript' , 'vb' => 'Visual Basic .NET' , 'VB' => 'Visual Basic .NET' , 'vbw' => 'Visual Basic' , # .vbw - autogenerated @@ -11484,7 +11485,7 @@ sub set_constants { # {{{1 [ 'remove_matches' , '^\s*"' ], [ 'remove_inline' , '".*$' ], ], - 'Visual Basic Script' => [ + 'VBScript' => [ [ 'remove_above' , '^\s*Attribute\s+VB_Name\s+=' ], [ 'remove_matches' , '^\s*Attribute\s+'], [ 'remove_matches' , '^\s*\47'], # \47 = ' @@ -11494,7 +11495,7 @@ sub set_constants { # {{{1 [ 'remove_matches' , '^\s*Attribute\s+'], [ 'remove_matches' , '^\s*\47'], # \47 = ' ], - 'VB for Applications' => [ + 'VBA' => [ [ 'remove_above' , '^\s*Attribute\s+VB_Name\s+=' ], [ 'remove_matches' , '^\s*Attribute\s+'], [ 'remove_matches' , '^\s*\47'], # \47 = ' @@ -12225,9 +12226,9 @@ sub set_constants { # {{{1 'VHDL' => 4.21, 'vim script' => 3.00, 'Visual Basic' => 2.76, - 'VB for Applications' => 2.76, + 'VBA' => 2.76, 'Visual Basic .NET' => 2.76, - 'Visual Basic Script' => 2.76, + 'VBScript' => 2.76, 'Visual Fox Pro' => 4.00, # Visual Fox Pro is not available in the language gearing ratios listed at Mayes Consulting web site 'Visualforce Component' => 1.9 , 'Visualforce Page' => 1.9 , diff --git a/Unix/t/00_C.t b/Unix/t/00_C.t index b54efd34..1f63bae9 100755 --- a/Unix/t/00_C.t +++ b/Unix/t/00_C.t @@ -1433,9 +1433,14 @@ my @Tests = ( 'args' => '../tests/inputs/gnureadline.vala', }, { - 'name' => 'VB.Net', - 'ref' => '../tests/outputs/VisualBasic.Net.vba.yaml', - 'args' => '../tests/inputs/VisualBasic.Net.vba', + 'name' => 'VBA', + 'ref' => '../tests/outputs/vba_test.vba.yaml', + 'args' => '../tests/inputs/vba_test.vba', + }, + { + 'name' => 'VB.NET', + 'ref' => '../tests/outputs/vbnet_test.vb.yaml', + 'args' => '../tests/inputs/vbnet_test.vb', }, { 'name' => 'Velocity Template Language', @@ -1452,6 +1457,21 @@ my @Tests = ( 'ref' => '../tests/outputs/JetCar.cls.yaml', 'args' => '../tests/inputs/JetCar.cls', }, + { + 'name' => 'Visual Basic (Dsr)', + 'ref' => '../tests/outputs/test.Dsr.yaml', + 'args' => '../tests/inputs/test.Dsr', + }, + { + 'name' => 'Visual Basic .NET (vbhtml)', + 'ref' => '../tests/outputs/test.vbhtml.yaml', + 'args' => '../tests/inputs/test.vbhtml', + }, + { + 'name' => 'VBScript', + 'ref' => '../tests/outputs/test.vbs.yaml', + 'args' => '../tests/inputs/test.vbs', + }, { 'name' => 'Visual Studio Solution', 'ref' => '../tests/outputs/vs_solution.sln.yaml', diff --git a/cloc b/cloc index dfe01dad..0ada193d 100755 --- a/cloc +++ b/cloc @@ -9608,17 +9608,18 @@ sub set_constants { # {{{1 'BAS' => 'Visual Basic' , 'ctl' => 'Visual Basic' , 'dsr' => 'Visual Basic' , + 'Dsr' => 'Visual Basic' , 'frm' => 'Visual Basic' , 'frx' => 'Visual Basic' , 'FRX' => 'Visual Basic' , - 'vba' => 'VB for Applications' , - 'VBA' => 'VB for Applications' , - 'vbhtml' => 'Visual Basic' , - 'VBHTML' => 'Visual Basic' , + 'vba' => 'VBA' , + 'VBA' => 'VBA' , + 'vbhtml' => 'Visual Basic .NET' , + 'VBHTML' => 'Visual Basic .NET' , 'vbproj' => 'Visual Basic .NET' , 'vbp' => 'Visual Basic' , # .vbp - autogenerated - 'vbs' => 'Visual Basic Script' , - 'VBS' => 'Visual Basic Script' , + 'vbs' => 'VBScript' , + 'VBS' => 'VBScript' , 'vb' => 'Visual Basic .NET' , 'VB' => 'Visual Basic .NET' , 'vbw' => 'Visual Basic' , # .vbw - autogenerated @@ -11476,7 +11477,7 @@ sub set_constants { # {{{1 [ 'remove_matches' , '^\s*"' ], [ 'remove_inline' , '".*$' ], ], - 'Visual Basic Script' => [ + 'VBScript' => [ [ 'remove_above' , '^\s*Attribute\s+VB_Name\s+=' ], [ 'remove_matches' , '^\s*Attribute\s+'], [ 'remove_matches' , '^\s*\47'], # \47 = ' @@ -11486,7 +11487,7 @@ sub set_constants { # {{{1 [ 'remove_matches' , '^\s*Attribute\s+'], [ 'remove_matches' , '^\s*\47'], # \47 = ' ], - 'VB for Applications' => [ + 'VBA' => [ [ 'remove_above' , '^\s*Attribute\s+VB_Name\s+=' ], [ 'remove_matches' , '^\s*Attribute\s+'], [ 'remove_matches' , '^\s*\47'], # \47 = ' @@ -12217,9 +12218,9 @@ sub set_constants { # {{{1 'VHDL' => 4.21, 'vim script' => 3.00, 'Visual Basic' => 2.76, - 'VB for Applications' => 2.76, + 'VBA' => 2.76, 'Visual Basic .NET' => 2.76, - 'Visual Basic Script' => 2.76, + 'VBScript' => 2.76, 'Visual Fox Pro' => 4.00, # Visual Fox Pro is not available in the language gearing ratios listed at Mayes Consulting web site 'Visualforce Component' => 1.9 , 'Visualforce Page' => 1.9 , diff --git a/tests/inputs/VisualBasic.Net.vba b/tests/inputs/VisualBasic.Net.vba deleted file mode 100644 index 5f70bff8..00000000 --- a/tests/inputs/VisualBasic.Net.vba +++ /dev/null @@ -1,12 +0,0 @@ -'from http://www.roesler-ac.de/wolfram/hello.htm -'Hello World in Visual Basic .NET (VB.NET) - -Imports System.Console - -Class HelloWorld - - Public Shared Sub Main() - WriteLine("Hello, world!") - End Sub - -End Class diff --git a/tests/inputs/test.Dsr b/tests/inputs/test.Dsr new file mode 100644 index 00000000..68cd942c --- /dev/null +++ b/tests/inputs/test.Dsr @@ -0,0 +1,20 @@ +VERSION 1.0 CLASS +BEGIN + MultiUse = -1 'True + Persistable = 0 'NotPersistable + DataBindingBehavior = 0 'vbNone + DataSourceBehavior = 0 'vbNone + MTSTransactionMode = 0 'NotAnMTSObject +END +Attribute VB_Name = "TestClass" +Attribute VB_GlobalNameSpace = False + +' This is a comment in a Dsr file +Option Explicit + +Public Sub TestMethod() + ' Method implementation + Dim x As Integer + x = 42 + Debug.Print "Value: " & x +End Sub \ No newline at end of file diff --git a/tests/inputs/test.vbhtml b/tests/inputs/test.vbhtml new file mode 100644 index 00000000..2a2f884d --- /dev/null +++ b/tests/inputs/test.vbhtml @@ -0,0 +1,18 @@ +@{ + ' VB.NET code in a vbhtml file + ViewBag.Title = "Test Page" + Dim message As String = "Hello from VB.NET" +} + + + + + @ViewBag.Title + + +

@message

+ @If True Then + @

This is a VB.NET HTML template

+ End If + + \ No newline at end of file diff --git a/tests/inputs/test.vbs b/tests/inputs/test.vbs new file mode 100644 index 00000000..8ae8f006 --- /dev/null +++ b/tests/inputs/test.vbs @@ -0,0 +1,10 @@ +' VBScript test file +' This is a comment +Dim greeting +greeting = "Hello, World!" +WScript.Echo greeting + +' Another comment +If 1 = 1 Then + WScript.Echo "True" +End If \ No newline at end of file diff --git a/tests/inputs/vba_test.vba b/tests/inputs/vba_test.vba new file mode 100644 index 00000000..34aa9cf1 --- /dev/null +++ b/tests/inputs/vba_test.vba @@ -0,0 +1,22 @@ +Attribute VB_Name = "Module1" +' VBA (Visual Basic for Applications) example +' This would typically be found in Excel, Word, or Access + +Option Explicit + +Sub HelloWorld() + ' This is a VBA subroutine + MsgBox "Hello from VBA!" +End Sub + +Function AddNumbers(x As Integer, y As Integer) As Integer + ' VBA function to add two numbers + AddNumbers = x + y +End Function + +Private Sub Worksheet_Change(ByVal Target As Range) + ' Event handler - typical in VBA + If Target.Address = "$A$1" Then + Range("B1").Value = "Cell A1 was changed" + End If +End Sub \ No newline at end of file diff --git a/tests/inputs/vbnet_test.vb b/tests/inputs/vbnet_test.vb new file mode 100644 index 00000000..d8aa1127 --- /dev/null +++ b/tests/inputs/vbnet_test.vb @@ -0,0 +1,25 @@ +Imports System +Imports System.Collections.Generic + +' VB.NET example +Namespace HelloWorldApp + Public Class Program + Public Shared Sub Main(args As String()) + Console.WriteLine("Hello from VB.NET!") + + Dim numbers As New List(Of Integer) + numbers.Add(1) + numbers.Add(2) + numbers.Add(3) + + For Each num As Integer In numbers + Console.WriteLine($"Number: {num}") + Next + End Sub + + ' VB.NET method with modern syntax + Public Function CalculateSum(values As List(Of Integer)) As Integer + Return values.Sum() + End Function + End Class +End Namespace \ No newline at end of file diff --git a/tests/outputs/VisualBasic.Net.vba.yaml b/tests/outputs/VisualBasic.Net.vba.yaml deleted file mode 100644 index c2ab57f2..00000000 --- a/tests/outputs/VisualBasic.Net.vba.yaml +++ /dev/null @@ -1,21 +0,0 @@ ---- -# github.com/AlDanial/cloc -header : - cloc_url : github.com/AlDanial/cloc - cloc_version : 1.89 - elapsed_seconds : 0.00676512718200684 - n_files : 1 - n_lines : 12 - files_per_second : 147.816881057269 - lines_per_second : 1773.80257268722 - report_file : tests/outputs/VisualBasic.Net.vba.yaml -'VB for Applications' : - nFiles: 1 - blank: 4 - comment: 2 - code: 6 -SUM: - blank: 4 - comment: 2 - code: 6 - nFiles: 1 diff --git a/tests/outputs/test.Dsr.yaml b/tests/outputs/test.Dsr.yaml new file mode 100644 index 00000000..8f8650e3 --- /dev/null +++ b/tests/outputs/test.Dsr.yaml @@ -0,0 +1,21 @@ +--- +# github.com/AlDanial/cloc +header : + cloc_url : github.com/AlDanial/cloc + cloc_version : 2.07 + elapsed_seconds : 0.00898003578186035 + n_files : 1 + n_lines : 20 + files_per_second : 111.358130890747 + lines_per_second : 2227.16261781495 + report_file : tests/outputs/test.Dsr.yaml +'Visual Basic' : + nFiles: 1 + blank: 2 + comment: 12 + code: 6 +SUM: + blank: 2 + comment: 12 + code: 6 + nFiles: 1 \ No newline at end of file diff --git a/tests/outputs/test.vbhtml.yaml b/tests/outputs/test.vbhtml.yaml new file mode 100644 index 00000000..9cd7b527 --- /dev/null +++ b/tests/outputs/test.vbhtml.yaml @@ -0,0 +1,21 @@ +--- +# github.com/AlDanial/cloc +header : + cloc_url : github.com/AlDanial/cloc + cloc_version : 2.07 + elapsed_seconds : 0.0128321647644043 + n_files : 1 + n_lines : 18 + files_per_second : 77.9291739437405 + lines_per_second : 1402.72513098733 + report_file : tests/outputs/test.vbhtml.yaml +'Visual Basic .NET' : + nFiles: 1 + blank: 1 + comment: 1 + code: 16 +SUM: + blank: 1 + comment: 1 + code: 16 + nFiles: 1 \ No newline at end of file diff --git a/tests/outputs/test.vbs.yaml b/tests/outputs/test.vbs.yaml new file mode 100644 index 00000000..69bed3ad --- /dev/null +++ b/tests/outputs/test.vbs.yaml @@ -0,0 +1,21 @@ +--- +# github.com/AlDanial/cloc +header : + cloc_url : github.com/AlDanial/cloc + cloc_version : 2.07 + elapsed_seconds : 0.00967001914978027 + n_files : 1 + n_lines : 10 + files_per_second : 103.412411548608 + lines_per_second : 1034.12411548608 + report_file : tests/outputs/test.vbs.yaml +'VBScript' : + nFiles: 1 + blank: 1 + comment: 3 + code: 6 +SUM: + blank: 1 + comment: 3 + code: 6 + nFiles: 1 \ No newline at end of file diff --git a/tests/outputs/vba_test.vba.yaml b/tests/outputs/vba_test.vba.yaml new file mode 100644 index 00000000..4a760540 --- /dev/null +++ b/tests/outputs/vba_test.vba.yaml @@ -0,0 +1,20 @@ +--- +# github.com/AlDanial/cloc +header : + cloc_url : github.com/AlDanial/cloc + cloc_version : 2.07 + elapsed_seconds : 0.00922179222106934 + n_files : 1 + n_lines : 22 + files_per_second : 108.43879107526 + lines_per_second : 2385.65340365573 +'VBA' : + nFiles: 1 + blank: 4 + comment: 6 + code: 12 +SUM: + blank: 4 + comment: 6 + code: 12 + nFiles: 1 \ No newline at end of file diff --git a/tests/outputs/vbnet_test.vb.yaml b/tests/outputs/vbnet_test.vb.yaml new file mode 100644 index 00000000..683e91a1 --- /dev/null +++ b/tests/outputs/vbnet_test.vb.yaml @@ -0,0 +1,20 @@ +--- +# github.com/AlDanial/cloc +header : + cloc_url : github.com/AlDanial/cloc + cloc_version : 2.07 + elapsed_seconds : 0.0076439380645752 + n_files : 1 + n_lines : 25 + files_per_second : 130.822619381803 + lines_per_second : 3270.56548454509 +'Visual Basic .NET' : + nFiles: 1 + blank: 4 + comment: 2 + code: 19 +SUM: + blank: 4 + comment: 2 + code: 19 + nFiles: 1 \ No newline at end of file