added github as repo
This commit is contained in:
parent
2f99969f12
commit
e769b891ab
9 changed files with 24 additions and 114 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -1 +1,2 @@
|
|||
/target
|
||||
*.sh
|
||||
17
README.md
Normal file
17
README.md
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
# Akai Lang
|
||||
|
||||
Akai Lang (yeah I'm not creative and the name is still unused on github, sooo) is a programming language I'm building as a side project to my Moonhare Game Engine.
|
||||
|
||||
**Work in Progress - doesn't work yet**
|
||||
|
||||
## Planned Features
|
||||
- Object-Oriented
|
||||
- dynamic typing
|
||||
- LLVM Backend
|
||||
|
||||
## Hello World
|
||||
```AkaiLang
|
||||
fun helloWorld() {
|
||||
print("Hello World!")
|
||||
}
|
||||
```
|
||||
|
|
@ -1 +1,3 @@
|
|||
pub mod ast;
|
||||
pub mod parser;
|
||||
pub mod tokens;
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
use chumsky::{combinator::Or, prelude::{choice, just, recursive}, recursive, select, text::{self, ascii::ident}, IterParser, Parser};
|
||||
|
||||
use crate::{ast::ast::Expression, tokens::Token};
|
||||
use crate::{language_frontend::ast::ast::Expression, language_frontend::tokens::Token};
|
||||
|
||||
|
||||
#[allow(clippy::let_and_return)]
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
use std::collections::HashMap;
|
||||
|
||||
use inkwell::{builder::Builder, context::Context, module::Module, values::{FunctionValue, PointerValue}};
|
||||
|
||||
|
|
@ -1,103 +0,0 @@
|
|||
use std::collections::HashMap;
|
||||
|
||||
use inkwell::values::{BasicValueEnum, FunctionValue, PointerValue};
|
||||
|
||||
use crate::ast::ast::Expression;
|
||||
|
||||
pub mod compiler;
|
||||
|
||||
// LLVM Codegen
|
||||
|
||||
struct CodegenContext<'ctx> {
|
||||
builder: inkwell::builder::Builder<'ctx>,
|
||||
module: inkwell::module::Module<'ctx>,
|
||||
context: &'ctx inkwell::context::Context,
|
||||
variables: HashMap<String, PointerValue<'ctx>>,
|
||||
functions: HashMap<String, FunctionValue<'ctx>>,
|
||||
}
|
||||
|
||||
|
||||
impl<'ctx, 'src> Expression<'src> {
|
||||
fn codegen(&self, ctx: &mut CodegenContext<'ctx>) -> BasicValueEnum<'ctx> {
|
||||
match self {
|
||||
Expression::VariableName(name) => {
|
||||
todo!()
|
||||
},
|
||||
|
||||
Expression::Integer(_) => {
|
||||
todo!()
|
||||
},
|
||||
|
||||
Expression::Float(_) => {
|
||||
todo!()
|
||||
},
|
||||
|
||||
Expression::String(_) => {
|
||||
todo!()
|
||||
},
|
||||
|
||||
Expression::Bool(_) => {
|
||||
todo!()
|
||||
},
|
||||
|
||||
Expression::Negatation(expression) => {
|
||||
todo!()
|
||||
},
|
||||
|
||||
Expression::Add(
|
||||
lhs,
|
||||
rhs
|
||||
) => {
|
||||
let l = lhs.codegen(ctx).into_int_value();
|
||||
let r = rhs.codegen(ctx).into_int_value();
|
||||
ctx.builder.build_int_add(l, r, "addtmp").unwrap().into()
|
||||
},
|
||||
|
||||
Expression::Substract(
|
||||
lhs,
|
||||
rhs
|
||||
) => {
|
||||
todo!()
|
||||
},
|
||||
|
||||
Expression::Multiply(
|
||||
lhs,
|
||||
rhs
|
||||
) => {
|
||||
todo!()
|
||||
},
|
||||
|
||||
Expression::Divide(
|
||||
lhs,
|
||||
rhs
|
||||
) => {
|
||||
todo!()
|
||||
},
|
||||
|
||||
Expression::Var {
|
||||
name,
|
||||
rhs,
|
||||
then
|
||||
} => {
|
||||
let value = rhs.codegen(ctx);
|
||||
let ptr = ctx.builder.build_alloca(ctx.context.f32_type(), name).unwrap();
|
||||
let _ = ctx.builder.build_store(ptr, value);
|
||||
ctx.variables.insert(name.to_string(), ptr);
|
||||
then.codegen(ctx)
|
||||
},
|
||||
|
||||
Expression::Function {
|
||||
name,
|
||||
args,
|
||||
body,
|
||||
then
|
||||
} => {
|
||||
todo!()
|
||||
},
|
||||
|
||||
Expression::Unit => {
|
||||
todo!()
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,12 +1,9 @@
|
|||
use chumsky::Parser;
|
||||
use logos::Logos;
|
||||
|
||||
use crate::{parser::parser, tokens::Token};
|
||||
use crate::{language_frontend::parser::parser, language_frontend::tokens::Token};
|
||||
|
||||
mod tokens;
|
||||
mod language_frontend;
|
||||
mod parser;
|
||||
mod llvm_backend;
|
||||
|
||||
fn main() {
|
||||
let lexer = Token::lexer("(1 + 1) * 3");
|
||||
|
|
|
|||
|
|
@ -18,14 +18,14 @@ class Cat derive Animal:
|
|||
fun helloWorld() {
|
||||
// Variables either dynamically or statically typed
|
||||
var String: test = "I'm a string"
|
||||
var foo = 12
|
||||
var foo = 12 // reads as int
|
||||
|
||||
var bar = foo + 10
|
||||
|
||||
print("Hello World " + bar)
|
||||
}
|
||||
|
||||
fun returnsInteger(int: i): int {
|
||||
fun returnsIntegerPlusOne(int: i): int {
|
||||
-> i + 1
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue