mirror of
https://codeberg.org/unspeaker/tengri.git
synced 2025-12-06 03:36:42 +01:00
51 lines
1.9 KiB
Rust
51 lines
1.9 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 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_domain; pub use self::dsl_domain::*;
|
|
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;
|