Reorganize repository into a workspace
This commit is contained in:
parent
de7d775648
commit
f8f58d70e0
31
Cargo.toml
31
Cargo.toml
|
@ -1,26 +1,5 @@
|
|||
[package]
|
||||
name = "zaia"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
logos = "0.12.0"
|
||||
ariadne = "0.1.5"
|
||||
cstree = "0.11.0"
|
||||
hexponent = "0.3.1"
|
||||
|
||||
[dev-dependencies]
|
||||
insta = "1.14.0"
|
||||
paste = "1.0.7"
|
||||
criterion = "0.3.5"
|
||||
|
||||
[profile.bench]
|
||||
debug = true
|
||||
|
||||
[[bench]]
|
||||
name = "parse"
|
||||
harness = false
|
||||
|
||||
[[bench]]
|
||||
name = "load"
|
||||
harness = false
|
||||
[workspace]
|
||||
members = [
|
||||
"crates/zaia",
|
||||
"crates/zaia-cli",
|
||||
]
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
# Zaia
|
||||
|
||||
Zaia is a dialect of the Lua language that is designed to be easy and flexible,
|
||||
promoting integration and extensibility within modern software.
|
||||
|
||||
## License
|
||||
|
||||
Zaia is licensed under the Apache v2.0 license.
|
||||
See the `LICENSE` file for more information.
|
8
crates/zaia-cli/Cargo.toml
Normal file
8
crates/zaia-cli/Cargo.toml
Normal file
|
@ -0,0 +1,8 @@
|
|||
[package]
|
||||
name = "zaia-cli"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
zaia = { path = "../zaia" }
|
||||
clap = { version = "3.2.5", features = ["derive"] }
|
18
crates/zaia-cli/src/main.rs
Normal file
18
crates/zaia-cli/src/main.rs
Normal file
|
@ -0,0 +1,18 @@
|
|||
use std::path::PathBuf;
|
||||
use clap::Parser;
|
||||
use zaia::Lua;
|
||||
use std::fs;
|
||||
|
||||
#[derive(Parser, Debug)]
|
||||
#[clap(author, version, about, long_about = None)]
|
||||
struct Args {
|
||||
file: PathBuf,
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let args = Args::parse();
|
||||
let source = fs::read_to_string(&args.file).unwrap();
|
||||
let mut lua = Lua::new();
|
||||
let script = lua.load(&source);
|
||||
lua.execute(&script).unwrap();
|
||||
}
|
23
crates/zaia/Cargo.toml
Normal file
23
crates/zaia/Cargo.toml
Normal file
|
@ -0,0 +1,23 @@
|
|||
[package]
|
||||
name = "zaia"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
logos = "0.12.0"
|
||||
ariadne = "0.1.5"
|
||||
cstree = "0.11.0"
|
||||
hexponent = "0.3.1"
|
||||
|
||||
[dev-dependencies]
|
||||
insta = "1.14.0"
|
||||
paste = "1.0.7"
|
||||
criterion = "0.3.5"
|
||||
|
||||
[[bench]]
|
||||
name = "parse"
|
||||
harness = false
|
||||
|
||||
[[bench]]
|
||||
name = "load"
|
||||
harness = false
|
|
@ -1,10 +1,10 @@
|
|||
use std::fs;
|
||||
|
||||
use criterion::{black_box, criterion_group, criterion_main, Criterion, Throughput};
|
||||
use zaia::engine::Lua;
|
||||
use zaia::Lua;
|
||||
|
||||
fn criterion_benchmark(c: &mut Criterion) {
|
||||
let source = fs::read_to_string("test-files/if.lua").unwrap();
|
||||
let source = fs::read_to_string("../../test-files/if.lua").unwrap();
|
||||
{
|
||||
let mut group = c.benchmark_group("load");
|
||||
let mut deferred = Vec::new();
|
|
@ -6,7 +6,7 @@ use logos::Logos;
|
|||
use zaia::parser::{kind::SyntaxKind, parse};
|
||||
|
||||
fn criterion_benchmark(c: &mut Criterion) {
|
||||
let source = fs::read_to_string("test-files/mixed.lua").unwrap();
|
||||
let source = fs::read_to_string("../../test-files/mixed.lua").unwrap();
|
||||
{
|
||||
let mut group = c.benchmark_group("lex");
|
||||
let mut deferred = Vec::new();
|
|
@ -1010,8 +1010,8 @@ mod tests {
|
|||
};
|
||||
}
|
||||
|
||||
test!(function, "test-files/function.lua");
|
||||
test!(if, "test-files/if.lua");
|
||||
test!(op_prec, "test-files/op_prec.lua");
|
||||
test!(nbody, "test-files/nbody.lua");
|
||||
test!(function, "../../test-files/function.lua");
|
||||
test!(if, "../../test-files/if.lua");
|
||||
test!(op_prec, "../../test-files/op_prec.lua");
|
||||
test!(nbody, "../../test-files/nbody.lua");
|
||||
}
|
|
@ -6,7 +6,7 @@ mod gc;
|
|||
pub mod value;
|
||||
mod vm;
|
||||
use std::cell::RefCell;
|
||||
mod api;
|
||||
pub mod api;
|
||||
|
||||
use std::{
|
||||
collections::HashMap,
|
||||
|
@ -15,7 +15,7 @@ use std::{
|
|||
|
||||
pub use error::Error;
|
||||
use gc::{Heap, ObjectPtr};
|
||||
pub use value::{ByteString, Function, Table2, Userdata, Value, ValueType};
|
||||
use value::{Table2, Value};
|
||||
use vm::{Chunk, VM};
|
||||
|
||||
use super::parser::{parse, syntax};
|
||||
|
@ -48,7 +48,7 @@ impl Lua {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn load(&mut self, code: &str) -> Rc<ScriptData> {
|
||||
pub fn load(&mut self, code: &str) -> Script {
|
||||
let (syntax_tree, reports) = parse(&mut self.cache, code);
|
||||
assert!(reports.is_empty());
|
||||
let root = syntax::Root::new(syntax_tree).unwrap();
|
||||
|
@ -77,7 +77,7 @@ impl Lua {
|
|||
self.script_id += 1;
|
||||
let data = Rc::new(data);
|
||||
self.scripts.insert(data.id, Rc::downgrade(&data));
|
||||
data
|
||||
Script { data, referenced: Rc::clone(&self.referenced) }
|
||||
}
|
||||
|
||||
pub fn execute(&mut self, script: &Script) -> Result<api::Value, Error> {
|
|
@ -1,5 +1,7 @@
|
|||
#![feature(hash_raw_entry)]
|
||||
#![allow(dead_code)]
|
||||
|
||||
pub mod engine;
|
||||
mod engine;
|
||||
pub mod parser;
|
||||
|
||||
pub use engine::{Lua, Script, api::{Value, Table}};
|
|
@ -83,12 +83,12 @@ mod tests {
|
|||
};
|
||||
}
|
||||
|
||||
test!(function, "test-files/function.lua");
|
||||
test!(op_prec, "test-files/op_prec.lua");
|
||||
test!(if, "test-files/if.lua");
|
||||
test!(declare, "test-files/declare.lua");
|
||||
test!(literal, "test-files/literal.lua");
|
||||
test!(comment, "test-files/comment.lua");
|
||||
test!(mixed, "test-files/mixed.lua");
|
||||
test!(nbody, "test-files/nbody.lua");
|
||||
test!(function, "../../test-files/function.lua");
|
||||
test!(op_prec, "../../test-files/op_prec.lua");
|
||||
test!(if, "../../test-files/if.lua");
|
||||
test!(declare, "../../test-files/declare.lua");
|
||||
test!(literal, "../../test-files/literal.lua");
|
||||
test!(comment, "../../test-files/comment.lua");
|
||||
test!(mixed, "../../test-files/mixed.lua");
|
||||
test!(nbody, "../../test-files/nbody.lua");
|
||||
}
|
Loading…
Reference in a new issue