Browse Source

OMG it works

pull/5/head
Jason Williams 6 years ago
parent
commit
6b9fac0882
  1. 8
      src/bin/bin.rs
  2. 6
      tests/js/defineVar.js

8
src/bin/bin.rs

@ -1,4 +1,5 @@
extern crate boa; extern crate boa;
use boa::exec::{Executor, Interpreter};
use boa::syntax::lexer::Lexer; use boa::syntax::lexer::Lexer;
use boa::syntax::parser::Parser; use boa::syntax::parser::Parser;
use std::fs::read_to_string; use std::fs::read_to_string;
@ -12,4 +13,11 @@ pub fn main() {
// Setup executor // Setup executor
let expr = Parser::new(tokens).parse_all().unwrap(); let expr = Parser::new(tokens).parse_all().unwrap();
println!("{}", expr); println!("{}", expr);
let mut engine: Interpreter = Executor::new();
let result = engine.run(&expr);
match result {
Ok(v) => print!("{}", v),
Err(v) => print!("Error: {}", v),
}
} }

6
tests/js/defineVar.js

@ -1,6 +1,2 @@
var b = 'Jason'; var b = 'Jason';
if(1===1){ typeof b;
b = 'another name';
}
console.log(b);

Loading…
Cancel
Save