Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not building anymore on new versions #46

Closed
rajasekarv opened this issue Jun 10, 2022 · 7 comments · Fixed by #29
Closed

Not building anymore on new versions #46

rajasekarv opened this issue Jun 10, 2022 · 7 comments · Fixed by #29

Comments

@rajasekarv
Copy link

Repo needs an update

Compiling antlr-rust v0.2.2 (/home/raja/work/rust/antlr4rust)
error[E0557]: feature has been removed
--> src/lib.rs:11:12
|
11 | #![feature(crate_visibility_modifier)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^ feature has been removed
|
= note: removed in favor of pub(crate)

error: expected one of ! or ::, found keyword fn
--> 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 here

error: expected one of ! or ::, found keyword struct
--> src/lexer.rs:113:7
|
113 | crate struct LexerPosition {
| ^^^^^^ expected one of ! or ::

error[E0432]: unresolved imports lexer::BaseLexer, lexer::Lexer
--> src/lib.rs:104:17
|
104 | pub use lexer::{BaseLexer, Lexer};
| ^^^^^^^^^ ^^^^^ no Lexer in lexer
| |
| no BaseLexer in lexer

error[E0432]: unresolved import crate::lexer::Lexer
--> src/lexer_action.rs:3:5
|
3 | use crate::lexer::Lexer;
| ^^^^^^^^^^^^^^^^^^^ no Lexer in lexer

error[E0432]: unresolved imports crate::lexer::LEXER_MAX_CHAR_VALUE, crate::lexer::LEXER_MIN_CHAR_VALUE
--> src/transition.rs:7:20
|
7 | use crate::lexer::{LEXER_MAX_CHAR_VALUE, LEXER_MIN_CHAR_VALUE};
| ^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^ no LEXER_MIN_CHAR_VALUE in lexer
| |
| no LEXER_MAX_CHAR_VALUE in lexer

error[E0432]: unresolved import crate::lexer::Lexer
--> src/lexer_action_executor.rs:6:5
|
6 | use crate::lexer::Lexer;
| ^^^^^^^^^^^^^^^^^^^ no Lexer in lexer

error[E0432]: unresolved imports crate::lexer::Lexer, crate::lexer::LexerPosition, crate::lexer::LEXER_MAX_CHAR_VALUE, crate::lexer::LEXER_MIN_CHAR_VALUE
--> src/lexer_atn_simulator.rs:21:20
|
21 | use crate::lexer::{Lexer, LexerPosition, LEXER_MAX_CHAR_VALUE, LEXER_MIN_CHAR_VALUE};
| ^^^^^ ^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^ no LEXER_MIN_CHAR_VALUE in lexer
| | | |
| | | no LEXER_MAX_CHAR_VALUE in lexer
| | no LexerPosition in lexer
| no Lexer in lexer

warning: unused attribute allow
--> src/token_factory.rs:17:1
|
17 | #[allow(non_upper_case_globals)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: #[warn(unused_attributes)] on by default
note: the built-in attribute allow will be ignored, since it's applied to the macro invocation lazy_static
--> src/token_factory.rs:18:1
|
18 | lazy_static! {
| ^^^^^^^^^^^

warning: unused import: crate::dfa::ScopeExt
--> src/atn.rs:6:5
|
6 | use crate::dfa::ScopeExt;
| ^^^^^^^^^^^^^^^^^^^^
|
= note: #[warn(unused_imports)] on by default

warning: 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 compile antlr-rust due to 8 previous errors; 9 warnings emitted

@ilonachan
Copy link

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.

@newca12
Copy link
Contributor

newca12 commented Jun 13, 2022

You should use branch v0.3 https://github.com/rrevenantt/antlr4rust/tree/v0.3 with rust stable toolchain.

@ilonachan
Copy link

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

@newca12
Copy link
Contributor

newca12 commented Jun 19, 2022

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.

@ilonachan
Copy link

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:

  • Because crates.io doesn't have v0.3 (or it looks like it kinda does, but under an incompatible crate name) I used this line instead in my Cargo.toml:
    antlr-rust = {git = "https://github.com/rrevenantt/antlr4rust", version = "0.3", branch = "v0.3"}
  • In order to generate the compatible code, I had to build the modified antlr4 version, but again modified to use the latest branch. I did that by cloning their antlr4 fork, then adding branch=v0.3 to the .gitmodules entry,
  • and then for some reason I had to go into runtime/Rust and do git checkout v0.3 (I have no experience with submodules, maybe that's just normal procedure)
  • finally a bunch of tests wouldn't compile, and -DskipTests did nothing for me, so I had to comment out the test module entries in the top-level pom.xml.
  • After that Antlr4 built properly, and the resulting jar can generate Rust parsers. (for total noobs: you can either 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.

@newca12
Copy link
Contributor

newca12 commented Jun 19, 2022

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.

@rrevenantt
Copy link
Owner

rrevenantt commented Jun 20, 2022

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.

@rrevenantt rrevenantt mentioned this issue Jul 5, 2022
36 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants