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