Compare commits
2 commits
79975ffcba
...
ed6c8c6f22
| Author | SHA1 | Date | |
|---|---|---|---|
| ed6c8c6f22 | |||
| 7c0dc98ef7 |
18 changed files with 121 additions and 67 deletions
4
.gitignore
vendored
4
.gitignore
vendored
|
|
@ -1,3 +1,5 @@
|
|||
/target
|
||||
*.sh
|
||||
sample.akai
|
||||
sample.akai
|
||||
.idea
|
||||
/.idea
|
||||
79
Cargo.lock
generated
79
Cargo.lock
generated
|
|
@ -11,6 +11,31 @@ dependencies = [
|
|||
"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]]
|
||||
name = "allocator-api2"
|
||||
version = "0.2.21"
|
||||
|
|
@ -58,12 +83,6 @@ dependencies = [
|
|||
"unicode-segmentation",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "either"
|
||||
version = "1.15.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719"
|
||||
|
||||
[[package]]
|
||||
name = "equivalent"
|
||||
version = "1.0.2"
|
||||
|
|
@ -95,11 +114,10 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "inkwell"
|
||||
version = "0.6.0"
|
||||
version = "0.7.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e67349bd7578d4afebbe15eaa642a80b884e8623db74b1716611b131feb1deef"
|
||||
checksum = "39457e8611219cf690f862a470575f5c06862910d03ea3c3b187ad7abc44b4e2"
|
||||
dependencies = [
|
||||
"either",
|
||||
"inkwell_internals",
|
||||
"libc",
|
||||
"llvm-sys",
|
||||
|
|
@ -109,24 +127,15 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "inkwell_internals"
|
||||
version = "0.11.0"
|
||||
version = "0.12.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f365c8de536236cfdebd0ba2130de22acefed18b1fb99c32783b3840aec5fb46"
|
||||
checksum = "ad9a7dd586b00f2b20e0b9ae3c6faa351fbfd56d15d63bbce35b13bece682eda"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "lang"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"chumsky",
|
||||
"inkwell",
|
||||
"logos",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "lazy_static"
|
||||
version = "1.5.0"
|
||||
|
|
@ -141,9 +150,9 @@ checksum = "1171693293099992e19cddea4e8b849964e9846f4acee11b3948bcc337be8776"
|
|||
|
||||
[[package]]
|
||||
name = "llvm-sys"
|
||||
version = "181.2.0"
|
||||
version = "211.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d320f9d2723c97d4b78f9190a61ed25cc7cfbe456668c08e6e7dd8e50ceb8500"
|
||||
checksum = "108b3ad2b2eaf2a561fc74196273b20e3436e4a688b8b44e250d83974dc1b2e2"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"cc",
|
||||
|
|
@ -155,34 +164,34 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "logos"
|
||||
version = "0.15.0"
|
||||
version = "0.15.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ab6f536c1af4c7cc81edf73da1f8029896e7e1e16a219ef09b184e76a296f3db"
|
||||
checksum = "ff472f899b4ec2d99161c51f60ff7075eeb3097069a36050d8037a6325eb8154"
|
||||
dependencies = [
|
||||
"logos-derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "logos-codegen"
|
||||
version = "0.15.0"
|
||||
version = "0.15.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "189bbfd0b61330abea797e5e9276408f2edbe4f822d7ad08685d67419aafb34e"
|
||||
checksum = "192a3a2b90b0c05b27a0b2c43eecdb7c415e29243acc3f89cc8247a5b693045c"
|
||||
dependencies = [
|
||||
"beef",
|
||||
"fnv",
|
||||
"lazy_static",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"regex-syntax 0.8.5",
|
||||
"regex-syntax 0.8.8",
|
||||
"rustc_version",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "logos-derive"
|
||||
version = "0.15.0"
|
||||
version = "0.15.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ebfe8e1a19049ddbfccbd14ac834b215e11b85b90bab0c2dba7c7b92fb5d5cba"
|
||||
checksum = "605d9697bcd5ef3a42d38efc51541aa3d6a4a25f7ab6d1ed0da5ac632a26b470"
|
||||
dependencies = [
|
||||
"logos-codegen",
|
||||
]
|
||||
|
|
@ -251,9 +260,9 @@ checksum = "dbb5fb1acd8a1a18b3dd5be62d25485eb770e05afb408a9627d14d451bae12da"
|
|||
|
||||
[[package]]
|
||||
name = "regex-syntax"
|
||||
version = "0.8.5"
|
||||
version = "0.8.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c"
|
||||
checksum = "7a2d987857b319362043e95f5353c0535c1f58eec5336fdfcf626430af7def58"
|
||||
|
||||
[[package]]
|
||||
name = "rustc_version"
|
||||
|
|
@ -322,18 +331,18 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "thiserror"
|
||||
version = "1.0.69"
|
||||
version = "2.0.17"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52"
|
||||
checksum = "f63587ca0f12b72a0600bcba1d40081f830876000bb46dd2337a3051618f4fc8"
|
||||
dependencies = [
|
||||
"thiserror-impl",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "thiserror-impl"
|
||||
version = "1.0.69"
|
||||
version = "2.0.17"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1"
|
||||
checksum = "3ff15c8ecd7de3849db632e14d18d2571fa09dfc5ed93479bc4485c7a517c913"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
|
|
|
|||
12
Cargo.toml
12
Cargo.toml
|
|
@ -1,9 +1,7 @@
|
|||
[package]
|
||||
name = "lang"
|
||||
[workspace]
|
||||
members = ["crates/akailang-backend", "crates/akailang", "crates/akailang-parser"]
|
||||
resolver = "3"
|
||||
|
||||
[workspace.package]
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
logos = "0.15.0"
|
||||
chumsky = "0.10.1"
|
||||
inkwell = { version = "0.6.0", features = ["llvm18-1"] }
|
||||
|
|
|
|||
9
crates/akailang-backend/Cargo.toml
Normal file
9
crates/akailang-backend/Cargo.toml
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
[package]
|
||||
name = "akailang-backend"
|
||||
version.workspace = true
|
||||
edition.workspace = true
|
||||
|
||||
[dependencies]
|
||||
inkwell = { version = "0.7.0", features = ["llvm21-1"] }
|
||||
chumsky = "0.10.1"
|
||||
akailang-parser = { path = "../akailang-parser" }
|
||||
18
crates/akailang-backend/src/lib.rs
Normal file
18
crates/akailang-backend/src/lib.rs
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
pub mod llvm;
|
||||
|
||||
pub use akailang_parser::*;
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,17 +1,17 @@
|
|||
use chumsky::prelude::todo;
|
||||
use inkwell::{
|
||||
OptimizationLevel,
|
||||
GlobalVisibility, OptimizationLevel,
|
||||
builder::{self, Builder},
|
||||
context::Context,
|
||||
execution_engine::ExecutionEngine,
|
||||
module::Module,
|
||||
types::BasicTypeEnum,
|
||||
values::{BasicValueEnum, FunctionValue},
|
||||
values::{BasicValue, BasicValueEnum, FunctionValue},
|
||||
};
|
||||
|
||||
use crate::language_frontend::abstract_syntax_tree::{
|
||||
use akailang_parser::abstract_syntax_tree::{
|
||||
ast::Expr,
|
||||
definitions::{Function, Type},
|
||||
definitions::{Function, Identifier, Type},
|
||||
};
|
||||
|
||||
pub struct CodeGen<'ctx> {
|
||||
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
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
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
|
||||
|
||||
|
|
@ -15,15 +15,14 @@ use chumsky::{
|
|||
newline, whitespace,
|
||||
},
|
||||
};
|
||||
use inkwell::Either;
|
||||
use logos::{Logos, source};
|
||||
|
||||
use crate::{
|
||||
language_frontend::{
|
||||
token,
|
||||
{
|
||||
abstract_syntax_tree::{ast::Expr, definitions::*},
|
||||
lexer::tokens::Token,
|
||||
},
|
||||
token,
|
||||
};
|
||||
|
||||
// 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 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;
|
||||
use akailang_parser::abstract_syntax_tree::parser::parse;
|
||||
|
||||
/*
|
||||
Simple Compiler -> 4 Stages:
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
pub mod abstract_syntax_tree;
|
||||
pub mod lexer;
|
||||
|
|
@ -1 +0,0 @@
|
|||
pub mod llvm;
|
||||
Loading…
Add table
Add a link
Reference in a new issue