layered_nlp/ll_line/x/
functions.rs

1use super::*;
2use crate::TextTag;
3
4/// Match if one of the matchers match
5pub fn any_of<T: AnyOf>(tuple: T) -> T::Out {
6    tuple.into_any()
7}
8
9/// Match if all matchers match
10pub fn all<T: All>(tuple: T) -> T::Out {
11    tuple.into_all()
12}
13
14/// Match if all matchers match one after the other
15///
16/// Example going forward:
17///
18/// ```txt
19/// [ Matcher #1 ]
20///               [ Matcher #2 ]
21///                             [ Matcher #3 ]
22/// ```
23pub fn seq<T: Seq>(tuple: T) -> T::Out {
24    tuple.into_seq()
25}
26
27/// Match single token and provide their text representation
28pub fn token_text() -> TokenText {
29    TokenText(())
30}
31
32/// Match token with `A` attributes equal to `attr`
33pub fn attr_eq<A>(attr: &A) -> AttrEq<'_, A> {
34    AttrEq { attr }
35}
36
37/// Match token with `A` attributes equals to one of `attrs` value
38pub fn token_has_any<A: PartialEq>(attrs: &[A]) -> TokenHasAny<'_, A> {
39    TokenHasAny { one_of: attrs }
40}
41
42/// Match token with `A` attributes
43pub fn attr<A>() -> Attr<A> {
44    Attr(Default::default())
45}
46
47/// Match any number of consecutive spaces.
48pub fn whitespace() -> AttrEq<'static, TextTag> {
49    attr_eq(&TextTag::SPACE)
50}