tengri/dsl/src/lib.rs
unspeaker c8827b43c3
Some checks failed
/ build (push) Has been cancelled
wip: slowly remembering where i was
2025-06-13 11:42:20 +03:00

51 lines
2 KiB
Rust

//! [Token]s are parsed substrings with an associated [Value].
//!
//! * [ ] FIXME: Value may be [Err] which may shadow [Result::Err]
//! * [Value::Exp] wraps an expression depth and a [SourceIter]
//! with the remaining part of the expression.
//! * expression depth other that 0 mean unclosed parenthesis.
//! * closing and unopened parenthesis panics during reading.
//! * [ ] TODO: signed depth might be interesting
//! * [Value::Sym] and [Value::Key] are stringish literals
//! with slightly different parsing rules.
//! * [Value::Num] is an unsigned integer literal.
//!```
//! use tengri_dsl::{*, Value::*};
//! let source = include_str!("../test.edn");
//! let mut view = TokenIter::new(source);
//! assert_eq!(view.peek(), Some(Token {
//! source,
//! start: 0,
//! length: source.len(),
//! value: Exp(0, TokenIter::new(&source[1..]))
//! }));
//!```
//! The token iterator [TokenIter] allows you to get the
//! general-purpose syntactic [Token]s represented by the source text.
//!
//! Both iterators are `peek`able:
//!
//! ```
//! let src = include_str!("../test.edn");
//! let mut view = tengri_dsl::TokenIter::new(src);
//! assert_eq!(view.0.0, src);
//! assert_eq!(view.peek(), view.0.peek())
//! ```
#![feature(adt_const_params)]
#![feature(type_alias_impl_trait)]
#![feature(impl_trait_in_fn_trait_return)]
pub(crate) use ::tengri_core::*;
pub(crate) use std::fmt::Debug;
pub(crate) use std::fmt::{Display, Formatter, Error as FormatError};
pub(crate) use konst::iter::{ConstIntoIter, IsIteratorKind};
pub(crate) use konst::string::{split_at, str_range, char_indices};
pub(crate) use thiserror::Error;
pub(crate) use self::DslError::*;
mod dsl_ast; pub use self::dsl_ast::*;
mod dsl_cst; pub use self::dsl_cst::*;
mod dsl_display; //pub use self::dsl_display::*;
mod dsl_error; pub use self::dsl_error::*;
mod dsl_iter; pub use self::dsl_iter::*;
mod dsl_token; pub use self::dsl_token::*;
mod dsl_value; pub use self::dsl_value::*;
#[cfg(test)] mod dsl_test;