Create an intermediate ast node type.
This commit is contained in:
@@ -1,6 +1,10 @@
|
||||
use crate::error::CustomError;
|
||||
|
||||
use super::ast_node::IAstNode;
|
||||
use super::registry::FootnoteDefinitionContents;
|
||||
use super::registry::Registry;
|
||||
use super::IElement;
|
||||
use super::IObject;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub(crate) struct IFootnoteDefinition {}
|
||||
@@ -14,3 +18,44 @@ impl IFootnoteDefinition {
|
||||
Ok(IFootnoteDefinition {})
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub(crate) struct IRealFootnoteDefinition {
|
||||
footnote_id: usize,
|
||||
contents: Vec<IAstNode>,
|
||||
}
|
||||
|
||||
impl IRealFootnoteDefinition {
|
||||
pub(crate) async fn new<'intermediate, 'parse>(
|
||||
registry: &mut Registry<'intermediate, 'parse>,
|
||||
footnote_id: usize,
|
||||
original: &FootnoteDefinitionContents<'intermediate, 'parse>,
|
||||
) -> Result<IRealFootnoteDefinition, CustomError> {
|
||||
let contents = match original {
|
||||
FootnoteDefinitionContents::FromReference(inner) => {
|
||||
let contents = {
|
||||
let mut ret = Vec::new();
|
||||
for obj in inner.iter() {
|
||||
ret.push(IAstNode::Object(IObject::new(registry, obj).await?));
|
||||
}
|
||||
ret
|
||||
};
|
||||
contents
|
||||
}
|
||||
FootnoteDefinitionContents::FromDefinition(inner) => {
|
||||
let contents = {
|
||||
let mut ret = Vec::new();
|
||||
for obj in inner.iter() {
|
||||
ret.push(IAstNode::Element(IElement::new(registry, obj).await?));
|
||||
}
|
||||
ret
|
||||
};
|
||||
contents
|
||||
}
|
||||
};
|
||||
Ok(IRealFootnoteDefinition {
|
||||
footnote_id,
|
||||
contents,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user