Quick start on ANTLR4 in Rust - part3
This is my note in adopting and learning ANTLR4Rust
Series
- Quick Start on ANTLR4 in Rust — Part1
- Quick Start on ANTLR4 in Rust — Part2
- Quick Start on ANTLR4 in Rust — Part3 (This article)
In the previous article, we implemented a parser with internal state variables. However, if a grammar is huge, it is practically impossible to manage a huge number of state variables. Alternatively, a visitor-like approach can be used.
In an exit method of the root rule in the Listener, we can grab the current context and its children and call custom parser methods:
1 | impl Listener { |
The minimal working example can be found here.