pub struct Builder { /* fields omitted */ }
This is used to create a Parser
using
the builder method
use ressa::Builder;
use ressa::node::*;
fn main() {
let js = "for (var i = 0; i < 100; i++) {
console.log('loop', i);
}";
let p = Builder::new()
.module(false)
.js(js)
.build()
.unwrap();
for part in p {
let expectation = ProgramPart::Statement(
Statement::For(
ForStatement {
init: Some(
LoopInit::Variable(
vec![VariableDecl::with_value("i", Expression::number("0"))]
)
),
test: Some(
Expression::binary(Expression::ident("i"), BinaryOperator::LessThan, Expression::number("100"))
),
update: Some(
Expression::Update(
UpdateExpression {
operator: UpdateOperator::Increment,
argument: Box::new(Expression::ident("i")),
prefix: false,
}
)
),
body:
Box::new(Statement::Block(
vec![ProgramPart::Statement(
Statement::Expr(
Expression::call(Expression::member(Expression::ident("console"), Expression::ident("log"), false),
vec![
Expression::string("'loop'"),
Expression::ident("i"),
])
)
)]
)
)
}
)
);
assert_eq!(part.unwrap(), expectation);
}
}
Enable or disable error tolerance
default: false
Enable or disable error tolerance with a builder
pattern
default: false
Set the parsing context to module or script
default: false
(script)
Set the parsing context to module or script
with a builder pattern
default: false
(script)
Set the js text that this parser would operate
on
Set the js text that this parser would operate
on with a builder pattern
Complete the builder pattern returning
Result<Parser, Error>
An alternate to the build
method. This will allow
users to define their own comment handler
🔬 This is a nightly-only experimental API. (try_from
)
The type returned in the event of a conversion error.
🔬 This is a nightly-only experimental API. (try_from
)
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
🔬 This is a nightly-only experimental API. (try_from
)
The type returned in the event of a conversion error.
🔬 This is a nightly-only experimental API. (try_from
)
🔬 This is a nightly-only experimental API. (get_type_id
)
this method will likely be replaced by an associated static