/*
 * Copyright 2021 wssccc
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.ngscript;

import org.jline.reader.EndOfFileException;
import org.jline.reader.LineReader;
import org.jline.reader.LineReaderBuilder;
import org.jline.reader.UserInterruptException;
import org.jline.reader.impl.history.DefaultHistory;
import org.jline.terminal.Terminal;
import org.jline.terminal.TerminalBuilder;

import java.io.IOException;

/**
 * @author wssccc
 */
public class Repl {

    public static void main(String[] args) throws IOException {
        Terminal terminal = TerminalBuilder.builder()
                .system(true)
                .build();

        LineReader lineReader = LineReaderBuilder.builder()
                .history(new DefaultHistory())
                .terminal(terminal)
                .build();
        Ngscript ngscript = new Ngscript();
        String prompt = "ngscript> ";
        while (true) {
            String line;
            try {
                line = lineReader.readLine(prompt);
                boolean compiled = ngscript.feed(line);
                if (compiled) {
                    prompt = "ngscript> ";
                } else {
                    prompt = "... ";
                }
            } catch (UserInterruptException e) {
                // Do nothing
            } catch (EndOfFileException e) {
                System.out.println("\nBye.");
                return;
            } catch (Exception ex) {
                ex.printStackTrace();
            }
        }
    }
}

@@ -1327,24 +1327,127 @@
   .build();%0A
+        Configuration configuration = new Configuration();%0A        configuration.setInteractive(true);%0A
         Ngsc
@@ -1475,16 +1475,29 @@
 gscript(
+configuration
 );%0A     
@@ -1521,32 +1521,64 @@
 = %22ngscript%3E %22;%0A
+        boolean running = true;%0A
         while (t
@@ -1576,20 +1576,23 @@
  while (
-t
 ru
-e
+nning
 ) %7B%0A    
@@ -1941,156 +1941,65 @@
 ion 
-e) %7B%0A                // Do nothing%0A            %7D catch (EndOfFileException e) %7B%0A                System.out.println(%22%5CnBye.%22);%0A                return
+%7C EndOfFileException e) %7B%0A                running = false
 ;%0A  
@@ -2091,20 +2091,58 @@
 %7D%0A        %7D%0A
+        System.out.println(%22%5CnBye.%22);%0A
     %7D%0A%7D%0A

Fix repl