mirror of
https://github.com/artegoser/ONLang
synced 2024-11-05 20:43:57 +03:00
commit
1290beea1c
2 changed files with 15 additions and 4 deletions
|
@ -14,8 +14,8 @@ pub struct Interpreter {
|
|||
}
|
||||
|
||||
impl Interpreter {
|
||||
pub fn new(input: String) -> Interpreter {
|
||||
Interpreter {
|
||||
pub fn new(input: String) -> Self {
|
||||
Self {
|
||||
input,
|
||||
vars: HashMap::new(),
|
||||
pos: 1,
|
||||
|
@ -219,8 +219,8 @@ impl Interpreter {
|
|||
fn input(&self, value: &String) -> Value {
|
||||
let mut input = String::new();
|
||||
print!("{}", value);
|
||||
io::stdout().flush().unwrap_or_default();
|
||||
io::stdin().read_line(&mut input).unwrap_or_default();
|
||||
io::stdout().flush().expect("Couldn't flush Stdout");
|
||||
io::stdin().read_line(&mut input).expect("Couldn't read from Stdin");
|
||||
Value::String(input.trim_end().to_string())
|
||||
}
|
||||
|
||||
|
|
11
src/main.rs
11
src/main.rs
|
@ -1,3 +1,5 @@
|
|||
#![feature(box_syntax, panic_info_message)]
|
||||
|
||||
use clap::Parser;
|
||||
use std::fs;
|
||||
use std::time::Instant;
|
||||
|
@ -15,6 +17,15 @@ mod interpreter;
|
|||
use interpreter::Interpreter;
|
||||
|
||||
fn main() {
|
||||
std::panic::set_hook(
|
||||
box |info| {
|
||||
eprint!("{msg}", msg = match info.message() {
|
||||
None => "Program panicked!".to_owned(),
|
||||
Some(x) => x.to_string()
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
let start = Instant::now();
|
||||
|
||||
let args = Args::parse();
|
||||
|
|
Loading…
Reference in a new issue