{"id":18339032,"url":"https://github.com/xoofx/antlr4ast","last_synced_at":"2025-04-06T05:31:56.848Z","repository":{"id":61147556,"uuid":"547872933","full_name":"xoofx/Antlr4Ast","owner":"xoofx","description":"Antlr4Ast is a .NET library that provides a parser and abstract syntax tree (AST) for ANTLR4/g4 files.","archived":false,"fork":false,"pushed_at":"2024-03-17T14:04:08.000Z","size":980,"stargazers_count":54,"open_issues_count":1,"forks_count":2,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-21T18:06:15.323Z","etag":null,"topics":["abstract-syntax-tree","antlr","antlr4","ast","csharp","dotnet","parser"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/xoofx.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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},"funding":{"github":["xoofx"]}},"created_at":"2022-10-08T13:16:22.000Z","updated_at":"2025-03-10T18:31:14.000Z","dependencies_parsed_at":"2024-02-13T09:31:05.254Z","dependency_job_id":"bd26e9df-15dd-4330-b697-f2f1951fca52","html_url":"https://github.com/xoofx/Antlr4Ast","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xoofx%2FAntlr4Ast","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xoofx%2FAntlr4Ast/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xoofx%2FAntlr4Ast/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xoofx%2FAntlr4Ast/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xoofx","download_url":"https://codeload.github.com/xoofx/Antlr4Ast/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247440351,"owners_count":20939220,"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":["abstract-syntax-tree","antlr","antlr4","ast","csharp","dotnet","parser"],"created_at":"2024-11-05T20:16:15.877Z","updated_at":"2025-04-06T05:31:54.977Z","avatar_url":"https://github.com/xoofx.png","language":"C#","funding_links":["https://github.com/sponsors/xoofx"],"categories":[],"sub_categories":[],"readme":"# Antlr4Ast [![ci](https://github.com/xoofx/Antlr4Ast/actions/workflows/ci.yml/badge.svg)](https://github.com/xoofx/Antlr4Ast/actions/workflows/ci.yml) [![Coverage Status](https://coveralls.io/repos/github/xoofx/Antlr4Ast/badge.svg?branch=main)](https://coveralls.io/github/xoofx/Antlr4Ast?branch=main) [![NuGet](https://img.shields.io/nuget/v/Antlr4Ast.svg)](https://www.nuget.org/packages/Antlr4Ast/)\n\n\u003cimg align=\"right\" width=\"160px\" height=\"160px\" src=\"img/antlr4ast.png\"\u003e\n\nAntlr4Ast is a .NET library that provides a parser and abstract syntax tree (AST) for [ANTLR4](https://www.antlr.org/)/g4 files. \n\n\u003e This can be useful if you are looking for building code generation tools from ANTLR4/g4 files.\n  \n## Features\n\n- Allow to **parse** and **merge** ANTLR4/g4 files to a simple AST.\n  - Should support almost all grammar features of ANTLR4/g4 except actions.\n- Provides **precise source location** for most of the AST elements.\n- Provides **access to comments** attached to syntax nodes.\n- Provides **visitor** and **transform**.\n- Library with nullable annotations.\n- Compatible with `netstandard2.0`\n\n\u003e Limitations\n\u003e\n\u003e As this library is mainly for codegen scenarios, it does not preserve whitespaces or the position of some comments within elements.\n\u003e There is no plan to support high fidelity roundtrip ANTLR4 parser.\n\n## Usage\n\nThe entry point for parsing an ANTLR4/g4 grammar is to use the `Grammar.Parse` methods:\n\n```c#\nvar input = @\"grammar MyGrammar;\n// Parser rules starting here!\nexpr_a_plus_b\n    : TOKEN_A '+' TOKEN_B\n    ;\n// Lexer rules starting here!\nTOKEN_A: 'a';\nTOKEN_B: 'b';\n\";\n// Parse the grammar\nvar grammar = Grammar.Parse(input);\n// Print the grammar\nConsole.WriteLine(\n    grammar.ToString(\n        new AntlrFormattingOptions() { \n                    MultiLineWithComments = true \n        }\n    )\n);\n```\n\nwill print the following:\n\n```antlr\ngrammar MyGrammar;\n\n// Parser rules starting here!\nexpr_a_plus_b\n  : TOKEN_A '+' TOKEN_B\n  ;\n\n// Lexer rules starting here!\nTOKEN_A\n  : 'a'\n  ;\n\nTOKEN_B\n  : 'b'\n  ;\n```\n\n### Documentation\n\nYou will find more details about how to use Antlr4Ast in this [user guide](https://github.com/xoofx/Antlr4Ast/blob/main/doc/readme.md).\n\n## License\n\nThis software is released under the [BSD-Clause 2 license](https://opensource.org/licenses/BSD-2-Clause). \n\n## Author\n\nAlexandre Mutel aka [xoofx](https://xoofx.github.io).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxoofx%2Fantlr4ast","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxoofx%2Fantlr4ast","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxoofx%2Fantlr4ast/lists"}