Skip to content

Commit

Permalink
deps: Update rustyline v13
Browse files Browse the repository at this point in the history
  • Loading branch information
phorward committed Dec 18, 2023
1 parent 542bad8 commit 14a89da
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 114 deletions.
155 changes: 50 additions & 105 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ num = "0.4"
num-bigint = "0.4"
num-parse = "0.1" # use crates.io-version
#num-parse = { version = "0.1", path = "../num-parse" } # use local version
rustyline = "9"
rustyline = "13"
tokay-macros = "0.4" # use crates.io-version
#tokay-macros = { version = "0.4", path = "macros" } # use local version
2 changes: 1 addition & 1 deletion ROADMAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ This document describes upcoming changes to achieve with a specific version.
- [x] Implement iterators and `for...in`-syntax (#101)
- [x] Implement generic parselets (#10, #105)
- [x] `Keyword<P>` (#121)
- [ ] `Until<P, Escape: '\\'>``
- [ ] `Until<P, Escape: '\\'>`
- [ ] `String<Start, End: Void, Escape: '\\'>`
- [ ] Implement inlined parselets (#120)
- [ ] New list syntax `,`, redefining sequence/`dict` syntax (#100)
Expand Down
18 changes: 11 additions & 7 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,12 @@ fn get_readers(opts: &Opts) -> Vec<Reader> {
}

// Read-Eval-Print-Loop (REPL) for Tokay
fn repl(opts: &Opts) {
fn repl(opts: &Opts) -> rustyline::Result<()> {
let mut globals: Vec<RefValue> = Vec::new();
let mut compiler = Compiler::new();

// todo: Implement a completer?
let mut readline = rustyline::Editor::<()>::new();
let mut readline = rustyline::DefaultEditor::new()?;

// todo: Implement a history in $HOME for production?
if cfg!(debug_assertions) && std::env::var("TOKAY_HISTORY_LOAD").map_or(true, |var| var == "1")
Expand Down Expand Up @@ -129,7 +129,7 @@ fn repl(opts: &Opts) {

//println!("code = {:?}", code);

readline.add_history_entry(code.as_str());
readline.add_history_entry(code.as_str())?;

match code.as_str() {
/*
Expand Down Expand Up @@ -179,9 +179,11 @@ fn repl(opts: &Opts) {
.save_history(".tokayhist")
.expect("Cannot save REPL history");
}

Ok(())
}

fn main() {
fn main() -> rustyline::Result<()> {
// Handle command-line arguments from Opts.
let opts = Opts::parse();

Expand Down Expand Up @@ -241,7 +243,7 @@ fn main() {
if readers.len() == 0 {
// Run program in its own REPL?
if opts.repl {
let mut readline = rustyline::Editor::<()>::new();
let mut readline = rustyline::DefaultEditor::new()?;
readline.load_history(".tokayrepl").ok();

loop {
Expand All @@ -261,7 +263,7 @@ fn main() {
continue;
}

readline.add_history_entry(code.as_str());
readline.add_history_entry(code.as_str())?;

match program.run_from_reader(Reader::new(
None,
Expand Down Expand Up @@ -329,6 +331,8 @@ fn main() {
print_version();
}

repl(&opts);
repl(&opts)?
}

Ok(())
}

0 comments on commit 14a89da

Please sign in to comment.