// File: /workspace/github_cpp_makefile_star2_O1/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 0x6d5a(%rip), %rdi      # 0x14fd0
leaq 0x134d(%rip), %rsi      # 0xf5ca
movl $0x16, %edx
callq 0x3200
leaq -0xd8(%rbp), %rax
movq %rax, -0x10(%rax)
leaq 0x1348(%rip), %rsi      # 0xf5e1
leaq 0x1358(%rip), %rdx      # 0xf5f8
leaq -0xe8(%rbp), %rdi
callq 0x3ba8
leaq -0x100(%rbp), %rax
movq %rax, -0x10(%rax)
leaq 0x1322(%rip), %rdx      # 0xf5e0
leaq -0x110(%rbp), %rdi
movq %rdx, %rsi
callq 0x3ba8
movq 0x6d0c(%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 0x6cce(%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 0x12b2(%rip), %rsi      # 0xf5f9
callq 0x30b0
testl %eax, %eax
je 0xe367
movq %r12, %rdi
leaq 0x1286(%rip), %rsi      # 0xf5e0
callq 0x30b0
testl %eax, %eax
je 0xe576
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 0xe392
movq %r13, %rdi
callq 0x3210
movq -0xa8(%rbp), %rsi
movq -0xa0(%rbp), %rdx
movzbl -0x1(%rsi,%rdx), %eax
cmpl $0x20, %eax
je 0xe38a
cmpl $0x5c, %eax
jne 0xe427
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 0xe554
movq -0x78(%rbp), %rsi
incq %rsi
jmp 0xe54f
movq %rbx, %rdi
callq 0x30c0
movq %r14, %rdi
movq %rbx, %rsi
callq 0x390a
movq %r14, %rdi
callq 0xb798
testq %rax, %rax
je 0xe4c1
movq -0xf0(%rbp), %rdi
movq %rax, %rsi
callq 0x48b2
testq %rax, %rax
je 0xe508
leaq -0xc8(%rbp), %rdi
movq %rax, %rsi
callq 0xbfe8
movq -0xc8(%rbp), %rsi
movq -0xc0(%rbp), %rdx
movq 0x6b4d(%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 0xe508
movq -0xb8(%rbp), %rsi
incq %rsi
callq 0x31c0
jmp 0xe508
movl $0x11, %edx
movq 0x6b03(%rip), %rdi      # 0x14fd0
leaq 0xb45(%rip), %rsi       # 0xf019
callq 0x3200
movq -0x50(%rbp), %rsi
movq -0x48(%rbp), %rdx
movq 0x6ae8(%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 0x10c5(%rip), %rcx      # 0xf5e0
xorl %r8d, %r8d
callq 0x3280
movq -0x70(%rbp), %rdi
leaq -0x60(%rbp), %rax
cmpq %rax, %rdi
je 0xe53c
movq -0x60(%rbp), %rsi
incq %rsi
callq 0x31c0
movq -0x88(%rbp), %rdi
testq %rdi, %rdi
je 0xe554
movq -0x78(%rbp), %rsi
subq %rdi, %rsi
callq 0x31c0
movq -0xa8(%rbp), %rdi
leaq -0x98(%rbp), %rax
cmpq %rax, %rdi
je 0xe576
movq -0x98(%rbp), %rsi
incq %rsi
callq 0x31c0
movq -0x50(%rbp), %rdi
leaq -0x40(%rbp), %rax
cmpq %rax, %rdi
je 0xe2ed
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x31c0
jmp 0xe2ed
jmp 0xe5f1
jmp 0xe5f1
movq %rax, %rbx
movq -0xc8(%rbp), %rdi
leaq -0xb8(%rbp), %rax
cmpq %rax, %rdi
je 0xe5f4
movq -0xb8(%rbp), %rsi
incq %rsi
callq 0x31c0
jmp 0xe5f4
jmp 0xe5c7
jmp 0xe5e5
movq %rax, %rbx
movq -0x88(%rbp), %rdi
leaq -0x78(%rbp), %rax
cmpq %rax, %rdi
je 0xe625
movq -0x78(%rbp), %rsi
incq %rsi
jmp 0xe620
jmp 0xe5e5
movq %rax, %rbx
jmp 0xe625
jmp 0xe649
movq %rax, %rbx
jmp 0xe665
movq %rax, %rbx
movq -0x70(%rbp), %rdi
leaq -0x60(%rbp), %rax
cmpq %rax, %rdi
je 0xe60d
movq -0x60(%rbp), %rsi
incq %rsi
callq 0x31c0
movq -0x88(%rbp), %rdi
testq %rdi, %rdi
je 0xe625
movq -0x78(%rbp), %rsi
subq %rdi, %rsi
callq 0x31c0
movq -0xa8(%rbp), %rdi
leaq -0x98(%rbp), %rax
cmpq %rax, %rdi
je 0xe64c
movq -0x98(%rbp), %rsi
incq %rsi
callq 0x31c0
jmp 0xe64c
movq %rax, %rbx
movq -0x50(%rbp), %rdi
leaq -0x40(%rbp), %rax
cmpq %rax, %rdi
je 0xe665
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x31c0
movq -0x110(%rbp), %rdi
leaq -0x100(%rbp), %rax
cmpq %rax, %rdi
je 0xe68c
movq -0x100(%rbp), %rsi
incq %rsi
callq 0x31c0
jmp 0xe68c
movq %rax, %rbx
leaq -0xd8(%rbp), %rax
movq -0xe8(%rbp), %rdi
cmpq %rax, %rdi
je 0xe6ae
movq -0xd8(%rbp), %rsi
incq %rsi
callq 0x31c0
movq %rbx, %rdi
callq 0x32e0