pub fn block<F>(closure: F) -> BlockBuilder<F> where
F: FnOnce(&mut LexicalContext) -> ParseResult<Vec<Statement>>,
Expand description
Creates a BlockStatement
from a closure that builds a vector of Statement
s.
use sljs::ast::{Program, build::*};
let b = Program::try_from(block(|ctx| Ok(vec![
// Statements
]))).expect("Program");