Closed rajasekarv closed 2 years ago
I'm pretty new to rust, but from what I can tell the syntax crate fn
/crate <field>
has been replaced with pub(crate)
. I got a patch if that helps, but it also takes like 5 minutes to fix manually.
You should use branch v0.3 https://github.com/rrevenantt/antlr4rust/tree/v0.3 with rust stable toolchain.
ooh that's really good to know! I didn't even realize that branch existed, maybe it'd be good to put a notice in the README
I agree but the main maintainer is unfortunatly unresponsive but has done a tremondous job to get that far. Branch v0.3 is in a very good shape (https://github.com/newca12/the-definitive-antlr4-reference-rs) and would deserve to be released as is. This branch also solve all the complaints about visitor not returning data (https://github.com/newca12/playground-rs/tree/main/antlr-calc). This mean that more than half of the issues could be closed. antlr4rust is probably one of the most underrated Rust project because of this. Great thanks to the maintainer for what has been done anyway.
Absolutely agreed, this is fantastic work! And I hope it does get merged at some point, tho if @rrevenantt is actually gone that seems unlikely to happen.
It's a real shame too, since in the meantime the README could really use a few pointers on how to get this to work. I hope it's ok if I write down the steps I took migrating my project to use v0.3:
Cargo.toml
:antlr-rust = {git = "https://github.com/rrevenantt/antlr4rust", version = "0.3", branch = "v0.3"}
branch=v0.3
to the .gitmodules
entry,runtime/Rust
and do git checkout v0.3
(I have no experience with submodules, maybe that's just normal procedure)-DskipTests
did nothing for me, so I had to comment out the test module entries in the top-level pom.xml
.mvn install
to register the libraries system-wide, or mvn package
and grab the resulting tool jar from tool/target
)Just putting that here in case someone even less knowledgeable than me stumbles over this issue. If you got more experience, feel free to roast my workflow.
A more straightforward way (but require at least git 2..22) : git clone -b rust-target https://github.com/rrevenantt/antlr4 cd antlr4 git submodule update --init --recursive git submodule set-branch --branch v0.3 runtime/Rust git submodule update --remote mvn -DskipTests install This will produce the generator : ./tool/target/antlr4-4.8-2-SNAPSHOT-complete.jar Example to check that v0.3 is used : java -jar ./antlr4-4.8-2-SNAPSHOT-complete.jar -Dlanguage=Rust -visitor LabeledExpr.g4 If you see the trait LabeledExprVisitorCompat in labeledexprvisitor.rs then you're done.
Hi, sorry for the delay with v0.3, recent world events seriously baffled me so i needed some time to adapt to the situation. I will be able get back to working on this project during upcoming weekend.
Repo needs an update
= note: removed in favor of
pub(crate)
error: expected one of
!
or::
, found keywordfn
--> src/atn.rs:58:11 | 57 | impl ATN { | - while parsing this item list starting here 58 | crate fn new_atn(grammar_type: ATNType, max_token_type: isize) -> ATN { | ^^ expected one of!
or::
... 175 | } | - the item list ends hereerror: expected one of
!
or::
, found keywordstruct
--> src/lexer.rs:113:7 | 113 | crate struct LexerPosition { | ^^^^^^ expected one of!
or::
lexer::BaseLexer
,lexer::Lexer
--> src/lib.rs:104:17Lexer
inlexer
BaseLexer
inlexer
error[E0432]: unresolved import
crate::lexer::Lexer
--> src/lexer_action.rs:3:5 | 3 | use crate::lexer::Lexer; | ^^^^^^^^^^^^^^^^^^^ noLexer
inlexer
crate::lexer::LEXER_MAX_CHAR_VALUE
,crate::lexer::LEXER_MIN_CHAR_VALUE
--> src/transition.rs:7:20LEXER_MIN_CHAR_VALUE
inlexer
LEXER_MAX_CHAR_VALUE
inlexer
error[E0432]: unresolved import
crate::lexer::Lexer
--> src/lexer_action_executor.rs:6:5 | 6 | use crate::lexer::Lexer; | ^^^^^^^^^^^^^^^^^^^ noLexer
inlexer
crate::lexer::Lexer
,crate::lexer::LexerPosition
,crate::lexer::LEXER_MAX_CHAR_VALUE
,crate::lexer::LEXER_MIN_CHAR_VALUE
--> src/lexer_atn_simulator.rs:21:20LEXER_MIN_CHAR_VALUE
inlexer
LEXER_MAX_CHAR_VALUE
inlexer
LexerPosition
inlexer
Lexer
inlexer
allow
--> src/token_factory.rs:17:1= note:
#[warn(unused_attributes)]
on by default note: the built-in attributeallow
will be ignored, since it's applied to the macro invocationlazy_static
--> src/token_factory.rs:18:1 | 18 | lazy_static! { | ^^^^^^^^^^^crate::dfa::ScopeExt
--> src/atn.rs:6:5= note:
#[warn(unused_imports)]
on by defaultwarning: unused import:
crate::interval_set::IntervalSet
--> src/atn.rs:7:5 | 7 | use crate::interval_set::IntervalSet; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^warning: unused import:
crate::ll1_analyzer::LL1Analyzer
--> src/atn.rs:9:5 | 9 | use crate::ll1_analyzer::LL1Analyzer; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^warning: unused import:
crate::parser::ParserNodeType
--> src/atn.rs:10:5 | 10 | use crate::parser::ParserNodeType; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^warning: unused import:
crate::rule_context::EmptyContextType
--> src/atn.rs:11:5 | 11 | use crate::rule_context::EmptyContextType; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^warning: unused imports:
TOKEN_EOF
,TOKEN_EPSILON
--> src/atn.rs:12:20 | 12 | use crate::token::{TOKEN_EOF, TOKEN_EPSILON}; | ^^^^^^^^^ ^^^^^^^^^^^^^warning: unused import:
crate::token_factory::CommonTokenFactory
--> src/atn.rs:13:5 | 13 | use crate::token_factory::CommonTokenFactory; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^warning: unused import:
crate::transition::RuleTransition
--> src/atn.rs:14:5 | 14 | use crate::transition::RuleTransition; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^Some errors have detailed explanations: E0432, E0557. For more information about an error, try
rustc --explain E0432
. warning:antlr-rust
(lib) generated 9 warnings error: could not compileantlr-rust
due to 8 previous errors; 9 warnings emitted