Skip to main content

antlr_rust_codegen/
lib.rs

1//! ANTLR v4 grammar compiler and Rust source generator.
2
3mod artifact;
4mod builder;
5mod cli;
6mod driver;
7pub(crate) mod embedded;
8mod error;
9#[path = "pipeline.rs"]
10mod generator;
11#[allow(dead_code)]
12pub(crate) mod grammar;
13mod lexer;
14mod optimization;
15mod parser;
16mod rust_output;
17mod semantics;
18mod structural;
19
20pub use artifact::Generation;
21pub use builder::{ActionMode, Builder, UnknownSemanticPolicy};
22pub use error::{Diagnostic, Error, ErrorKind, Severity};
23
24/// Version of this generator package.
25pub const VERSION: &str = env!("CARGO_PKG_VERSION");
26
27/// Generated-source/runtime API revision emitted by this generator.
28pub const CODEGEN_API: u32 = antlr4_runtime::__ANTLR4_RUST_CODEGEN_API;
29
30#[cfg(test)]
31pub(crate) use generator::ParserCodegenData;
32#[cfg(test)]
33pub(crate) use parser::render_parser;
34#[cfg(test)]
35pub(crate) use rust_output::rust_string;
36#[cfg(test)]
37pub(crate) use semantics::collect_structural_grammar_options;
38#[cfg(test)]
39pub(crate) use structural::{structural_embedded_model, structural_predicates};
40
41/// Runs the `antlr4-rust-gen` command using the process arguments and streams.
42///
43/// The public [`Builder`] API is the preferred integration point for build
44/// scripts. This function exists for the package's binary adapter.
45#[doc(hidden)]
46pub fn run_cli() -> Result<(), Box<dyn std::error::Error>> {
47    cli::run_cli()
48}