Just barely starting to diff the two parsed forms.
This commit is contained in:
@@ -30,6 +30,22 @@ pub struct TextWithProperties<'s> {
|
||||
properties: Vec<Token<'s>>,
|
||||
}
|
||||
|
||||
impl<'s> Token<'s> {
|
||||
pub fn as_list<'p>(&'p self) -> Result<&'p Vec<Token<'s>>, Box<dyn std::error::Error>> {
|
||||
Ok(match self {
|
||||
Token::List(children) => Ok(children),
|
||||
_ => Err("wrong token type"),
|
||||
}?)
|
||||
}
|
||||
|
||||
pub fn as_atom<'p>(&'p self) -> Result<&'s str, Box<dyn std::error::Error>> {
|
||||
Ok(match self {
|
||||
Token::Atom(body) => Ok(*body),
|
||||
_ => Err("wrong token type"),
|
||||
}?)
|
||||
}
|
||||
}
|
||||
|
||||
#[tracing::instrument(ret, level = "debug")]
|
||||
pub fn sexp<'s>(input: &'s str) -> Res<&'s str, Token<'s>> {
|
||||
let (remaining, _) = multispace0(input)?;
|
||||
|
||||
Reference in New Issue
Block a user