mirror of
https://github.com/artegoser/ONLang
synced 2024-12-23 01:23:46 +03:00
commit
1290beea1c
2 changed files with 15 additions and 4 deletions
|
@ -14,8 +14,8 @@ pub struct Interpreter {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Interpreter {
|
impl Interpreter {
|
||||||
pub fn new(input: String) -> Interpreter {
|
pub fn new(input: String) -> Self {
|
||||||
Interpreter {
|
Self {
|
||||||
input,
|
input,
|
||||||
vars: HashMap::new(),
|
vars: HashMap::new(),
|
||||||
pos: 1,
|
pos: 1,
|
||||||
|
@ -219,8 +219,8 @@ 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())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
11
src/main.rs
11
src/main.rs
|
@ -1,3 +1,5 @@
|
||||||
|
#![feature(box_syntax, panic_info_message)]
|
||||||
|
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
use std::fs;
|
use std::fs;
|
||||||
use std::time::Instant;
|
use std::time::Instant;
|
||||||
|
@ -15,6 +17,15 @@ mod interpreter;
|
||||||
use interpreter::Interpreter;
|
use interpreter::Interpreter;
|
||||||
|
|
||||||
fn main() {
|
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 start = Instant::now();
|
||||||
|
|
||||||
let args = Args::parse();
|
let args = Args::parse();
|
||||||
|
|
Loading…
Add table
Reference in a new issue