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 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146
#![warn(missing_docs)]
#![doc = include_str!("../README.md")]
//! ## This Documentation
//!
//! * [Explanation of Concepts used in scope graphs](concepts)
//! * Examples:
//! * [Standard patterns](patterns)
//! * [API Docs](https://docs.rs/scopegraphs)
#![cfg_attr(docsrs, feature(doc_auto_cfg, doc_cfg))]
#![cfg_attr(not(docsrs), allow(rustdoc::broken_intra_doc_links))]
#![allow(unknown_lints)]
#![allow(unexpected_cfgs)]
#![allow(clippy::empty_docs)]
#[cfg(feature = "documentation")]
pub mod concepts;
#[cfg(feature = "documentation")]
pub mod patterns;
#[macro_use]
mod label;
pub use label::Label;
#[cfg(feature = "dot")]
pub mod render;
pub use scopegraphs_regular_expressions::*;
pub mod completeness;
pub mod containers;
mod future_wrapper;
pub mod resolve;
mod scopegraph;
pub use scopegraph::{Scope, ScopeGraph};
mod storage;
pub use storage::Storage;
/// Derive [`Label`] implementation.
///
/// ```rust
/// # use std::borrow;
/// use scopegraphs::*;
/// use scopegraphs::Label;
///
/// #[derive(Label, Debug, PartialEq, Eq)]
/// pub enum Alphabet {
/// A,
/// B,
/// C,
/// }
/// use Alphabet::*;
///
/// assert_eq!(vec![A, B, C], Alphabet::iter().collect::<Vec<_>>());
/// ```
pub use scopegraphs_macros::Label;
/// Compile a regular expression into Rust code.
///
/// Generates a struct implementing [`RegexMatcher`].
/// Instances of this struct can match the regular expression that is specified.
///
/// Syntax: `$attrs type $type<$alphabet_type> = regex`.
/// For example:
///
/// ```rust
/// # use std::borrow;
/// use scopegraphs::*;
///
/// pub enum Alphabet {
/// A,
/// B,
/// C,
/// }
/// use Alphabet::*;
///
/// compile_regex!(type Machine<Alphabet> = A* B);
/// assert!(Machine::new().accepts([A, B]));
/// ```
///
/// # Supported Attributes
/// * `#[graph="$path"]` location to put a graphviz dot file representing the generated finite state machine. (only with the `dot` feature)
///
/// # Query Directly
///
/// Instead of using [`compile_regex`], you can also use [`query_regex`], which has a simpler syntax
/// and can immediately be used to match a string. This is useful if you want to use a regular expression
/// only once.
/// ```
/// # use std::borrow;
/// # use scopegraphs::*;
/// #
/// # pub enum Alphabet {
/// # A,
/// # B,
/// # C,
/// # }
/// # use Alphabet::*;
/// use scopegraphs::query_regex;
/// assert!(query_regex!(Alphabet: A* B).accepts([A, B]));
/// ```
pub use scopegraphs_macros::compile_regex;
/// Define a [label ordering](crate::concepts::label_ordering), an implementation of [`LabelOrder`](crate::resolve::LabelOrder)
///
/// Syntax:
/// ```grammar
/// $type: $( $label_order ),*
/// ```
/// with
/// ```grammar
/// $label_order: $( $label_group )<*
/// $label_group: { $($variant),* } | $variant
/// $variant: $ident | '$'
/// ```
///
/// For example
/// ```rust
/// # use scopegraphs_macros::label_order;
///
/// #[derive(Copy, Clone)]
/// enum Lbl {
/// Def,
/// Mod,
/// Lex,
/// Imp,
/// }
///
/// label_order!(Lbl: $ < { Def, Mod } < Lex, Imp < Lex);
/// ```
///
/// Here, `$` means the end-of-path label: i.e., the current scope.
///
/// Using `{ ... }`, labels with equal priority can be grouped.
///
/// Multiple partial orders can be combined using `,`-separators: `X < Y, Z < Y`.
///
/// Sequences of multiple `<` can be chained (`X < Y < Z`).
/// This is equivalent to the 2-windowed decomposition: `X < Y, Y < Z` (which, by transitivity, also includes `X < Z`).
///
/// The macro will at compile time validate whether the order is a strict partial order, and report
/// any symmetric or reflexive entries.
pub use scopegraphs_macros::label_order;