use super::{
	cst::{self, NodeKind},
	tok::{self, TokenKind},
};

pub struct Atom<'a>(&'a cst::Node);
impl cst::Node {
	pub fn as_atom(&self) -> Option<Atom> {
		if *self.kind() != NodeKind::Atom {
			return None;
		}

		Some(Atom(self))
	}
}
impl Atom<'_> {
	pub fn value(&self) -> &tok::Atom {
		match &self.0.token().unwrap().kind {
			TokenKind::Atom(a) => a,
			_ => unreachable!(),
		}
	}
}
