1#![allow(clippy::comparison_chain)]
2#![allow(clippy::needless_range_loop)]
3
4pub mod earley;
10
11mod matcher;
12mod tokenparser;
13pub use tokenparser::TokenParser;
14pub mod api;
15pub mod output;
16pub use toktrie;
17pub mod panic_utils;
18
19mod constraint;
20mod stop_controller;
21mod tokenizer_json;
22pub use constraint::{CommitResult, Constraint};
23pub use matcher::Matcher;
24
25mod factory;
26pub use factory::ParserFactory;
27
28mod logging;
29pub use logging::Logger;
30
31pub use derivre;
32pub use derivre::{HashMap, HashSet};
33
34pub mod ffi;
35#[cfg(feature = "rayon")]
36mod ffi_par;
37
38mod grammar_builder;
39mod json;
40#[cfg(feature = "jsonschema_validation")]
41mod json_validation;
42mod regex_rewrite;
43pub mod substring;
44pub use grammar_builder::{GrammarBuilder, NodeRef};
45pub use json::compiler::JsonCompileOptions;
46pub use json::json_merge;
47pub use stop_controller::StopController;
48pub use tokenizer_json::token_bytes_from_tokenizer_json;
49
50#[cfg(feature = "lark")]
51mod lark;
52
53pub use regex_rewrite::regex_to_lark;
54
55#[cfg(feature = "wasm")]
56pub use instant::Instant;
57
58#[cfg(not(feature = "wasm"))]
59pub use std::time::Instant;
60
61#[macro_export]
62macro_rules! loginfo {
63 ($s:expr, $($arg:tt)*) => {
64 if $s.level_enabled(2) {
65 use std::fmt::Write;
66 writeln!($s.info_logger(), $($arg)*).unwrap();
67 }
68 };
69}
70
71#[macro_export]
72macro_rules! infoln {
73 ($s:expr, $($arg:tt)*) => {
74 if $s.logger.level_enabled(2) {
75 use std::fmt::Write;
76 writeln!($s.logger.info_logger(), $($arg)*).unwrap();
77 }
78 };
79}
80
81#[macro_export]
82macro_rules! warn {
83 ($s:expr, $($arg:tt)*) => {
84 if $s.logger.level_enabled(1) {
85 use std::fmt::Write;
86 $s.logger.write_warning("Warning: ");
87 writeln!($s.logger.warning_logger(), $($arg)*).unwrap();
88 }
89 };
90}
91
92#[macro_export]
93macro_rules! id32_type {
94 ($name:ident) => {
95 #[derive(serde::Serialize, serde::Deserialize, Hash, PartialEq, Eq, Clone, Copy, Debug)]
96 #[serde(transparent)]
97 pub struct $name(pub u32);
98
99 impl $name {
100 pub fn as_usize(&self) -> usize {
101 self.0 as usize
102 }
103
104 pub fn new(idx: usize) -> Self {
105 $name(idx as u32)
106 }
107 }
108 };
109}