the error reporting is so stupid lmfao

This commit is contained in:
MCorange 2023-03-13 02:07:43 +02:00
parent 0921100d4f
commit e053d7bef3
3 changed files with 10 additions and 9 deletions

View File

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

View File

@ -13,7 +13,7 @@ impl Parser {
}
}
pub fn parse(&mut self) -> Result<Vec<Operator>, &'static str> {
pub fn parse(&mut self) -> Result<Vec<Operator>, ()> {
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(());
}
}
}

View File

@ -1,3 +1,3 @@
35 34 + print
35 34 + printas
500 80 - print