Browse Source

[parser] Minor refactor and rename (#841)

pull/849/head
croraf 4 years ago committed by GitHub
parent
commit
0c92d37921
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 16
      boa/src/context.rs

16
boa/src/context.rs

@ -617,12 +617,6 @@ impl Context {
Ok(()) Ok(())
} }
fn parser_expr(src: &str) -> StdResult<StatementList, String> {
Parser::new(src.as_bytes())
.parse_all()
.map_err(|e| e.to_string())
}
/// Evaluates the given code. /// Evaluates the given code.
/// ///
/// # Examples /// # Examples
@ -639,8 +633,12 @@ impl Context {
pub fn eval(&mut self, src: &str) -> Result<Value> { pub fn eval(&mut self, src: &str) -> Result<Value> {
let main_timer = BoaProfiler::global().start_event("Main", "Main"); let main_timer = BoaProfiler::global().start_event("Main", "Main");
let result = match Self::parser_expr(src) { let parsing_result = Parser::new(src.as_bytes())
Ok(expr) => expr.run(self), .parse_all()
.map_err(|e| e.to_string());
let execution_result = match parsing_result {
Ok(statement_list) => statement_list.run(self),
Err(e) => self.throw_syntax_error(e), Err(e) => self.throw_syntax_error(e),
}; };
@ -648,7 +646,7 @@ impl Context {
drop(main_timer); drop(main_timer);
BoaProfiler::global().drop(); BoaProfiler::global().drop();
result execution_result
} }
/// Returns a structure that contains the JavaScript well known symbols. /// Returns a structure that contains the JavaScript well known symbols.

Loading…
Cancel
Save