Closed dfrankland closed 3 years ago
I've also run into the case that I need to extend the functionality of BaseLexer
to emit more tokens. It seems that BaseLexer
should be a trait that other traits have a constraint on so that user-provided functionality is possible.
I was able to get superClass
to be supported by fixing up the antlr4
repo's rust-target
branch's Rust template and fixing the LexerRecog
trait to be generic.
Fix for antlr4
template:
https://github.com/rrevenantt/antlr4/compare/rust-target...dfrankland:rust-target-fix-superClass
Fix for antlr4rust
:
https://github.com/dfrankland/antlr4rust/compare/6f3ac16...9c1557c
You can see the full changes and the tests for antlr4
here:
https://github.com/rrevenantt/antlr4rust/compare/master...dfrankland:fix_base_lexer_deref
I am trying to use
antlr4rust
with a stateful lexer that is already implemented in C++ and TypeScript.It seems the best way to do this is to add to the lexer
fields
/members
, but there's no way to reference them from from theBaseLexer
.BaseParser
seems toderef
to its innerext
, so I thought thatBaseLexer
should probably be doing something similar byderef
ing to its innerrecog
.Here's the change I am thinking of: https://github.com/dfrankland/antlr4rust/commit/6f3ac161da1defa06560eea12ab3dd243bcfaf31
Does that seem correct?