safe commit, because actually reading about good practices now, so rework incomming uwu
This commit is contained in:
parent
05ebc02909
commit
2f99969f12
9 changed files with 57 additions and 20 deletions
|
|
@ -1,8 +0,0 @@
|
|||
use std::ops::Range;
|
||||
|
||||
use crate::ast::op::Op;
|
||||
|
||||
pub mod op;
|
||||
pub mod ast;
|
||||
|
||||
|
||||
2
src/language_frontend/ast/mod.rs
Normal file
2
src/language_frontend/ast/mod.rs
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
pub mod ast;
|
||||
pub mod op;
|
||||
1
src/language_frontend/mod.rs
Normal file
1
src/language_frontend/mod.rs
Normal file
|
|
@ -0,0 +1 @@
|
|||
pub mod ast;
|
||||
|
|
@ -44,27 +44,54 @@ impl<'ctx, 'src> Expression<'src> {
|
|||
todo!()
|
||||
},
|
||||
|
||||
Expression::Add(expression, expression1) => {
|
||||
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::Substract(expression, expression1) => {
|
||||
Expression::Multiply(
|
||||
lhs,
|
||||
rhs
|
||||
) => {
|
||||
todo!()
|
||||
},
|
||||
|
||||
Expression::Multiply(expression, expression1) => {
|
||||
Expression::Divide(
|
||||
lhs,
|
||||
rhs
|
||||
) => {
|
||||
todo!()
|
||||
},
|
||||
|
||||
Expression::Divide(expression, expression1) => {
|
||||
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::Var { name, rhs, then } => {
|
||||
todo!()
|
||||
},
|
||||
|
||||
Expression::Function { name, args, body, then } => {
|
||||
Expression::Function {
|
||||
name,
|
||||
args,
|
||||
body,
|
||||
then
|
||||
} => {
|
||||
todo!()
|
||||
},
|
||||
|
||||
|
|
@ -4,9 +4,9 @@ use logos::Logos;
|
|||
use crate::{parser::parser, tokens::Token};
|
||||
|
||||
mod tokens;
|
||||
mod ast;
|
||||
mod language_frontend;
|
||||
mod parser;
|
||||
mod code_generation;
|
||||
mod llvm_backend;
|
||||
|
||||
fn main() {
|
||||
let lexer = Token::lexer("(1 + 1) * 3");
|
||||
|
|
|
|||
15
syntax.akai
15
syntax.akai
|
|
@ -25,14 +25,29 @@ fun helloWorld() {
|
|||
print("Hello World " + bar)
|
||||
}
|
||||
|
||||
fun returnsInteger(int: i): int {
|
||||
-> i + 1
|
||||
}
|
||||
|
||||
/*
|
||||
Keywords/ Tokens:
|
||||
- class
|
||||
- interface
|
||||
- fun
|
||||
- var
|
||||
|
||||
- derive // Inheritance for classes
|
||||
- impl // for interfaces
|
||||
|
||||
// Standard keywords for basic stuff
|
||||
- int
|
||||
- float
|
||||
- char
|
||||
- bool
|
||||
- if
|
||||
- else
|
||||
- enum
|
||||
|
||||
- (
|
||||
- )
|
||||
- {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue