we (web engine): Experimental web browser project to understand the limits of Claude
at js-parser 36 lines 1.1 kB view raw
1//! JavaScript engine — lexer, parser, bytecode, register VM, GC, JIT (AArch64). 2 3pub mod ast; 4pub mod lexer; 5pub mod parser; 6 7use std::fmt; 8 9/// An error produced by the JavaScript engine. 10#[derive(Debug)] 11pub enum JsError { 12 /// The engine does not yet support this feature or syntax. 13 NotImplemented, 14 /// A parse/syntax error in the source. 15 SyntaxError(String), 16 /// A runtime error during execution. 17 RuntimeError(String), 18} 19 20impl fmt::Display for JsError { 21 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { 22 match self { 23 JsError::NotImplemented => write!(f, "not implemented"), 24 JsError::SyntaxError(msg) => write!(f, "SyntaxError: {}", msg), 25 JsError::RuntimeError(msg) => write!(f, "RuntimeError: {}", msg), 26 } 27 } 28} 29 30/// Evaluate a JavaScript source string and return the completion value. 31/// 32/// This is a stub that always returns `NotImplemented`. The real 33/// implementation will lex, parse, compile to bytecode, and execute. 34pub fn evaluate(_source: &str) -> Result<(), JsError> { 35 Err(JsError::NotImplemented) 36}