proclet_utils/
lib.rs

1#![doc = include_str!("../README.md")]
2
3#[doc(hidden)]
4pub use proclet::{Match, MatchOpFn, OpParser, PunctExt};
5#[doc(hidden)]
6pub use proclet_utils_macros::_define_ops;
7
8/// Macro for making a function that will create an [`OpParser`] for parsing a specific set of operators.
9#[macro_export]
10macro_rules! define_ops {
11    ($(#[$attr:meta])* $vis:vis $ident:ident, $($ops:literal),* $(,)?) => {
12        $(#[$attr])*
13        #[inline]
14        // rust fails type inference if this function is const
15        $vis fn $ident<P: $crate::PunctExt>() -> $crate::OpParser<P, impl MatchOpFn> {
16            $crate::_define_ops!($($ops),*);
17            $crate::OpParser::new(__proclet_define_ops)
18        }
19    };
20}
21
22define_ops! {
23    /// Parse operators defined by the Rust language.
24    pub rust_op_parser,
25    "!", "!=", "#", "$", "%", "%=", "&", "&&", "&=", "*", "*=", "+", "+=", ",", "-", "-=", "->",
26    ".", "..", "...", "..=", "/", "/=", ":", "::", ";", "<", "<-", "<<", "<<=", "<=", "=", "==",
27    "=>", ">", ">=", ">>", ">>=", "?", "@", "^", "^=", "|", "|=", "||", "~",
28}