feat: add ANTLR v4 grammar parser with CI integration #13
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Adds a Go-based ANTLR v4 grammar parser that can parse all
.g4grammar files in the repository. This serves as the foundation for future grammar-based fuzzing tools and grammar validation.Changes
Core Implementation
tools/grammar/- New Go ANTLR v4 grammar parserANTLRv4Lexer.g4,ANTLRv4Parser.g4- ANTLR v4 grammars from upstreamlexer_adaptor.go- Custom lexer with context-sensitive parsingparser_test.go- Comprehensive test suiteMakefile- Build automation with auto-fixingREADME.md- DocumentationCI Integration
.github/workflows/tests.yml- Addedantlr-grammar-testsjob.g4file changes ortools/grammar/changesgo-testsjoball-tests-passedrequirementKey Features
✅ 100% Success Rate - Parses all 12 grammar files in repository:
✅ Context-Sensitive Parsing - Handles complex ANTLR constructs:
IDtokens toTOKEN_REF/RULE_REFbased on case[charset]vs[actions]based on context✅ Automated Workflow - Smart CI integration:
Technical Details
Go ANTLR Challenges Solved
TokenTypeWrapperto override token typesNextToken()instead ofEmit()Source Attribution
Usage
Future Use Cases
This parser enables: