From 1744d9dff4f372ed15dada6766a17b05c26e5f33 Mon Sep 17 00:00:00 2001 From: nic-gaffney Date: Thu, 27 Jul 2023 23:10:18 -0500 Subject: [PATCH] formatting --- examples/chatbot.sloth | 12 +++++++++++ mandelbrot.c | 32 ----------------------------- mandelbrot.java | 40 ------------------------------------- mandelbrot.py | 23 --------------------- sloth/src/analysis/setup.rs | 2 +- sloth/src/codegen/mod.rs | 6 +++--- sloth/src/parser/ast.rs | 2 +- sloth/src/parser/graph.rs | 6 +++--- 8 files changed, 20 insertions(+), 103 deletions(-) create mode 100644 examples/chatbot.sloth delete mode 100644 mandelbrot.c delete mode 100644 mandelbrot.java delete mode 100644 mandelbrot.py diff --git a/examples/chatbot.sloth b/examples/chatbot.sloth new file mode 100644 index 0000000..01f7701 --- /dev/null +++ b/examples/chatbot.sloth @@ -0,0 +1,12 @@ +fn main() Int { + var run: Bool = true; + while run == true { + println("Hello! How are you?"); + print("User> "); + var input: String = readln(); + if sequals(input, "bad") { + println("lmao sucks"); + } + } + return 0; +} diff --git a/mandelbrot.c b/mandelbrot.c deleted file mode 100644 index a6eff9e..0000000 --- a/mandelbrot.c +++ /dev/null @@ -1,32 +0,0 @@ -#include - -int main() { - float size = 800.0; - float maxVal = 4.0; - float maxIter = 50.0; - float plane = 4.0; - int x = 0; - while (x < size) { - int y = 0; - while (y < size) { - float cReal = (x * plane / size) - 2.0; - float cImg = (y * plane / size) - 2.0; - float zReal = 0.0; - float zImg = 0.0; - float count = 0.0; - while ((zReal * zReal + zImg * zImg) <= maxVal && count < maxIter) { - float temp = (zReal * zReal) - (zImg * zImg) + cReal; - zImg = 2.0 * zReal * zImg + cImg; - zReal = temp; - count = count + 1; - if (count == maxIter) { - printf("\x1b[%d;%dH", x, y); - printf("█"); - } - } - y = y + 1; - } - x = x + 1; - } - return 0; -} diff --git a/mandelbrot.java b/mandelbrot.java deleted file mode 100644 index 1409ce6..0000000 --- a/mandelbrot.java +++ /dev/null @@ -1,40 +0,0 @@ -public class mandelbrot { - public static void main(String[] args) { - // char escCode = 0x1B; - // System.out.printf("%c[%d;%dH", escCode, 20, 10); - // System.out.print("█"); - // System.out.printf("%c[%d;%dH", escCode, 20, 20); - // System.out.print("█"); - // System.out.printf("%c[%d;%dH", escCode, 30, 10); - // System.out.print("█"); - - double size = 800; - double maxVal = 4; - double maxIter = 50; - double plane = 4; - int x = 0; - while (x < size) { - int y = 0; - while (y < size) { - double cReal = (x * plane / size) - 2.0; - double cImg = (y * plane / size) - 2.0; - double zReal = 0.0; - double zImg = 0.0; - double count = 0.0; - while ((zReal * zReal + zImg * zImg) <= maxVal && count < maxIter) { - var temp = (zReal * zReal) - (zImg * zImg) + cReal; - zImg = 2.0 * zReal * zImg + cImg; - zReal = temp; - count = count + 1.0; - if (count == maxIter) { - char escCode = 0x1B; - System.out.printf("%c[%d;%dH", escCode, x, y); - System.out.print("█"); - } - } - y = y + 1; - } - x = x + 1; - } - } -} diff --git a/mandelbrot.py b/mandelbrot.py deleted file mode 100644 index 234beb4..0000000 --- a/mandelbrot.py +++ /dev/null @@ -1,23 +0,0 @@ -size = 800.0 -maxVal = 4.0 -maxIter = 50.0 -plane = 4.0 -x = 0; -while x < size: - y = 0; - while y < size: - cReal = (x * plane / size) - 2.0 - cImg = (y * plane / size) - 2.0 - zReal = 0.0 - zImg = 0.0 - count = 0.0 - while (zReal * zReal + zImg * zImg) <= maxVal and count < maxIter: - temp = (zReal * zReal) - (zImg * zImg) + cReal - zImg = 2.0 * zReal * zImg + cImg - zReal = temp - count = count + 1.0 - if count == maxIter: - print(f"\x1b[{x};{y}H", end="") - print("█", end="") - y = y + 1 - x = x + 1 diff --git a/sloth/src/analysis/setup.rs b/sloth/src/analysis/setup.rs index 9ce518e..3110f77 100644 --- a/sloth/src/analysis/setup.rs +++ b/sloth/src/analysis/setup.rs @@ -164,7 +164,7 @@ pub(super) fn propagate_types_stmt(node: &mut Stmt) -> Result<(), AnalysisError> propagate_types(iterator)?; propagate_types_stmt(body)?; } - StmtKind::DefineVariable { value, typ, .. } => { + StmtKind::DefineVariable { value, .. } => { propagate_types(value)?; } StmtKind::AssignVariable { value, .. } => { diff --git a/sloth/src/codegen/mod.rs b/sloth/src/codegen/mod.rs index 3e34227..4a42e88 100644 --- a/sloth/src/codegen/mod.rs +++ b/sloth/src/codegen/mod.rs @@ -428,7 +428,7 @@ impl<'ctx> Codegen<'ctx> { // match value.typ { Some(Type::Boolean) => { - let value = self.codegen_expr(value).unwrap().into_int_value(); + let _value = self.codegen_expr(value).unwrap().into_int_value(); match op { UnaryOp::Not => { @@ -923,10 +923,10 @@ impl<'ctx> Codegen<'ctx> { let inputs = &[array_input.into(), self.context.i32_type().into()]; let func_type = self.context.void_type().fn_type(inputs, false); self._setup(&format!("vremove{name}"), func_type); - let func = self.current_func.unwrap(); + let _func = self.current_func.unwrap(); // Types - let element_type = self.type_as_basic_type(typ); + let _element_type = self.type_as_basic_type(typ); // FIXME: Array cant shrink as of now // TODO: vremove diff --git a/sloth/src/parser/ast.rs b/sloth/src/parser/ast.rs index fbd0970..74500ef 100644 --- a/sloth/src/parser/ast.rs +++ b/sloth/src/parser/ast.rs @@ -188,7 +188,7 @@ impl Stmt { } StmtKind::ForStmt { iterator, - identifier, + identifier: _, body, } => { children.push(iterator.as_node()); diff --git a/sloth/src/parser/graph.rs b/sloth/src/parser/graph.rs index 29dd66c..7b56b56 100644 --- a/sloth/src/parser/graph.rs +++ b/sloth/src/parser/graph.rs @@ -1,4 +1,4 @@ -us estd::fmt::{Error, Write}; +use std::fmt::{Error, Write}; use super::ast::{Expr, ExprKind, Function, FunctionKind, Stmt, StmtKind}; @@ -74,7 +74,7 @@ impl GraphBuilder { } StmtKind::ForStmt { iterator, - identifier, + identifier: _, body, } => { writeln!( @@ -257,7 +257,7 @@ impl GraphBuilder { } StmtKind::ForStmt { iterator, - identifier, + identifier: _, body, } => { writeln!(