{"id":22408343,"url":"https://github.com/phmatray/antlr4library","last_synced_at":"2026-04-28T22:34:24.511Z","repository":{"id":265665149,"uuid":"875592585","full_name":"phmatray/Antlr4Library","owner":"phmatray","description":"A .NET template for creating Antlr4 projects in C#, including a sample CSV parser for building language parsers and interpreters","archived":false,"fork":false,"pushed_at":"2026-03-09T11:40:32.000Z","size":386,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"dev","last_synced_at":"2026-03-09T14:56:08.463Z","etag":null,"topics":["antlr","csharp","design-patterns","dotnet","nuke","parser","template"],"latest_commit_sha":null,"homepage":"https://www.nuget.org/packages/Antlr4Library","language":"C#","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/phmatray.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-10-20T11:57:37.000Z","updated_at":"2026-03-04T22:56:51.000Z","dependencies_parsed_at":"2024-11-30T12:20:46.762Z","dependency_job_id":"5ebfcd5c-3706-4581-8dfa-1521ed21731e","html_url":"https://github.com/phmatray/Antlr4Library","commit_stats":null,"previous_names":["phmatray/antlr4library"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/phmatray/Antlr4Library","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phmatray%2FAntlr4Library","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phmatray%2FAntlr4Library/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phmatray%2FAntlr4Library/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phmatray%2FAntlr4Library/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/phmatray","download_url":"https://codeload.github.com/phmatray/Antlr4Library/tar.gz/refs/heads/dev","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phmatray%2FAntlr4Library/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32402670,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-28T19:38:08.556Z","status":"ssl_error","status_checked_at":"2026-04-28T19:37:55.688Z","response_time":56,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["antlr","csharp","design-patterns","dotnet","nuke","parser","template"],"created_at":"2024-12-05T11:17:20.292Z","updated_at":"2026-04-28T22:34:24.499Z","avatar_url":"https://github.com/phmatray.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Atypical Antlr4 Library Template\n\n[![NuGet](https://img.shields.io/nuget/v/Atypical.Antlr4Library.Templates)](https://www.nuget.org/packages/Atypical.Antlr4Library.Templates)\n[![NuGet Downloads](https://img.shields.io/nuget/dt/Atypical.Antlr4Library.Templates)](https://www.nuget.org/packages/Atypical.Antlr4Library.Templates)\n[![Build](https://github.com/phmatray/Antlr4Library/actions/workflows/continuous.yml/badge.svg)](https://github.com/phmatray/Antlr4Library/actions/workflows/continuous.yml)\n[![License](https://img.shields.io/github/license/phmatray/Antlr4Library)](LICENSE)\n\nA .NET template for creating Antlr4 projects in C#, including a sample CSV parser. This template provides a starting point for building language parsers or interpreters using Antlr4 in a C# environment.\n\n## Table of Contents\n\n- [Overview](#overview)\n- [Features](#features)\n- [Installation](#installation)\n- [Usage](#usage)\n- [Project Structure](#project-structure)\n- [Customization](#customization)\n- [Contributing](#contributing)\n- [License](#license)\n- [About](#about)\n\n## Overview\n\nThis template includes:\n\n- An Antlr4 grammar file (`CSV.g4`) for parsing CSV files.\n- Generated lexer and parser classes.\n- A service class demonstrating how to use the parser.\n- A visitor class implementing the logic to build a CSV model.\n- A model class representing the parsed CSV data.\n- Pre-configured project files for building and packaging.\n\n## Features\n\n- **Antlr4 Integration**: Seamless integration with Antlr4 for parsing custom languages or data formats.\n- **Sample Grammar**: Includes a sample CSV grammar to get you started.\n- **Visitor Pattern**: Implements the visitor pattern for traversing the parse tree.\n- **Easy Customization**: Modify the grammar and visitor classes to suit your needs.\n- **.NET 8 Support**: Built targeting .NET 8.0 for the latest features and performance improvements.\n\n## Installation\n\nInstall the template using the `dotnet new` command:\n\n```bash\ndotnet new install Atypical.Antlr4Library.Templates\n```\n\n## Usage\n\nCreate a new project using the template:\n\n```bash\ndotnet new antlr4 -n YourProjectName\n```\n\nThis command creates a new directory `YourProjectName` with the template contents.\n\n### With JetBrains Rider or Visual Studio\n\n![With JetBrains Rider](https://raw.githubusercontent.com/phmatray/Antlr4Library/refs/heads/main/assets/new-project-rider.png)\n\nYou can create a new project using JetBrains Rider or Visual Studio by selecting the `Antlr4 Library` template from the project creation dialog.\n\nFor color syntax highlighting and code completion, install the [ANTLR v4](https://plugins.jetbrains.com/plugin/7358-antlr-v4) plugin by Terence Parr.\n\n## Project Structure\n\n- `Grammar/CSV.g4`: The Antlr4 grammar file for CSV parsing.\n- `Models/CSV.cs`: The model class representing the CSV data.\n- `Services/CSVService.cs`: Service class to parse CSV data using the generated parser.\n- `Services/CSVVisitor.cs`: Visitor class to build the CSV model from the parse tree.\n- `Antlr4Library.csproj`: Project file with Antlr4 build tasks and runtime dependencies.\n- `Program.cs`: Sample program demonstrating how to use the `CSVService`.\n\n## Customization\n\n### Modifying the Grammar\n\nEdit the `Grammar/CSV.g4` file to change the grammar rules or create a new grammar for your specific language or data format.\n\nAfter modifying the grammar, rebuild the project to regenerate the parser and lexer classes:\n\n```bash\ndotnet build\n```\n\n### Updating the Visitor\n\nModify `CSVVisitor.cs` to implement custom logic for traversing the parse tree generated by your grammar.\n\n### Parsing Custom Data\n\nUse `CSVService.cs` as a reference to create your own service classes for parsing different types of data.\n\n## Contributing\n\nContributions are welcome! If you find any issues or have suggestions for improvements, please open an issue or submit a pull request to the repository.\n\n## License\n\nThis project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.\n\n## About\n\nDeveloped and maintained by [Philippe Matray](https://www.linkedin.com/in/phmatray), founder of [Atypical Consulting SRL](https://atypical.consulting).\n\n---\n\n## What is Antlr4?\n\nCreated by Terence Parr, [Antlr4](https://www.antlr.org/) is a powerful parser generator for reading, processing, executing, or translating structured text or binary files. It's widely used to build language parsers, interpreters, and compilers for various programming languages and data formats.\n\nIt has been around for many years and has a large community of users and contributors. Antlr4 is available for multiple programming languages, including Java, C#, Python, and JavaScript.\n\n## Quick Start Guide\n\n1. **Install the Template**\n\n   ```bash\n   dotnet new install Atypical.Antlr4Library.Templates\n   ```\n\n2. **Create a New Solution**\n\n   ```bash\n   mkdir AntlrDemo\n   cd AntlrDemo\n   dotnet new sln -n MyAntlrSolution\n   ```\n\n3. **Create a New Antlr4 Project**\n\n   ```bash\n   dotnet new antlr4 -n MyAntlrLibrary\n   dotnet sln add MyAntlrLibrary\n   ```\n\n4. **Create a Console Application with the demo code**\n\n   ```bash\n   dotnet new console -n MyAntlrApp\n   dotnet add MyAntlrApp reference MyAntlrLibrary\n   dotnet sln add MyAntlrApp\n   ```\n    \n   Replace the contents of `Program.cs` with the following code:\n    \n   ```csharp\n   using MyAntlrLibrary.Services;\n\n   const string csvInput =\n       \"\"\"\"\n       Details,Month,Amount\n       Mid Bonus,June,\"$2,000\"\n       ,January,\"\"\"zippo\"\"\"\n       Total Bonuses,\"\",\"$5,000\"\n       \"\"\"\";\n    \n   var service = new CSVService();\n   var csv = service.Parse(csvInput);\n    \n   Console.WriteLine(string.Join(\", \", csv.Header));\n   Console.WriteLine(\"---------------------\");\n    \n   foreach (var row in csv.Rows)\n   {\n       Console.WriteLine(string.Join(\", \", row));\n   }\n   ```\n   \n   Then build and run the application:\n    \n   ```bash\n   dotnet run --project MyAntlrApp\n   ```\n    \n   You should see the parsed CSV output in the console.\n\n---\n\n## Contact\n\nFor support or inquiries, please contact Philippe Matray at [philippe@atypical.consulting](mailto:philippe@atypical.consulting) or open an issue in the repository.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphmatray%2Fantlr4library","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphmatray%2Fantlr4library","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphmatray%2Fantlr4library/lists"}