// File: /workspace/github_cpp_makefile_star2_O3/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, -0xf0(%rbp)
movq 0x6e66(%rip), %rdi      # 0x14fd0
leaq 0x1421(%rip), %rsi      # 0xf592
movl $0x16, %edx
callq 0x3200
leaq -0xd8(%rbp), %rax
movq %rax, -0x10(%rax)
leaq 0x141c(%rip), %rsi      # 0xf5a9
leaq 0x142c(%rip), %rdx      # 0xf5c0
leaq -0xe8(%rbp), %rdi
callq 0x3bb0
leaq -0x100(%rbp), %rax
movq %rax, -0x10(%rax)
leaq 0x13f6(%rip), %rdx      # 0xf5a8
leaq -0x110(%rbp), %rdi
movq %rdx, %rsi
callq 0x3bb0
movq 0x6e18(%rip), %r15      # 0x14fe0
leaq -0x50(%rbp), %r12
leaq -0x110(%rbp), %rbx
leaq -0xa8(%rbp), %r13
leaq -0x88(%rbp), %r14
movq -0xe8(%rbp), %rsi
movq -0xe0(%rbp), %rdx
movq 0x6dda(%rip), %rdi      # 0x14fd0
callq 0x3200
leaq -0x40(%rbp), %rax
movq %rax, -0x50(%rbp)
movq $0x0, -0x48(%rbp)
movb $0x0, -0x40(%rbp)
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x31a0
movsbl %al, %edx
movq %r15, %rdi
movq %r12, %rsi
callq 0x3310
movq %rbx, %rdi
leaq 0x1386(%rip), %rsi      # 0xf5c1
callq 0x30b0
testl %eax, %eax
je 0xe25b
movq %r12, %rdi
leaq 0x135a(%rip), %rsi      # 0xf5a8
callq 0x30b0
testl %eax, %eax
je 0xe46a
leaq -0x98(%rbp), %rax
movq %rax, -0xa8(%rbp)
movq -0x50(%rbp), %rsi
movq -0x48(%rbp), %rdx
addq %rsi, %rdx
movq %r13, %rdi
callq 0x3a18
jmp 0xe286
movq %r13, %rdi
callq 0x3210
movq -0xa8(%rbp), %rsi
movq -0xa0(%rbp), %rdx
movzbl -0x1(%rsi,%rdx), %eax
cmpl $0x20, %eax
je 0xe27e
cmpl $0x5c, %eax
jne 0xe31b
movq %r13, %rdi
callq 0x3210
leaq -0x78(%rbp), %rax
movq %rax, -0x88(%rbp)
movq -0xa8(%rbp), %rsi
movq -0xa0(%rbp), %rdx
addq %rsi, %rdx
movq %r14, %rdi
callq 0x3a18
movq -0x80(%rbp), %rsi
movl $0x1, %ecx
movq %r14, %rdi
xorl %edx, %edx
movl $0x20, %r8d
callq 0x3320
movq -0x88(%rbp), %rsi
movq -0x80(%rbp), %rdx
movq %rbx, %rdi
callq 0x30c0
movq -0x88(%rbp), %rdi
leaq -0x78(%rbp), %rax
cmpq %rax, %rdi
je 0xe448
movq -0x78(%rbp), %rsi
incq %rsi
jmp 0xe443
movq %rbx, %rdi
callq 0x30c0
movq %r14, %rdi
movq %rbx, %rsi
callq 0x390a
movq %r14, %rdi
callq 0xb6b0
testq %rax, %rax
je 0xe3b5
movq -0xf0(%rbp), %rdi
movq %rax, %rsi
callq 0x4886
testq %rax, %rax
je 0xe3fc
leaq -0xc8(%rbp), %rdi
movq %rax, %rsi
callq 0xbf12
movq -0xc8(%rbp), %rsi
movq -0xc0(%rbp), %rdx
movq 0x6c59(%rip), %rdi      # 0x14fd0
callq 0x3200
movb $0xa, -0x29(%rbp)
movl $0x1, %edx
movq %rax, %rdi
leaq -0x29(%rbp), %rsi
callq 0x3200
movq -0xc8(%rbp), %rdi
leaq -0xb8(%rbp), %rax
cmpq %rax, %rdi
je 0xe3fc
movq -0xb8(%rbp), %rsi
incq %rsi
callq 0x31c0
jmp 0xe3fc
movl $0x11, %edx
movq 0x6c0f(%rip), %rdi      # 0x14fd0
leaq 0xc51(%rip), %rsi       # 0xf019
callq 0x3200
movq -0x50(%rbp), %rsi
movq -0x48(%rbp), %rdx
movq 0x6bf4(%rip), %rdi      # 0x14fd0
callq 0x3200
movb $0xa, -0xc8(%rbp)
movl $0x1, %edx
movq %rax, %rdi
leaq -0xc8(%rbp), %rsi
callq 0x3200
movq -0x108(%rbp), %rdx
movq %rbx, %rdi
xorl %esi, %esi
leaq 0x1199(%rip), %rcx      # 0xf5a8
xorl %r8d, %r8d
callq 0x3280
movq -0x70(%rbp), %rdi
leaq -0x60(%rbp), %rax
cmpq %rax, %rdi
je 0xe430
movq -0x60(%rbp), %rsi
incq %rsi
callq 0x31c0
movq -0x88(%rbp), %rdi
testq %rdi, %rdi
je 0xe448
movq -0x78(%rbp), %rsi
subq %rdi, %rsi
callq 0x31c0
movq -0xa8(%rbp), %rdi
leaq -0x98(%rbp), %rax
cmpq %rax, %rdi
je 0xe46a
movq -0x98(%rbp), %rsi
incq %rsi
callq 0x31c0
movq -0x50(%rbp), %rdi
leaq -0x40(%rbp), %rax
cmpq %rax, %rdi
je 0xe1e1
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x31c0
jmp 0xe1e1
jmp 0xe4e5
jmp 0xe4e5
movq %rax, %rbx
movq -0xc8(%rbp), %rdi
leaq -0xb8(%rbp), %rax
cmpq %rax, %rdi
je 0xe4e8
movq -0xb8(%rbp), %rsi
incq %rsi
callq 0x31c0
jmp 0xe4e8
jmp 0xe4bb
jmp 0xe4d9
movq %rax, %rbx
movq -0x88(%rbp), %rdi
leaq -0x78(%rbp), %rax
cmpq %rax, %rdi
je 0xe519
movq -0x78(%rbp), %rsi
incq %rsi
jmp 0xe514
jmp 0xe4d9
movq %rax, %rbx
jmp 0xe519
jmp 0xe53d
movq %rax, %rbx
jmp 0xe559
movq %rax, %rbx
movq -0x70(%rbp), %rdi
leaq -0x60(%rbp), %rax
cmpq %rax, %rdi
je 0xe501
movq -0x60(%rbp), %rsi
incq %rsi
callq 0x31c0
movq -0x88(%rbp), %rdi
testq %rdi, %rdi
je 0xe519
movq -0x78(%rbp), %rsi
subq %rdi, %rsi
callq 0x31c0
movq -0xa8(%rbp), %rdi
leaq -0x98(%rbp), %rax
cmpq %rax, %rdi
je 0xe540
movq -0x98(%rbp), %rsi
incq %rsi
callq 0x31c0
jmp 0xe540
movq %rax, %rbx
movq -0x50(%rbp), %rdi
leaq -0x40(%rbp), %rax
cmpq %rax, %rdi
je 0xe559
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x31c0
movq -0x110(%rbp), %rdi
leaq -0x100(%rbp), %rax
cmpq %rax, %rdi
je 0xe580
movq -0x100(%rbp), %rsi
incq %rsi
callq 0x31c0
jmp 0xe580
movq %rax, %rbx
leaq -0xd8(%rbp), %rax
movq -0xe8(%rbp), %rdi
cmpq %rax, %rdi
je 0xe5a2
movq -0xd8(%rbp), %rsi
incq %rsi
callq 0x31c0
movq %rbx, %rdi
callq 0x32e0