rrevenantt / antlr4rust

ANTLR4 parser generator runtime for Rust programming laguage
Other
398 stars 70 forks source link

Not building anymore on new versions #46

Closed rajasekarv closed 2 years ago

rajasekarv commented 2 years ago

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 commented 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.

newca12 commented 2 years ago

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

ilonachan commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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:

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 commented 2 years ago

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 commented 2 years ago

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.