safe commit, because actually reading about good practices now, so rework incomming uwu

This commit is contained in:
LunarAkai 2025-08-06 11:47:59 +02:00
commit 2f99969f12
9 changed files with 57 additions and 20 deletions

View file

@ -1,8 +0,0 @@
use std::ops::Range;
use crate::ast::op::Op;
pub mod op;
pub mod ast;

View file

@ -0,0 +1,2 @@
pub mod ast;
pub mod op;

View file

@ -0,0 +1 @@
pub mod ast;

View file

@ -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!()
},

View file

@ -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");