Skip to content

Commit

Permalink
Set buffer size to 1 and reset with Stdin
Browse files Browse the repository at this point in the history
  • Loading branch information
WilliamRagstad committed Oct 29, 2024
1 parent 8c4928d commit dea8839
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/commands/repl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use lento_core::{
type_checker::types::GetType,
};

use crate::error::print_error;
use crate::{error::print_error, CLI_VERSION};

pub fn handle_command_repl(_args: &ArgMatches, _arg_parser: &mut Command) {
println!(
Expand All @@ -23,6 +23,7 @@ Exit using Ctrl+C",
LANG_VERSION = lento_core::LANG_VERSION.yellow()
);
let mut parser = parser::from_stdin();
parser.lexer().set_buffer_size(1);
let mut env = global_env();
loop {
print!("> ");
Expand All @@ -45,6 +46,6 @@ Exit using Ctrl+C",
Err(err) => print_error(err.message),
}
// Instead of creating a new parser, lexer, and reader, we simply reset them to save memory
parser.reset(StdinReader::default());
parser.lexer().reset(StdinReader::default());
}
}

0 comments on commit dea8839

Please sign in to comment.