From 473c7c6e9760f02f1c7e89124b91fc45de509e95 Mon Sep 17 00:00:00 2001 From: amirrezaask Date: Sat, 19 Oct 2019 21:53:13 +0330 Subject: [PATCH] remove .repl --- .gitignore | 2 +- interpreter/.repl/sessions/605659000/go.mod | 3 --- interpreter/.repl/sessions/605659000/main.go | 17 ----------------- interpreter/session.go | 13 ++++++------- main.go | 4 ++-- 5 files changed, 9 insertions(+), 30 deletions(-) delete mode 100644 interpreter/.repl/sessions/605659000/go.mod delete mode 100755 interpreter/.repl/sessions/605659000/main.go diff --git a/.gitignore b/.gitignore index 5f7ce9d..9d36695 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ .idea -.gshell +.repl cover.profile plans \ No newline at end of file diff --git a/interpreter/.repl/sessions/605659000/go.mod b/interpreter/.repl/sessions/605659000/go.mod deleted file mode 100644 index 950fc76..0000000 --- a/interpreter/.repl/sessions/605659000/go.mod +++ /dev/null @@ -1,3 +0,0 @@ -module shell - -go 1.13 diff --git a/interpreter/.repl/sessions/605659000/main.go b/interpreter/.repl/sessions/605659000/main.go deleted file mode 100755 index b3144c6..0000000 --- a/interpreter/.repl/sessions/605659000/main.go +++ /dev/null @@ -1,17 +0,0 @@ -package main - -type user struct { - Name string -} - -func Name() string {} - -var ( - x = 2 - _, y = 3, 4 - z = 2 -) - -func main() { - x += 2 -} diff --git a/interpreter/session.go b/interpreter/session.go index c3560a9..1ebefa0 100644 --- a/interpreter/session.go +++ b/interpreter/session.go @@ -133,14 +133,13 @@ func (s *Interpreter) Eval(code string) (string, error) { return "", err } if s.continueMode { - return "", nil - } - if typ == Shell { - return "", nil + return strings.Repeat("...", s.indents), nil } - if err := checkIfHasParsingError(s.String()); err != nil { - s.removeLastCode() - return "", errors.New(err.Error() + "\n") + if typ != Shell { + if err := checkIfHasParsingError(s.String()); err != nil { + s.removeLastCode() + return "", errors.New(err.Error() + "\n") + } } return s.eval(), nil } diff --git a/main.go b/main.go index a54e4dd..081fadc 100644 --- a/main.go +++ b/main.go @@ -18,7 +18,7 @@ var ( ) const ( - version = "0.1.1a" + version = "0.1.2" ) func completer(d prompt.Document) []prompt.Suggest { @@ -64,7 +64,7 @@ func main() { if err != nil { panic(err) } - fmt.Printf("gshell v%s\n", version) + fmt.Printf("repl v%s\n", version) p := prompt.New(handler, completer, prompt.OptionPrefix("repl> ")) p.Run()