// File: /workspace/github_cpp_makefile_star2_O2/BlinfoldKing[P]lisval/src/lib/repl.cpp
// Function: Repl::run()
void Repl::run() {

	/* linenoiseHistoryLoad(file); */
	cout << "Press Ctrl+C to exit\n\n";

	string prompt = "(\x1b[1;32mlisval\x1b[0m) \u03bb ";

	string input = "";
	while (1) {
        cout << prompt;

        string result;
        getline(cin, result);

		if (input == "(history)") {

		} else if (result == "") {
			continue;
		}

		string str_result(result);
		while (str_result.back() == ' ') str_result.pop_back();
		if (str_result.back() == '\\') {
			str_result.pop_back();
			input += str_result + ' ';
			continue;
		}

		input += str_result;

		Parser p(input);
		Token *ast = p.parse();
		if (ast)
		{
			Token *eval_result = this->evaluator.eval(ast);
			if (eval_result)
				cout << eval_result->debug() << '\n';
		}
		else
		{
			cout << "invalid pattern: " << result << '\n';
		}

		input = "";
	}

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xe8, %rsp
movq %rdi, -0x30(%rbp)
movq 0x6599(%rip), %rdi      # 0x11fc8
leaq 0xb36(%rip), %rsi       # 0xc56c
callq 0x31f0
leaq 0xb41(%rip), %rsi       # 0xc583
leaq -0xd0(%rbp), %rdi
leaq -0x108(%rbp), %rdx
callq 0x3100
leaq 0xb26(%rip), %rsi       # 0xc582
leaq -0xb0(%rbp), %rdi
leaq -0x108(%rbp), %rdx
callq 0x3100
leaq -0x50(%rbp), %r13
leaq -0xb0(%rbp), %r15
leaq -0x70(%rbp), %r12
leaq -0x108(%rbp), %rbx
movq 0x653c(%rip), %rdi      # 0x11fc8
leaq -0xd0(%rbp), %rsi
callq 0x31e0
leaq -0x40(%rbp), %rax
movq %rax, -0x50(%rbp)
andq $0x0, -0x48(%rbp)
movb $0x0, -0x40(%rbp)
movq 0x6530(%rip), %rdi      # 0x11fe0
movq %r13, %rsi
callq 0x3070
movq %r15, %rdi
leaq 0xad9(%rip), %rsi       # 0xc59b
callq 0x9969
testb %al, %al
jne 0xbae2
movq %r13, %rdi
leaq 0xaad(%rip), %rsi       # 0xc582
callq 0x9969
testb %al, %al
jne 0xbbf2
movq %r12, %rdi
movq %r13, %rsi
callq 0x3290
jmp 0xbaf7
movq %r12, %rdi
callq 0x3250
movq -0x70(%rbp), %rax
movq -0x68(%rbp), %rcx
movzbl -0x1(%rax,%rcx), %eax
cmpl $0x20, %eax
je 0xbaef
cmpl $0x5c, %eax
jne 0xbb3c
movq %r12, %rdi
callq 0x3250
movq %rbx, %rdi
movq %r12, %rsi
pushq $0x20
popq %rdx
callq 0x3789
movq %r15, %rdi
movq %rbx, %rsi
callq 0x3370
movq %rbx, %rdi
callq 0x3140
jmp 0xbbea
movq %r15, %rdi
movq %r12, %rsi
callq 0x3370
movq %rbx, %rdi
movq %r15, %rsi
callq 0x37c4
movq %rbx, %rdi
callq 0x8e16
testq %rax, %rax
je 0xbbaa
movq -0x30(%rbp), %rdi
movq %rax, %rsi
callq 0x42ea
testq %rax, %rax
je 0xbbd3
leaq -0x90(%rbp), %r14
movq %r14, %rdi
movq %rax, %rsi
callq 0x937e
movq 0x643f(%rip), %rdi      # 0x11fc8
movq %r14, %rsi
callq 0x31e0
movq %rax, %rdi
pushq $0xa
popq %rsi
callq 0x3240
leaq -0x90(%rbp), %rdi
callq 0x3140
jmp 0xbbd3
movq 0x6417(%rip), %rdi      # 0x11fc8
leaq 0x461(%rip), %rsi       # 0xc019
callq 0x31f0
movq %rax, %rdi
movq %r13, %rsi
callq 0x31e0
movq %rax, %rdi
pushq $0xa
popq %rsi
callq 0x3240
movq %r15, %rdi
leaq 0x9a5(%rip), %rsi       # 0xc582
callq 0x3360
movq %rbx, %rdi
callq 0x381e
movq %r12, %rdi
callq 0x3140
movq %r13, %rdi
callq 0x3140
jmp 0xba85
jmp 0xbc3a
jmp 0xbc3a
movq %rax, %rbx
leaq -0x90(%rbp), %rdi
callq 0x3140
jmp 0xbc3d
jmp 0xbc29
movq %rax, %rbx
leaq -0x108(%rbp), %rdi
callq 0x3140
jmp 0xbc49
jmp 0xbc29
movq %rax, %rbx
jmp 0xbc49
jmp 0xbc30
movq %rax, %rbx
jmp 0xbc52
movq %rax, %rbx
jmp 0xbc5b
movq %rax, %rbx
leaq -0x108(%rbp), %rdi
callq 0x381e
leaq -0x70(%rbp), %rdi
callq 0x3140
leaq -0x50(%rbp), %rdi
callq 0x3140
leaq -0xb0(%rbp), %rdi
callq 0x3140
jmp 0xbc6c
movq %rax, %rbx
leaq -0xd0(%rbp), %rdi
callq 0x3140
movq %rbx, %rdi
callq 0x3320