valkyrie-ast 0.1.0

Strong typed abstract syntax tree of valkyrie language
Documentation
use super::*;

impl PrettyPrint for ApplyDotNode {
    fn build<'a>(&self, allocator: &'a PrettyProvider<'a>) -> PrettyTree<'a> {
        let newline = allocator.hardline();
        let mut terms = Vec::with_capacity(6);
        terms.push(allocator.text("."));
        terms.push(self.caller.build(allocator));
        terms.push(allocator.text("("));
        terms.push(allocator.join(&self.terms, ", "));
        terms.push(allocator.text(")"));
        newline.append(allocator.concat(terms).indent(4))
    }
}

impl PrettyPrint for ApplyCallNode {
    fn build<'a>(&self, allocator: &'a PrettyProvider<'a>) -> PrettyTree<'a> {
        let mut terms = Vec::with_capacity(3);
        terms.push(allocator.text("("));
        terms.push(allocator.join(&self.terms, ", "));
        terms.push(allocator.text(")"));
        allocator.concat(terms)
    }
}

impl PrettyPrint for ApplyCallTerm {
    fn build<'a>(&self, allocator: &'a PrettyProvider<'a>) -> PrettyTree<'a> {
        self.term.build(allocator)
    }
}

impl PrettyPrint for ApplyArgumentNode {
    fn build<'a>(&self, allocator: &'a PrettyProvider<'a>) -> PrettyTree<'a> {
        allocator.text("(").append(allocator.join(&self.terms, ", ")).append(allocator.text(")"))
    }
}

impl PrettyPrint for ApplyArgumentTerm {
    fn build<'a>(&self, allocator: &'a PrettyProvider<'a>) -> PrettyTree<'a> {
        self.term.build(allocator)
    }
}

impl PrettyPrint for ArgumentKeyNode {
    fn build<'a>(&self, allocator: &'a PrettyProvider<'a>) -> PrettyTree<'a> {
        let mods = self.modifiers.build(allocator);
        let key = allocator.argument(self.key.name.clone(), false);
        mods.append(key)
    }
}