fabricate surrounding parens for top level statements from repl
Signed-off-by: Ava Hahn <ava@sunnypup.io>
This commit is contained in:
parent
c05b94e92a
commit
88e9287d01
1 changed files with 17 additions and 15 deletions
|
|
@ -254,7 +254,6 @@ fn incomplete_brackets(line: &str) -> bool {
|
|||
},
|
||||
|
||||
'(' if within_string.is_none() => balance.push(')'),
|
||||
|
||||
')' => if let Some(last) = balance.last() {
|
||||
if last == &c {
|
||||
balance.pop();
|
||||
|
|
@ -391,7 +390,10 @@ fn main() {
|
|||
match user_doc {
|
||||
Signal::Success(line) => {
|
||||
println!(""); // add a new line before output gets printed
|
||||
let l = line.as_str().to_owned();
|
||||
let mut l = line.as_str().to_owned();
|
||||
if !l.starts_with('(') {
|
||||
l = "(".to_owned() + &l + ")";
|
||||
}
|
||||
match lex(&l) {
|
||||
Ok(a) => match eval(&a, &mut syms) {
|
||||
Ok(a) => println!("{}", a),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue