use super::*;
#[cfg(feature = "pretty-print")]
mod display;
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub enum AnnotationKind {
Normal,
Environment,
NonCapture,
}
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct AnnotationNode {
pub kind: AnnotationKind,
pub term: AnnotationTerm,
pub span: Range<u32>,
}
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct AnnotationList {
pub kind: AnnotationKind,
pub terms: Vec<AnnotationTerm>,
pub span: Range<u32>,
}
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct AnnotationTerm {
pub path: AnnotationPathNode,
pub arguments: ApplyCallNode,
pub collects: CollectsNode,
}
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct AnnotationStatements {
pub kind: AnnotationKind,
pub terms: Vec<AnnotationPathNode>,
}
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct AnnotationPathNode {
pub path: NamePathNode,
pub names: Vec<IdentifierNode>,
pub span: Range<u32>,
}
#[derive(Clone, Debug, Default, PartialEq, Eq, Hash)]
pub struct ModifiersNode {
pub terms: Vec<IdentifierNode>,
}
impl From<AnnotationNode> for AnnotationList {
fn from(value: AnnotationNode) -> Self {
Self { kind: value.kind, terms: vec![value.term], span: value.span }
}
}
impl AnnotationKind {
pub fn as_str(&self) -> &'static str {
match self {
Self::Normal => "@",
Self::Environment => "@@",
Self::NonCapture => "@!",
}
}
}
impl AnnotationPathNode {
pub fn new(path: NamePathNode, names: Vec<IdentifierNode>, span: Range<u32>) -> Self {
Self { path, names, span }
}
}
impl AnnotationTerm {
pub fn expand(self) -> AnnotationStatements {
todo!()
}
}
impl AnnotationList {
pub fn expand(self) -> AnnotationStatements {
todo!()
}
}
impl ModifiersNode {
pub fn new(modifiers: Vec<IdentifierNode>) -> Self {
Self { terms: modifiers }
}
pub fn contains(&self, modifier: &str) -> bool {
self.terms.iter().any(|x| x.name.eq(modifier))
}
}