{"id":20958010,"url":"https://github.com/brucificus/vb6-antlr4-typescript","last_synced_at":"2025-06-13T10:38:59.440Z","repository":{"id":38173046,"uuid":"251456593","full_name":"brucificus/vb6-antlr4-typescript","owner":"brucificus","description":"Visual Basic 6 lexer \u0026 parser written in TypeScript using ANTLR 4 \u0026 ANTLR4TS","archived":false,"fork":false,"pushed_at":"2025-05-08T10:55:05.000Z","size":1222,"stargazers_count":8,"open_issues_count":1,"forks_count":5,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-08T11:43:35.177Z","etag":null,"topics":["antlr4","npm-package","typescript","visual-basic-6"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/vb6-antlr4","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/brucificus.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2020-03-31T00:02:00.000Z","updated_at":"2025-05-08T10:55:08.000Z","dependencies_parsed_at":"2023-10-16T22:58:54.622Z","dependency_job_id":"1363ffdc-cec5-48a8-b0da-3b8c0cd2af56","html_url":"https://github.com/brucificus/vb6-antlr4-typescript","commit_stats":{"total_commits":156,"total_committers":3,"mean_commits":52.0,"dds":0.5576923076923077,"last_synced_commit":"e51d1f05307d4bc2fa4f379de9719c7ceb3e8cfb"},"previous_names":[],"tags_count":54,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brucificus%2Fvb6-antlr4-typescript","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brucificus%2Fvb6-antlr4-typescript/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brucificus%2Fvb6-antlr4-typescript/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brucificus%2Fvb6-antlr4-typescript/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/brucificus","download_url":"https://codeload.github.com/brucificus/vb6-antlr4-typescript/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254084643,"owners_count":22011915,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["antlr4","npm-package","typescript","visual-basic-6"],"created_at":"2024-11-19T01:44:57.354Z","updated_at":"2025-05-14T06:31:43.878Z","avatar_url":"https://github.com/brucificus.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# vb6-antlr4\n\n[![Dependabot Status](https://api.dependabot.com/badges/status?host=github\u0026repo=brucificus/vb6-antlr4-typescript)](https://dependabot.com)\n![Libraries.io dependency status for latest release](https://img.shields.io/librariesio/release/npm/vb6-antlr4)\n![npm latest release](https://img.shields.io/npm/v/vb6-antlr4/latest)\n[![License](https://img.shields.io/badge/License-BSD%203--Clause-blue.svg)](./LICENSE.txt)\n![Release](https://github.com/brucificus/vb6-antlr4-typescript/workflows/Release/badge.svg)\n[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)\n[![Gitmoji](https://img.shields.io/badge/gitmoji-%20😜%20😍-FFDD67.svg?style=flat-square)](https://gitmoji.carloscuesta.me/)\n[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com)\n[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)\n[![Awesome Badges](https://img.shields.io/badge/badges-awesome-green.svg)](https://github.com/Naereen/badges)\n\nA Visual Basic 6 lexer \u0026 parser that provides both visitor and listener patterns to traverse the parse tree. The parser is based on grammar that has been test-driven and **successfully applied to large Visual Basic 6.0 projects.**\n\n## Overview\n\nThis is a continuous-delivery focused synthesis of the [ProLeap Visual Basic 6.0 parser](https://github.com/uwol/proleap-vb6-parser)'s ANTLR4 grammar and the Optimized ANLTR TypeScript target provided by [antlr4ts](https://github.com/tunnelvisionlabs/antlr4ts).\n\n- **Releases:** See the [GitHub Releases](https://github.com/brucificus/vb6-antlr4-typescript/releases) page for release notes and\n  links to the distribution.\n- **Feedback:**\n  Got a feature request to make, or a bug to complain about? Depending on the nature of your feedback, it probably needs to go to one of three places:\n  - 📐 For the _grammar_ (which includes the API \"shape\" of the generated lexer/parser), provide feedback at [ProLeap Visual Basic 6.0 parser's GitHub Issues](https://github.com/uwol/proleap-vb6-parser/issues).\n  - 🔢 For the _code generated_ based on the grammar (or the runtime it depends on), provide feedback at [antlr4ts's GitHub Issues](https://github.com/tunnelvisionlabs/antlr4ts/issues).\n  - 🚀 For the _deployment process_ (versioning, update cadence, documentation), provide feedback at our own [GitHub Issues](https://github.com/brucificus/vb6-antlr4-typescript).\n\n  If in doubt, talk to us first so we can try to point you in the right direction.\n\n\n## Features\n\n- The grammar is line-based and takes into account whitespace, so that member calls (e.g. `A.B`) are distinguished from contextual object calls in WITH statements (e.g. `A .B`).\n- Keywords can be used as identifiers depending on the context, enabling e.g. `A.Type`, but not `Type.B`.\n- The ANTLR4 grammar is derived from the [Visual Basic 6.0 language reference](http://msdn.microsoft.com/en-us/library/aa338033%28v=vs.60%29.aspx) and tested against MSDN VB6 statement examples as well as several Visual Basic 6.0 code repositories.\n- Rigorous test-driven development.\n\n## Getting started\n\n1. Install `vb6-antlr4` and `antlr4ts` as dependencies using your preferred package manager.\n\n```bash\nnpm install vb6-antlr4 antlr4ts --save\n```\n\n```bash\nyarn add vb6-antlr4 antlr4ts\n```\n\n2. Use your grammar in TypeScript (or JavaScript)\n\n```typescript\nimport { VisualBasic6Lexer, VisualBasic6Parser } from \"vb6-antlr4\";\nimport { ANTLRInputStream, CommonTokenStream } from \"antlr4ts\";\n\n// Create the lexer and parser\nlet inputStream = new ANTLRInputStream(`\nPrivate Sub Command1_Click ()\n   Text1.Text = \"Hello, world!\"\nEnd Sub\n`);\nlet lexer = new VisualBasic6Lexer(inputStream);\nlet tokenStream = new CommonTokenStream(lexer);\nlet parser = new VisualBasic6Parser(tokenStream);\n\nlet tree = parser.startRule();\n```\n\nThe two main ways to inspect the tree are by using a listener or a visitor, you can read about the differences between the two [here](https://github.com/antlr/antlr4/blob/master/doc/listeners.md).\n\n###### Listener Approach\n\n```typescript\n// ...\nimport { VisualBasic6Listener, SubStmtContext } from \"vb6-antlr4\";\nimport { ParseTreeWalker } from \"antlr4ts/tree\";\n\nclass EnterSubListener implements VisualBasic6Listener {\n  enterSubStmt(context: SubStmtContext) {\n    console.log(`Sub start line number ${context._start.line}`);\n    // ...\n  }\n\n  // other enterX functions...\n}\n\n// Create the listener\nconst listener: VisualBasic6Listener = new EnterSubListener();\n// Use the entry point for listeners\nParseTreeWalker.DEFAULT.walk(listener, tree);\n```\n\n###### Visitor Approach\n\n```typescript\n// ...\nimport { VisualBasic6Visitor, SubStmtContext } from \"vb6-antlr4\";\nimport { AbstractParseTreeVisitor } from \"antlr4ts/tree\";\n\n// Extend the AbstractParseTreeVisitor to get default visitor behaviour\nclass CountSubsVisitor\n  extends AbstractParseTreeVisitor\u003cnumber\u003e\n  implements VisualBasic6Visitor\u003cnumber\u003e {\n\n  defaultResult() {\n    return 0;\n  }\n\n  aggregateResult(aggregate: number, nextResult: number) {\n    return aggregate + nextResult;\n  }\n\n  visitSubStmt(context: SubStmtContext): number {\n    return 1 + super.visitChildren(context);\n  }\n}\n\n// Create the visitor\nconst countSubsVisitor = new CountSubsVisitor();\n// Use the visitor entry point\nconst count = countSubsVisitor.visit(tree);\nconsole.log(`There are ${count} Subs`);\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrucificus%2Fvb6-antlr4-typescript","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbrucificus%2Fvb6-antlr4-typescript","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrucificus%2Fvb6-antlr4-typescript/lists"}