Function sljs::ast::build::block

source · []
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 Statements.

use sljs::ast::{Program, build::*};

let b = Program::try_from(block(|ctx| Ok(vec![
    // Statements
]))).expect("Program");