Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add Visual Basic support #1038

Merged
merged 3 commits into from
Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

- Support for [Emacs Lisp](https://www.gnu.org/software/emacs/), and
[Puppet manifests](https://www.puppet.com/docs/puppet/8/puppet_language) was added.
- Support for [Emacs Lisp](https://www.gnu.org/software/emacs/), [Puppet
manifests](https://www.puppet.com/docs/puppet/8/puppet_language), and [Visual
Basic](https://learn.microsoft.com/en-us/dotnet/visual-basic/) was added.
- Support for recognizing multi-line comments only at the beginning of a line
(Ruby, Perl) was added.

Expand Down
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,14 @@ yamllint: ## Runs the yamllint linter.
fi; \
yamllint --strict -c .yamllint.yaml . $$extraargs

## Documentation
#####################################################################

SUPPORTED_LANGUAGES.md: node_modules/.installed internal/scanner/languages.yml ## Supported languages documentation.
@set -e;\
go mod vendor; \
go run ./internal/cmd/genlangdocs | ./node_modules/.bin/prettier --parser markdown > $@

## Maintenance
#####################################################################

Expand Down
82 changes: 42 additions & 40 deletions SUPPORTED_LANGUAGES.md
Original file line number Diff line number Diff line change
@@ -1,43 +1,45 @@
# Supported Languages

37 languages are currently supported.
39 languages are currently supported.

| File type | Supported comments |
| ------------- | ------------------ |
| Assembly | `;`, `/* */` |
| C | `//`, `/* */` |
| C# | `//`, `/* */` |
| C++ | `//`, `/* */` |
| Clojure | `;` |
| CoffeeScript | `#`, `### ###` |
| Dockerfile | `#` |
| Emacs Lisp | `;` |
| Erlang | `%` |
| Go | `//`, `/* */` |
| Go Module | `//` |
| Groovy | `//`, `/* */` |
| HTML | `<!-- --!>` |
| Haskell | `--`, `{- -}` |
| JSON | `//`, `#`, `/* */` |
| Java | `//`, `/* */` |
| JavaScript | `//`, `/* */` |
| Lua | `--`, `--[[ --]]` |
| Makefile | `#` |
| Objective-C | `//`, `/* */` |
| PHP | `#`, `//`, `/* */` |
| Perl | `#`, `= =cut` |
| Puppet | `#` |
| Python | `#`, `""" """` |
| R | `#` |
| Ruby | `#`, `=begin =end` |
| Rust | `//`, `/* */` |
| SQL | `--`, `/* */` |
| Scala | `//`, `/* */` |
| Shell | `#` |
| Swift | `//`, `/* */` |
| TOML | `#` |
| TeX | `%` |
| TypeScript | `//`, `/* */` |
| Unix Assembly | `;`, `/* */` |
| XML | `<!-- --!>` |
| YAML | `#` |
| File type | Supported comments |
| ----------------- | ------------------ |
| Assembly | `;`, `/* */` |
| C | `//`, `/* */` |
| C# | `//`, `/* */` |
| C++ | `//`, `/* */` |
| Clojure | `;` |
| CoffeeScript | `#`, `### ###` |
| Dockerfile | `#` |
| Emacs Lisp | `;` |
| Erlang | `%` |
| Go | `//`, `/* */` |
| Go Module | `//` |
| Groovy | `//`, `/* */` |
| HTML | `<!-- --!>` |
| Haskell | `--`, `{- -}` |
| JSON | `//`, `#`, `/* */` |
| Java | `//`, `/* */` |
| JavaScript | `//`, `/* */` |
| Lua | `--`, `--[[ --]]` |
| Makefile | `#` |
| Objective-C | `//`, `/* */` |
| PHP | `#`, `//`, `/* */` |
| Perl | `#`, `= =cut` |
| Puppet | `#` |
| Python | `#`, `""" """` |
| R | `#` |
| Ruby | `#`, `=begin =end` |
| Rust | `//`, `/* */` |
| SQL | `--`, `/* */` |
| Scala | `//`, `/* */` |
| Shell | `#` |
| Swift | `//`, `/* */` |
| TOML | `#` |
| TeX | `%` |
| TypeScript | `//`, `/* */` |
| Unix Assembly | `;`, `/* */` |
| VBA | `'` |
| Visual Basic .NET | `'` |
| XML | `<!-- --!>` |
| YAML | `#` |
12 changes: 12 additions & 0 deletions internal/scanner/languages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,18 @@ Unix Assembly:
# - start: "'"
# end: "'"
# escape: backslash
VBA:
line_comment_start: ["'"]
strings:
- start: '"'
end: '"'
escape: backslash
Visual Basic .NET:
line_comment_start: ["'"]
strings:
- start: '"'
end: '"'
escape: backslash
XML:
multiline_comment:
start: "<!--"
Expand Down
159 changes: 106 additions & 53 deletions internal/scanner/scanner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,7 @@ var scannerTestCases = []*struct {
src: `#!/usr/bin/env groovy
// package comment

z = '''
z = '''
// TODO is a function.
'''

Expand Down Expand Up @@ -1754,62 +1754,115 @@ TODO is a function.
},
},

// VBA
{
name: "line_comments.vba",
src: `' A "Hello, World!" program in Visual Basic.
Module Hello
Sub Main()
MsgBox("Hello, World!") ' Display message on computer screen.
End Sub
End Module`,
config: "VBA",
comments: []struct {
text string
line int
}{
{
text: "' A \"Hello, World!\" program in Visual Basic.",
line: 1,
},
{
text: "' Display message on computer screen.",
line: 4,
},
},
},

// Visual Basic .NET
{
name: "line_comments.vba",
src: `' A "Hello, World!" program in Visual Basic.
Imports System 'System is a Namespace
Module Hello_Program
Sub Main()
Console.WriteLine("Hello, Welcome to the world of VB.NET")
Console.WriteLine("Press any key to continue...")
Console.ReadKey()
End Sub
End Module`,
config: "Visual Basic .NET",
comments: []struct {
text string
line int
}{
{
text: "' A \"Hello, World!\" program in Visual Basic.",
line: 1,
},
{
text: "'System is a Namespace",
line: 2,
},
},
},

// TODO(#460): Support Vim Script
// {
// name: "line_comments.vim",
// src: `" file comment

// " TODO is a function.
// function TODO()
// return "Hello" " Random comment
// endfunction
// " extra comment`,
// config: "Vim Script",
// comments: []struct {
// text string
// line int
// }{
// {
// text: "\" file comment",
// line: 1,
// },
// {
// text: "\" TODO is a function.",
// line: 3,
// },
// {
// text: "\" Random comment",
// line: 5,
// },
// {
// text: "\" extra comment",
// line: 7,
// },
// },
// name: "line_comments.vim",
// src: `" file comment

// " TODO is a function.
// function TODO()
// return "Hello" " Random comment
// endfunction
// " extra comment`,
// config: "Vim Script",
// comments: []struct {
// text string
// line int
// }{
// {
// text: "\" file comment",
// line: 1,
// },
// {
// text: "\" TODO is a function.",
// line: 3,
// },
// {
// text: "\" Random comment",
// line: 5,
// },
// {
// text: "\" extra comment",
// line: 7,
// },
// },
// },
// {
// name: "escaped_string.vim",
// src: `" module comment

// " TODO is a function
// function TODO()
// return "\" Random comment"
// endfunction
// `,
// config: "Vim Script",
// comments: []struct {
// text string
// line int
// }{
// {
// text: "\" module comment",
// line: 1,
// },
// {
// text: "\" TODO is a function",
// line: 3,
// },
// },
// name: "escaped_string.vim",
// src: `" module comment

// " TODO is a function
// function TODO()
// return "\" Random comment"
// endfunction
// `,
// config: "Vim Script",
// comments: []struct {
// text string
// line int
// }{
// {
// text: "\" module comment",
// line: 1,
// },
// {
// text: "\" TODO is a function",
// line: 3,
// },
// },
// },
}

Expand Down
17 changes: 17 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,8 @@
},
"devDependencies": {
"markdownlint-cli": "0.37.0"
},
"dependencies": {
"prettier": "^3.0.3"
}
}