pub mod compiler; // LLVM Codegen //-------------------------- // Parser //------------------------- use std::collections::HashMap; use logos::Lexer; use crate::tokens::Token; /// Defines a primitive expression #[derive(Debug)] pub enum Expr { Binary { op: char, left: Box, right: Box, }, Call { fn_name: String, args: Vec, }, Conditional { cond: Box, consequence: Box, alternative: Box, }, For { var_name: String, start: Box, end: Box, step: Option>, body: Box, }, Number(f64), Variable(String), VarIn { variables: Vec<(String, Option)>, body: Box, } } /// Defines the prototype (name and parameters) of a function #[derive(Debug)] pub struct Prototype { pub name: String, pub args: Vec, pub is_op: bool, pub prec: usize, } /// Defines a user-defined or external function #[derive(Debug)] pub struct Function { pub prototype: Prototype, pub body: Option, pub is_anon: bool, } pub struct Parser<'a> { tokens: Vec>, pos: usize, prec: &'a mut HashMap, }