From e053d7bef39a742b39323c44e36b90ab2f388456 Mon Sep 17 00:00:00 2001 From: MCorange Date: Mon, 13 Mar 2023 02:07:43 +0200 Subject: [PATCH] the error reporting is so stupid lmfao --- src/main.rs | 13 +++++++------ src/parser.rs | 4 ++-- test.mcl | 2 +- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/main.rs b/src/main.rs index 22ada8f..ff9d55f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -30,7 +30,7 @@ pub struct Args { interpret: bool } -fn main() -> Result<(), &'static str> { +fn main() -> Result<(), ()> { let args = Args::parse(); println!("MClang2 0.0.1"); @@ -44,15 +44,16 @@ fn main() -> Result<(), &'static str> { // } let mut parser = parser::Parser::new(tokens); - let tokens = parser.parse()?; + let tokens = match parser.parse(){ + Ok(t) => t, + Err(_) => return Ok(()) + }; if args.compile && args.interpret { util::logger::error("Cannot compile and interpret at the same time"); } else if args.interpret { - interpret::linux_x86_64::run(tokens)?; + let _ = interpret::linux_x86_64::run(tokens); } else if args.compile { - if let Err(e) = compile::linux_x86_64::compile(tokens, args) { - println!("{}", e); - } + let _ = compile::linux_x86_64::compile(tokens, args); } else { util::logger::error("Did not choose to compile or to interpret, exiting"); } diff --git a/src/parser.rs b/src/parser.rs index ba3eb5a..1f9ff1f 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -13,7 +13,7 @@ impl Parser { } } - pub fn parse(&mut self) -> Result, &'static str> { + pub fn parse(&mut self) -> Result, ()> { let mut tokens = Vec::new(); for token in &self.tokens { @@ -32,7 +32,7 @@ impl Parser { t => { util::logger::pos_error(pos, format!("Unknown token '{}'", t).as_str()); - return Err(""); + return Err(()); } } } diff --git a/test.mcl b/test.mcl index 1a48821..a7c4dc8 100644 --- a/test.mcl +++ b/test.mcl @@ -1,3 +1,3 @@ -35 34 + print +35 34 + printas 500 80 - print \ No newline at end of file