moved to workspaces
This commit is contained in:
parent
79975ffcba
commit
7c0dc98ef7
16 changed files with 91 additions and 103 deletions
4
.gitignore
vendored
4
.gitignore
vendored
|
|
@ -1,3 +1,5 @@
|
||||||
/target
|
/target
|
||||||
*.sh
|
*.sh
|
||||||
sample.akai
|
sample.akai
|
||||||
|
.idea
|
||||||
|
/.idea
|
||||||
79
Cargo.lock
generated
79
Cargo.lock
generated
|
|
@ -11,6 +11,31 @@ dependencies = [
|
||||||
"memchr",
|
"memchr",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "akailang"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"akailang-backend",
|
||||||
|
"akailang-parser",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "akailang-backend"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"akailang-parser",
|
||||||
|
"chumsky",
|
||||||
|
"inkwell",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "akailang-parser"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"chumsky",
|
||||||
|
"logos",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "allocator-api2"
|
name = "allocator-api2"
|
||||||
version = "0.2.21"
|
version = "0.2.21"
|
||||||
|
|
@ -58,12 +83,6 @@ dependencies = [
|
||||||
"unicode-segmentation",
|
"unicode-segmentation",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "either"
|
|
||||||
version = "1.15.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "equivalent"
|
name = "equivalent"
|
||||||
version = "1.0.2"
|
version = "1.0.2"
|
||||||
|
|
@ -95,11 +114,10 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "inkwell"
|
name = "inkwell"
|
||||||
version = "0.6.0"
|
version = "0.7.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "e67349bd7578d4afebbe15eaa642a80b884e8623db74b1716611b131feb1deef"
|
checksum = "39457e8611219cf690f862a470575f5c06862910d03ea3c3b187ad7abc44b4e2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"either",
|
|
||||||
"inkwell_internals",
|
"inkwell_internals",
|
||||||
"libc",
|
"libc",
|
||||||
"llvm-sys",
|
"llvm-sys",
|
||||||
|
|
@ -109,24 +127,15 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "inkwell_internals"
|
name = "inkwell_internals"
|
||||||
version = "0.11.0"
|
version = "0.12.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f365c8de536236cfdebd0ba2130de22acefed18b1fb99c32783b3840aec5fb46"
|
checksum = "ad9a7dd586b00f2b20e0b9ae3c6faa351fbfd56d15d63bbce35b13bece682eda"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn",
|
"syn",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "lang"
|
|
||||||
version = "0.1.0"
|
|
||||||
dependencies = [
|
|
||||||
"chumsky",
|
|
||||||
"inkwell",
|
|
||||||
"logos",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "lazy_static"
|
name = "lazy_static"
|
||||||
version = "1.5.0"
|
version = "1.5.0"
|
||||||
|
|
@ -141,9 +150,9 @@ checksum = "1171693293099992e19cddea4e8b849964e9846f4acee11b3948bcc337be8776"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "llvm-sys"
|
name = "llvm-sys"
|
||||||
version = "181.2.0"
|
version = "211.0.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d320f9d2723c97d4b78f9190a61ed25cc7cfbe456668c08e6e7dd8e50ceb8500"
|
checksum = "108b3ad2b2eaf2a561fc74196273b20e3436e4a688b8b44e250d83974dc1b2e2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"cc",
|
"cc",
|
||||||
|
|
@ -155,34 +164,34 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "logos"
|
name = "logos"
|
||||||
version = "0.15.0"
|
version = "0.15.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ab6f536c1af4c7cc81edf73da1f8029896e7e1e16a219ef09b184e76a296f3db"
|
checksum = "ff472f899b4ec2d99161c51f60ff7075eeb3097069a36050d8037a6325eb8154"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"logos-derive",
|
"logos-derive",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "logos-codegen"
|
name = "logos-codegen"
|
||||||
version = "0.15.0"
|
version = "0.15.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "189bbfd0b61330abea797e5e9276408f2edbe4f822d7ad08685d67419aafb34e"
|
checksum = "192a3a2b90b0c05b27a0b2c43eecdb7c415e29243acc3f89cc8247a5b693045c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"beef",
|
"beef",
|
||||||
"fnv",
|
"fnv",
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"regex-syntax 0.8.5",
|
"regex-syntax 0.8.8",
|
||||||
"rustc_version",
|
"rustc_version",
|
||||||
"syn",
|
"syn",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "logos-derive"
|
name = "logos-derive"
|
||||||
version = "0.15.0"
|
version = "0.15.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ebfe8e1a19049ddbfccbd14ac834b215e11b85b90bab0c2dba7c7b92fb5d5cba"
|
checksum = "605d9697bcd5ef3a42d38efc51541aa3d6a4a25f7ab6d1ed0da5ac632a26b470"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"logos-codegen",
|
"logos-codegen",
|
||||||
]
|
]
|
||||||
|
|
@ -251,9 +260,9 @@ checksum = "dbb5fb1acd8a1a18b3dd5be62d25485eb770e05afb408a9627d14d451bae12da"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "regex-syntax"
|
name = "regex-syntax"
|
||||||
version = "0.8.5"
|
version = "0.8.8"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c"
|
checksum = "7a2d987857b319362043e95f5353c0535c1f58eec5336fdfcf626430af7def58"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustc_version"
|
name = "rustc_version"
|
||||||
|
|
@ -322,18 +331,18 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "thiserror"
|
name = "thiserror"
|
||||||
version = "1.0.69"
|
version = "2.0.17"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52"
|
checksum = "f63587ca0f12b72a0600bcba1d40081f830876000bb46dd2337a3051618f4fc8"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"thiserror-impl",
|
"thiserror-impl",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "thiserror-impl"
|
name = "thiserror-impl"
|
||||||
version = "1.0.69"
|
version = "2.0.17"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1"
|
checksum = "3ff15c8ecd7de3849db632e14d18d2571fa09dfc5ed93479bc4485c7a517c913"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
|
|
|
||||||
14
Cargo.toml
14
Cargo.toml
|
|
@ -1,9 +1,7 @@
|
||||||
[package]
|
[workspace]
|
||||||
name = "lang"
|
members = ["crates/akailang-backend", "crates/akailang", "crates/akailang-parser"]
|
||||||
version = "0.1.0"
|
resolver = "3"
|
||||||
edition = "2024"
|
|
||||||
|
|
||||||
[dependencies]
|
[workspace.package]
|
||||||
logos = "0.15.0"
|
version = "0.1.0"
|
||||||
chumsky = "0.10.1"
|
edition = "2024"
|
||||||
inkwell = { version = "0.6.0", features = ["llvm18-1"] }
|
|
||||||
8
crates/akailang-parser/Cargo.toml
Normal file
8
crates/akailang-parser/Cargo.toml
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
[package]
|
||||||
|
name = "akailang-parser"
|
||||||
|
version.workspace = true
|
||||||
|
edition.workspace = true
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
logos = "0.15.0"
|
||||||
|
chumsky = "0.10.1"
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
use crate::language_frontend::abstract_syntax_tree::definitions::*;
|
use crate::abstract_syntax_tree::definitions::*;
|
||||||
|
|
||||||
// Option and Result -> define in Std
|
// Option and Result -> define in Std
|
||||||
#[derive(Clone, Debug, PartialEq)]
|
#[derive(Clone, Debug, PartialEq)]
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
use std::{ops::Range, rc::Rc};
|
use std::{ops::Range, rc::Rc};
|
||||||
|
|
||||||
use crate::language_frontend::abstract_syntax_tree::ast::Expr;
|
use crate::abstract_syntax_tree::ast::Expr;
|
||||||
|
|
||||||
// Abstract Syntax Tree
|
// Abstract Syntax Tree
|
||||||
|
|
||||||
|
|
@ -15,15 +15,14 @@ use chumsky::{
|
||||||
newline, whitespace,
|
newline, whitespace,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
use inkwell::Either;
|
|
||||||
use logos::{Logos, source};
|
use logos::{Logos, source};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
language_frontend::{
|
token,
|
||||||
|
{
|
||||||
abstract_syntax_tree::{ast::Expr, definitions::*},
|
abstract_syntax_tree::{ast::Expr, definitions::*},
|
||||||
lexer::tokens::Token,
|
lexer::tokens::Token,
|
||||||
},
|
},
|
||||||
token,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// goal of parsing is to construct an abstract syntax tree
|
// goal of parsing is to construct an abstract syntax tree
|
||||||
17
crates/akailang-parser/src/lib.rs
Normal file
17
crates/akailang-parser/src/lib.rs
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
pub mod abstract_syntax_tree;
|
||||||
|
pub mod lexer;
|
||||||
|
|
||||||
|
pub fn add(left: u64, right: u64) -> u64 {
|
||||||
|
left + right
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn it_works() {
|
||||||
|
let result = add(2, 2);
|
||||||
|
assert_eq!(result, 4);
|
||||||
|
}
|
||||||
|
}
|
||||||
8
crates/akailang/Cargo.toml
Normal file
8
crates/akailang/Cargo.toml
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
[package]
|
||||||
|
name = "akailang"
|
||||||
|
version.workspace = true
|
||||||
|
edition.workspace = true
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
akailang-parser = {path = "../akailang-parser" }
|
||||||
|
akailang-backend = {path = "../akailang-backend"}
|
||||||
|
|
@ -1,15 +1,4 @@
|
||||||
use chumsky::Parser;
|
use akailang_parser::abstract_syntax_tree::parser::parse;
|
||||||
use chumsky::input::{Input, Stream};
|
|
||||||
use logos::Logos;
|
|
||||||
|
|
||||||
mod language_frontend;
|
|
||||||
mod llvm_backend;
|
|
||||||
|
|
||||||
use crate::{
|
|
||||||
language_frontend::abstract_syntax_tree::parser::parse, language_frontend::lexer::tokens::Token,
|
|
||||||
};
|
|
||||||
|
|
||||||
use crate::language_frontend::abstract_syntax_tree::ast::Expr;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Simple Compiler -> 4 Stages:
|
Simple Compiler -> 4 Stages:
|
||||||
|
|
@ -1,2 +0,0 @@
|
||||||
pub mod abstract_syntax_tree;
|
|
||||||
pub mod lexer;
|
|
||||||
|
|
@ -1,39 +0,0 @@
|
||||||
use chumsky::prelude::todo;
|
|
||||||
use inkwell::{
|
|
||||||
OptimizationLevel,
|
|
||||||
builder::{self, Builder},
|
|
||||||
context::Context,
|
|
||||||
execution_engine::ExecutionEngine,
|
|
||||||
module::Module,
|
|
||||||
types::BasicTypeEnum,
|
|
||||||
values::{BasicValueEnum, FunctionValue},
|
|
||||||
};
|
|
||||||
|
|
||||||
use crate::language_frontend::abstract_syntax_tree::{
|
|
||||||
ast::Expr,
|
|
||||||
definitions::{Function, Type},
|
|
||||||
};
|
|
||||||
|
|
||||||
pub struct CodeGen<'ctx> {
|
|
||||||
pub(crate) context: &'ctx Context,
|
|
||||||
pub(crate) module: Module<'ctx>,
|
|
||||||
pub(crate) builder: Builder<'ctx>,
|
|
||||||
pub(crate) exec_engine: ExecutionEngine<'ctx>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'ctx> CodeGen<'ctx> {
|
|
||||||
pub fn new(context: &'ctx Context, module_name: &str, opt_level: OptimizationLevel) -> Self {
|
|
||||||
let module = context.create_module(module_name);
|
|
||||||
let exec_engine = module.create_jit_execution_engine(opt_level).unwrap();
|
|
||||||
let builder = context.create_builder();
|
|
||||||
|
|
||||||
CodeGen {
|
|
||||||
context,
|
|
||||||
module,
|
|
||||||
builder,
|
|
||||||
exec_engine,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn compile_expr(&mut self, expr: &Expr) {}
|
|
||||||
}
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
pub mod llvm;
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue