peginator_codegen/
lib.rs

1// Copyright (C) 2022, Alex Badics
2// This file is part of peginator
3// Licensed under the MIT license. See LICENSE file in the project root for details.
4
5//! This crate contains the code used for generating [`peginator`] parsing code from a
6//! grammar file. Unless you are using [`Compile`] in a buildscript, you
7//! probably want to see the [`peginator`] crate documentation instead.
8//!
9//! To integrate [`peginator`] using a buildscript, first add `peginator_codegen` as
10//! a build dependency in your `Cargo.toml`:
11//!
12//! ```toml
13//! [build-dependencies]
14//! peginator_codegen = "0.6"
15//! ```
16//!
17//! And then in your `build.rs`:
18//!
19//! ```ignore
20//! use peginator_codegen::Compile;
21//!
22//! fn main() {
23//!     let out = format!("{}/grammar.rs", std::env::var("OUT_DIR").unwrap());
24//!
25//!     peginator_codegen::Compile::file("grammar.ebnf")
26//!         .destination(out)
27//!         .format()
28//!         .run_exit_on_error();
29//!
30//!     println!("cargo:rerun-if-changed=grammar.ebnf");
31//! }
32//! ```
33//!
34//! See the documentation of [`Compile`] for more advanced options.
35
36#[doc(hidden)]
37pub mod grammar;
38
39mod buildscript;
40mod char_rule;
41mod choice;
42mod closure;
43mod common;
44mod eoi;
45mod extern_rule;
46mod field;
47mod header;
48mod include_rule;
49mod lookahead;
50mod misc;
51mod optional;
52mod rule;
53mod sequence;
54mod string;
55
56pub use buildscript::Compile;
57#[doc(hidden)]
58pub use common::{CodegenGrammar, CodegenSettings};
59#[doc(hidden)]
60pub use grammar::Grammar;
61#[doc(hidden)]
62pub use header::generate_source_header;
63
64#[doc(hidden)]
65pub const VERSION: &str = env!("CARGO_PKG_VERSION");
66
67#[doc(hidden)]
68pub const BUILD_TIME: &str = env!("PEGINATOR_BUILD_TIME");