{"_id":"@arrmee/tree-sitter-vba","name":"@arrmee/tree-sitter-vba","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@arrmee/tree-sitter-vba","version":"1.0.0","description":"Tree-sitter grammar for Visual Basic for Applications (VBA) — case-insensitive, with full statement coverage","license":"MIT","author":{"name":"arrmee-wt","email":"https://github.com/arrmee-wt"},"homepage":"https://github.com/arrmee-wt/tree-sitter-vba","repository":{"type":"git","url":"git+https://github.com/arrmee-wt/tree-sitter-vba.git"},"bugs":{"url":"https://github.com/arrmee-wt/tree-sitter-vba/issues"},"keywords":["tree-sitter","vba","parser","grammar","visual-basic","ast"],"main":"bindings/node","scripts":{"build":"tree-sitter generate && node-gyp build","test":"tree-sitter test"},"dependencies":{"nan":"^2.20.0"},"devDependencies":{"tree-sitter-cli":"^0.24.0"},"gitHead":"d351c625e084623004731a0c4680c8201d070953","_id":"@arrmee/tree-sitter-vba@1.0.0","_nodeVersion":"26.1.0","_npmVersion":"11.14.1","dist":{"integrity":"sha512-ucnFLmpeH6JOICMl9vV+VNFy2EGbadWcqFxZ/ncteItOTUSekLjbkIWEfCpfgUvpiVXSC76WCTfva4v4bUFv4w==","shasum":"0fc63cedb2caa05a19fadc02c117b8b7e1ece7fd","tarball":"https://registry.npmjs.org/@arrmee/tree-sitter-vba/-/tree-sitter-vba-1.0.0.tgz","fileCount":32,"unpackedSize":3308897,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIB7oZw/Jsbs6UcSfHC+znlCOHO6K6EkK9X3WeMmdv0UqAiEAn6H8CRcfgfl88NOuR2/AKevca7KwpJXOUr8c4p/ysIQ="}]},"_npmUser":{"name":"arrmee","email":"arrmee@foxmail.com"},"directories":{},"maintainers":[{"name":"arrmee","email":"arrmee@foxmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/tree-sitter-vba_1.0.0_1780967994009_0.8943238069385044"},"_hasShrinkwrap":false}},"time":{"created":"2026-06-09T01:19:53.833Z","1.0.0":"2026-06-09T01:19:54.210Z","modified":"2026-06-09T01:19:54.444Z"},"maintainers":[{"name":"arrmee","email":"arrmee@foxmail.com"}],"description":"Tree-sitter grammar for Visual Basic for Applications (VBA) — case-insensitive, with full statement coverage","homepage":"https://github.com/arrmee-wt/tree-sitter-vba","keywords":["tree-sitter","vba","parser","grammar","visual-basic","ast"],"repository":{"type":"git","url":"git+https://github.com/arrmee-wt/tree-sitter-vba.git"},"author":{"name":"arrmee-wt","email":"https://github.com/arrmee-wt"},"bugs":{"url":"https://github.com/arrmee-wt/tree-sitter-vba/issues"},"license":"MIT","readme":"# tree-sitter-vba\n\nA [Tree-sitter](https://tree-sitter.github.io/) grammar for **Visual Basic for Applications (VBA)**.\n\n[![Test](https://github.com/arrmee-wt/tree-sitter-vba/actions/workflows/test.yml/badge.svg)](https://github.com/arrmee-wt/tree-sitter-vba/actions/workflows/test.yml)\n\nFills the gap of the long-missing tree-sitter VBA parser — the only production-ready open-source VBA grammar for tree-sitter.\n\n## Features\n\n- ✅ **Case-insensitive keywords** — VBA is case-insensitive by nature; `Sub`, `sub`, and `SUB` all match correctly\n- ✅ **Line continuation** — supports VBA's `_` line continuation character\n- ✅ **Full VBA statement coverage** — `Sub`/`Function`/`Property`, `If`/`ElseIf`/`Else`, `For`/`For Each`/`While`/`Do` loops, `Select Case`, `With`, `Dim`, `Const`, `Set`, `GoTo`, error handling, file I/O, and more\n- ✅ **Expression hierarchy** — proper operator precedence for arithmetic, comparison, logical, and concatenation operators\n- ✅ **Pre-built DLL** — compiled for Windows with MSVC ABI compatibility (via Zig)\n\n## Project Structure\n\n```\ntree-sitter-vba/\n├── grammar.js              # Tree-sitter grammar definition\n├── src/\n│   ├── parser.c            # Generated C parser (1.2M)\n│   ├── node-types.json     # AST node type definitions\n│   └── grammar.json        # Grammar metadata\n├── tree_sitter_vba.dll     # Pre-built Windows DLL (MSVC compatible)\n├── sgconfig.yml            # ast-grep custom language config\n├── rules/                  # ast-grep search rules\n│   └── find_subs.yml       # Example rule: find all Sub procedures\n├── test/\n│   ├── sample.bas          # Sample VBA test file\n│   └── simple.bas          # Simple VBA test file\n└── tree-sitter.json        # Tree-sitter configuration\n```\n\n## Usage\n\n### As a Tree-sitter grammar\n\n```bash\n# Install the grammar\nnpm install tree-sitter-vba\n\n# Or generate from source\nnpx tree-sitter generate\nnpx tree-sitter build\n```\n\n### With Python\n\n```python\nimport ctypes\nfrom tree_sitter import Language, Parser\n\nlib = ctypes.CDLL('./tree_sitter_vba.dll')\nlib.tree_sitter_vba.restype = ctypes.c_void_p\nlang = Language(lib.tree_sitter_vba())\n\nparser = Parser(lang)\ntree = parser.parse(bytes(code, 'utf-8'))\n```\n\n### With C/C++\n\n```c\n#include \"tree_sitter/api.h\"\nTSLanguage *tree_sitter_vba();\n\nTSLanguage *vba = tree_sitter_vba();\nTSParser *parser = ts_parser_new();\nts_parser_set_language(parser, vba);\n```\n\n### With ast-grep (custom language)\n\n```yaml\n# sgconfig.yml\ncustomLanguages:\n  vba:\n    libraryPath: ./tree_sitter_vba.dll\n    extensions:\n      - .bas\n      - .cls\n      - .frm\n```\n\n## Building from Source\n\n### Prerequisites\n\n- [Tree-sitter CLI](https://tree-sitter.github.io/tree-sitter/creating-parsers#installation)\n- A C compiler (GCC/MinGW, MSVC, or Zig)\n\n### Generate & Build\n\n```bash\n# Generate the C parser from grammar.js\nnpx tree-sitter generate\n\n# Compile the shared library with Zig (MSVC compatible)\nzig cc -shared -O3 -I src src/parser.c -o tree_sitter_vba.dll -target x86_64-windows-msvc\n```\n\n## License\n\nMIT. This grammar is an independent implementation based on the publicly available [Microsoft VBA Language Specification (MS-VBAL)](https://learn.microsoft.com/en-us/openspecs/microsoft_apis/ms-vbal/). It does not derive from any GPL-licensed ANTLR4 grammar or other third-party VBA parser implementation.\n\n## Why another VBA parser?\n\nExisting tree-sitter VBA grammars were either:\n- **Incomplete** — only parsing a subset of VBScript (`tree-sitter-vbscript`)\n- **Wrong language** — targeting VB.NET (`tree-sitter-vb-dotnet`) which has significant syntax differences from VBA\n- **Abandoned** — started but never reached production quality\n\nThis grammar is implemented from scratch based on the Microsoft VBA Language Specification. It was developed using AI-assisted translation with manual validation and extensive testing against real-world VBA codebases.\n","readmeFilename":"README.md","_rev":"1-ca53b171c8e7d16f9c45d553db03979b"}