1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/*
* Databind - Expand the functionality of Minecraft Datapacks.
* Copyright (C) 2021 Adam Thompson-Sharpe
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
//! Expand the functionality of Minecraft Datapacks.
//!
//! ## CLI
//!
//! If you're just looking to use Databind as a tool and not to make your own
//! Rust project with it, then you can use the CLI. Documentation for it is
//! available [here](https://databind.rtfd.io/en/stable).
//!
//! ## Quick Start
//!
//! Here's some code to compile a given string and print the output
//! for each file:
//!
//! ```rust
//! use databind::compiler::{Compiler, macros::Macro};
//! use std::collections::HashMap;
//!
//! fn main() {
//! // Databind source file
//! let source_file = "
//! func main\n\
//! say Hello, World!\n\
//! end\n\
//! func second_func\n\
//! say Second function\n\
//! end"
//! .to_string();
//!
//! // Keep track of global macros
//! let mut macros: HashMap<String, Macro> = HashMap::new();
//!
//! // Compiled
//! let compiled = Compiler::compile(&source_file, "", None, &mut macros)
//! .expect("Compilation failed");
//!
//! // Print the contents of each file
//! for (file, contents) in compiled.files.iter() {
//! println!("Output File: {}.mcfunction", file);
//! println!("Contents:\n{}", contents);
//! println!("----------");
//! }
//! }
//! ```
//!
//! The code above results in the following output:
//!
//! ```text
//! Output File: main.mcfunction
//! Contents:
//! # Compiled with MysteryBlokHed/databind
//! say Hello, World!
//! ----------
//! Output File: second_func.mcfunction
//! Contents:
//! # Compiled with MysteryBlokHed/databind
//! say Second function
//! ----------
//! ```
extern crate pest_derive;
pub use Settings;
// Trigger CI