luau_lexer/
lib.rs

1#![doc = include_str!("../README.md")]
2#![deny(unsafe_code)]
3#![warn(clippy::missing_docs_in_private_items)]
4#![warn(missing_docs)]
5#![warn(clippy::absolute_paths)]
6#![warn(clippy::missing_const_for_fn)]
7#![deny(unused_must_use)]
8#![deny(dead_code)]
9#![deny(unused_assignments)]
10#![warn(clippy::missing_errors_doc)]
11#![warn(clippy::missing_panics_doc)]
12#![warn(clippy::doc_markdown)]
13#![warn(clippy::module_name_repetitions)]
14#![warn(clippy::wildcard_imports)]
15#![warn(clippy::too_many_arguments)]
16#![warn(clippy::large_types_passed_by_value)]
17#![warn(clippy::needless_pass_by_value)]
18#![warn(clippy::inefficient_to_string)]
19#![warn(clippy::unwrap_used)]
20#![warn(clippy::expect_used)]
21#![warn(clippy::nursery)]
22
23/// A simple macro to reexport modules and include them in [`prelude`].
24macro_rules! reexport {
25    ($($name: ident $({$($inner:ident as $inner_name:ident),+ $(,)?})?),* $(,)?) => {
26        $( pub mod $name; )*
27
28        /// Loads all needed items for outside crates to use.
29        pub mod prelude {
30            $(
31                pub use crate::$name::*;
32                $($( pub use crate::$name::$inner as $inner_name; )+)?
33            )*
34        }
35    };
36}
37
38/// A simple macro to reexport modules without including them in [`prelude`].
39macro_rules! crate_reexport {
40    ($($name: ident),* $(,)?) => {
41        $( pub mod $name; )*
42
43        $( pub use $name::*; )*
44    };
45}
46
47/// Implements the [`From`] trait for the passed structs. This is meant for
48/// enums only.
49///
50/// # Usage
51///
52/// ```ignore
53/// impl_from!(name <= {
54///     enum1::struct1,
55/// }) // This will implement `From<enum1::struct1>` for `name`
56///
57/// ```
58macro_rules! impl_from {
59    ($struct: ident <= { $($enum: ident ($type: ty)),* $(,)? }) => {
60        $(
61            impl From<$type> for $struct {
62                #[inline]
63                fn from(value: $type) -> Self {
64                    Self::$enum(value)
65                }
66            }
67        )*
68    };
69}
70
71mod utils;
72
73reexport!(
74    lexer,
75    state,
76    position { Ext as PositionExt },
77    error,
78    token
79);