mirror of
https://github.com/artegoser/ONLang
synced 2024-12-23 01:23:46 +03:00
fix: replace info.message() to info.payload()
This commit is contained in:
parent
b5970aaac6
commit
5a79cede01
2 changed files with 16 additions and 7 deletions
|
@ -219,8 +219,10 @@ impl Interpreter {
|
||||||
fn input(&self, value: &String) -> Value {
|
fn input(&self, value: &String) -> Value {
|
||||||
let mut input = String::new();
|
let mut input = String::new();
|
||||||
print!("{}", value);
|
print!("{}", value);
|
||||||
io::stdout().flush().unwrap_or_default();
|
io::stdout().flush().expect("Couldn't flush Stdout");
|
||||||
io::stdin().read_line(&mut input).unwrap_or_default();
|
io::stdin()
|
||||||
|
.read_line(&mut input)
|
||||||
|
.expect("Couldn't read from Stdin");
|
||||||
Value::String(input.trim_end().to_string())
|
Value::String(input.trim_end().to_string())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -625,24 +627,22 @@ impl Interpreter {
|
||||||
std::process::exit(1);
|
std::process::exit(1);
|
||||||
}
|
}
|
||||||
fn unk_token(&self, name: &str) {
|
fn unk_token(&self, name: &str) {
|
||||||
println!(
|
panic!(
|
||||||
"\n{} {} | {} {}",
|
"\n{} {} | {} {}",
|
||||||
"Unexpected token name:".red(),
|
"Unexpected token name:".red(),
|
||||||
name.bold().black(),
|
name.bold().black(),
|
||||||
"pos:".green(),
|
"pos:".green(),
|
||||||
self.pos
|
self.pos
|
||||||
);
|
);
|
||||||
std::process::exit(1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn error(&self, name: &str) {
|
fn error(&self, name: &str) {
|
||||||
println!(
|
panic!(
|
||||||
"\n{} {} | {} {}",
|
"\n{} {} | {} {}",
|
||||||
"Error:".red(),
|
"Error:".red(),
|
||||||
name.bold().black(),
|
name.bold().black(),
|
||||||
"pos:".green(),
|
"pos:".green(),
|
||||||
self.pos
|
self.pos
|
||||||
);
|
);
|
||||||
std::process::exit(1);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
11
src/main.rs
11
src/main.rs
|
@ -15,8 +15,17 @@ mod interpreter;
|
||||||
use interpreter::Interpreter;
|
use interpreter::Interpreter;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let start = Instant::now();
|
std::panic::set_hook(Box::new(|info| {
|
||||||
|
eprint!(
|
||||||
|
"{msg}",
|
||||||
|
msg = match info.payload().downcast_ref::<String>() {
|
||||||
|
None => "Program panicked without a message!".to_owned(),
|
||||||
|
Some(x) => x.to_string(),
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}));
|
||||||
|
|
||||||
|
let start = Instant::now();
|
||||||
let args = Args::parse();
|
let args = Args::parse();
|
||||||
if args.verbose == true {
|
if args.verbose == true {
|
||||||
println!("Running: {}\n", args.file);
|
println!("Running: {}\n", args.file);
|
||||||
|
|
Loading…
Add table
Reference in a new issue