mirror of https://github.com/boa-dev/boa.git
Iban Eguia
5 years ago
committed by
GitHub
51 changed files with 541 additions and 452 deletions
@ -1,61 +1,28 @@
|
||||
[package] |
||||
name = "Boa" |
||||
version = "0.5.1" |
||||
authors = ["Jason Williams <jase.williams@gmail.com>"] |
||||
description = "Boa is a Javascript lexer, parser and Just-in-Time compiler written in Rust. Currently, it has support for some of the language." |
||||
homepage = "https://github.com/jasonwilliams/boa" |
||||
repository = "https://github.com/jasonwilliams/boa" |
||||
keywords = ["javascript", "compiler", "lexer", "parser", "js"] |
||||
license = "Unlicense/MIT" |
||||
exclude = [".vscode/*", "Dockerfile", "Makefile", ".editorConfig"] |
||||
edition = "2018" |
||||
default-run = "boa" |
||||
|
||||
[features] |
||||
default = ["wasm-bindgen"] |
||||
|
||||
[dependencies] |
||||
gc = "^0.3.3" |
||||
gc_derive = "^0.3.2" |
||||
serde_json = "^1.0.40" |
||||
rand = "^0.7.0" |
||||
regex = "^1.3.0" |
||||
structopt = "0.3.2" |
||||
|
||||
# Optional Dependencies |
||||
wasm-bindgen = { version = "^0.2.50", optional = true } |
||||
|
||||
[dev-dependencies] |
||||
criterion = "^0.3.0" |
||||
|
||||
[lib] |
||||
crate-type = ["cdylib", "lib"] |
||||
name = "boa" |
||||
path = "src/lib/lib.rs" |
||||
bench = false |
||||
|
||||
[[bench]] |
||||
name = "string" |
||||
harness = false |
||||
|
||||
[[bench]] |
||||
name = "fib" |
||||
harness = false |
||||
|
||||
[[bench]] |
||||
name = "exec" |
||||
harness = false |
||||
|
||||
[[bench]] |
||||
name = "parser" |
||||
harness = false |
||||
|
||||
[[bin]] |
||||
name = "boa" |
||||
path = "src/bin/bin.rs" |
||||
bench = false |
||||
|
||||
[[bin]] |
||||
name = "boashell" |
||||
path = "src/bin/shell.rs" |
||||
bench = false |
||||
[workspace] |
||||
members = [ |
||||
"boa", |
||||
"boa_cli", |
||||
] |
||||
|
||||
# The release profile, used for `cargo build`. |
||||
[profile.dev] |
||||
incremental = true |
||||
opt-level = 0 |
||||
debug = true |
||||
rpath = false |
||||
lto = false |
||||
debug-assertions = true |
||||
overflow-checks = true |
||||
panic = 'unwind' |
||||
|
||||
# The release profile, used for `cargo build --release`. |
||||
[profile.release] |
||||
incremental = false |
||||
opt-level = 3 |
||||
debug = false |
||||
rpath = false |
||||
codegen-units = 1 |
||||
lto = true |
||||
debug-assertions = false |
||||
overflow-checks = false |
||||
panic = 'unwind' |
@ -0,0 +1,48 @@
|
||||
[package] |
||||
name = "Boa" |
||||
version = "0.5.1" |
||||
authors = ["Jason Williams <jase.williams@gmail.com>"] |
||||
description = "Boa is a Javascript lexer, parser and Just-in-Time compiler written in Rust. Currently, it has support for some of the language." |
||||
repository = "https://github.com/jasonwilliams/boa" |
||||
keywords = ["javascript", "compiler", "lexer", "parser", "js"] |
||||
categories = ["parser-implementations", "wasm"] |
||||
license = "Unlicense/MIT" |
||||
exclude = ["../.vscode/*", "../Dockerfile", "../Makefile", "../.editorConfig"] |
||||
edition = "2018" |
||||
|
||||
[features] |
||||
default = ["wasm-bindgen"] |
||||
|
||||
[dependencies] |
||||
gc = "0.3.3" |
||||
gc_derive = "0.3.2" |
||||
serde_json = "1.0.46" |
||||
rand = "0.7.3" |
||||
regex = "1.3.4" |
||||
|
||||
# Optional Dependencies |
||||
wasm-bindgen = { version = "0.2.58", optional = true } |
||||
|
||||
[dev-dependencies] |
||||
criterion = "0.3.1" |
||||
|
||||
[lib] |
||||
crate-type = ["cdylib", "lib"] |
||||
name = "boa" |
||||
bench = false |
||||
|
||||
[[bench]] |
||||
name = "string" |
||||
harness = false |
||||
|
||||
[[bench]] |
||||
name = "fib" |
||||
harness = false |
||||
|
||||
[[bench]] |
||||
name = "exec" |
||||
harness = false |
||||
|
||||
[[bench]] |
||||
name = "parser" |
||||
harness = false |
@ -0,0 +1,15 @@
|
||||
[package] |
||||
name = "boa_cli" |
||||
version = "0.1.0" |
||||
authors = ["razican <iban.eguia@cern.ch>"] |
||||
description = "Boa is a Javascript lexer, parser and Just-in-Time compiler written in Rust. Currently, it has support for some of the language." |
||||
repository = "https://github.com/jasonwilliams/boa" |
||||
keywords = ["javascript", "compiler", "lexer", "parser", "js", "cli"] |
||||
categories = ["command-line-utilities"] |
||||
license = "Unlicense/MIT" |
||||
exclude = ["../.vscode/*", "../Dockerfile", "../Makefile", "../.editorConfig"] |
||||
edition = "2018" |
||||
|
||||
[dependencies] |
||||
Boa = { path = "../boa" } |
||||
structopt = "0.3.9" |
@ -0,0 +1,39 @@
|
||||
#![deny(unused_qualifications, clippy::correctness, clippy::style)] |
||||
#![warn(clippy::perf)] |
||||
#![allow(clippy::cognitive_complexity)] |
||||
|
||||
use boa::{exec, exec::Executor, forward_val, realm::Realm}; |
||||
use std::{fs::read_to_string, path::PathBuf}; |
||||
use structopt::StructOpt; |
||||
|
||||
/// CLI configuration for Boa.
|
||||
#[derive(Debug, StructOpt)] |
||||
#[structopt(author, about)] |
||||
struct Opt { |
||||
/// The javascript file to be evaluated.
|
||||
#[structopt(name = "FILE", parse(from_os_str), default_value = "tests/js/test.js")] |
||||
file: PathBuf, |
||||
/// Open a boa shell (WIP).
|
||||
#[structopt(short, long)] |
||||
shell: bool, |
||||
} |
||||
|
||||
pub fn main() -> Result<(), std::io::Error> { |
||||
let args = Opt::from_args(); |
||||
|
||||
let buffer = read_to_string(args.file)?; |
||||
|
||||
if args.shell { |
||||
let realm = Realm::create(); |
||||
let mut engine = Executor::new(realm); |
||||
|
||||
match forward_val(&mut engine, &buffer) { |
||||
Ok(v) => print!("{}", v.to_string()), |
||||
Err(v) => eprint!("{}", v.to_string()), |
||||
} |
||||
} else { |
||||
dbg!(exec(&buffer)); |
||||
} |
||||
|
||||
Ok(()) |
||||
} |
@ -1,40 +0,0 @@
|
||||
#![deny(unused_qualifications, clippy::correctness, clippy::style)] |
||||
#![warn(clippy::perf)] |
||||
#![allow(clippy::cognitive_complexity)] |
||||
|
||||
use boa::exec; |
||||
use std::{env, fs::read_to_string, process::exit}; |
||||
|
||||
fn print_usage() { |
||||
println!( |
||||
"Usage: |
||||
boa [file.js] |
||||
Interpret and execute file.js |
||||
(if no file given, defaults to tests/js/test.js" |
||||
); |
||||
} |
||||
|
||||
pub fn main() -> Result<(), std::io::Error> { |
||||
let args: Vec<String> = env::args().collect(); |
||||
let read_file; |
||||
|
||||
match args.len() { |
||||
// No arguments passed, default to "test.js"
|
||||
1 => { |
||||
read_file = "tests/js/test.js"; |
||||
} |
||||
// One argument passed, assumed this is the test file
|
||||
2 => { |
||||
read_file = &args[1]; |
||||
} |
||||
// Some other number of arguments passed: not supported
|
||||
_ => { |
||||
print_usage(); |
||||
exit(1); |
||||
} |
||||
} |
||||
|
||||
let buffer = read_to_string(read_file)?; |
||||
dbg!(exec(&buffer)); |
||||
Ok(()) |
||||
} |
@ -1,29 +0,0 @@
|
||||
#![deny(unused_qualifications, clippy::correctness, clippy::style)] |
||||
#![warn(clippy::perf)] |
||||
#![allow(clippy::cognitive_complexity)] |
||||
|
||||
use boa::realm::Realm; |
||||
use boa::{exec::Executor, forward_val}; |
||||
use std::{fs::read_to_string, path::PathBuf}; |
||||
use structopt::StructOpt; |
||||
|
||||
#[derive(StructOpt)] |
||||
struct Opt { |
||||
#[structopt(parse(from_os_str), help = "the javascript file to be evaluated")] |
||||
file: PathBuf, |
||||
} |
||||
|
||||
pub fn main() -> Result<(), std::io::Error> { |
||||
let args = Opt::from_args(); |
||||
|
||||
let buffer = read_to_string(args.file)?; |
||||
let realm = Realm::create(); |
||||
let mut engine = Executor::new(realm); |
||||
|
||||
match forward_val(&mut engine, &buffer) { |
||||
Ok(v) => print!("{}", v.to_string()), |
||||
Err(v) => eprint!("{}", v.to_string()), |
||||
} |
||||
|
||||
Ok(()) |
||||
} |
Loading…
Reference in new issue