use crate::bounded::{Bounded, NonEmptyError};
use crate::token::SpanHandle;
#[path = "type_guard.rs"]
mod guard;
#[path = "provenance.rs"]
mod provenance;
pub const GENERATED_TOKEN_LIMIT: usize = 4096;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum GeneratedSpacing {
Joint,
Alone,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum GeneratedDelimiter {
Parenthesis,
Brace,
Bracket,
Bare,
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct GeneratedLiteral {
value: GeneratedLiteralValue,
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
enum GeneratedLiteralValue {
Number(String),
Character(char),
Byte(u8),
NulTerminatedText(Vec<u8>),
}
#[derive(Clone, Copy)]
pub(crate) enum GeneratedLiteralForm<'literal> {
Number(&'literal str),
Character(char),
Byte(u8),
NulTerminatedText(&'literal [u8]),
}
#[must_use = "a generated-literal refusal names the exact literal contract that disagreed"]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum GeneratedLiteralRefusal {
NotANumber,
InteriorNul,
}
#[must_use = "a fragment-generation issue names the exact token conversion that refused"]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum FragmentGenerationIssue {
Literal(GeneratedLiteralRefusal),
Unbounded,
}
#[must_use = "a fragment-generation refusal carries its issue and exact captured span"]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct FragmentGenerationRefusal {
pub(super) issue: FragmentGenerationIssue,
pub(super) at: Option<SpanHandle>,
}
#[must_use = "a generated-row refusal names the exact row and non-empty token disagreement"]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct GeneratedRowRefusal {
position: usize,
cause: NonEmptyError,
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum GeneratedToken {
Word(String),
Punct {
mark: char,
spacing: GeneratedSpacing,
},
Text(String),
Group {
delimiter: GeneratedDelimiter,
tokens: Bounded<GeneratedToken, GENERATED_TOKEN_LIMIT>,
},
ByteText(Vec<u8>),
Number(u64),
RawIdentifier(String),
Literal(GeneratedLiteral),
}
#[derive(Clone)]
pub struct GeneratedTree {
tokens: Bounded<GeneratedToken, GENERATED_TOKEN_LIMIT>,
source_spans: Vec<Option<SpanHandle>>,
}