// File: pranavmodx[P]modlang/repl.cpp
// Function: REPL()
void REPL()
{
	const std::string PROMPT = ">> ";

	Lexer lexer;
	Parser parser;
	Evaluator evaluator;

	Environment *env = new Environment();

	std::string line;

	while (true)
	{
		std::cout << PROMPT;

		std::getline(std::cin, line);

		if (line.empty())
			continue;

		lexer.New(line);
		parser.New(lexer);

		Program *program = parser.ParseProgram();

		if (parser.Errors().size())
			for (std::string error : parser.Errors())
				std::cout << error << std::endl;

		else {
			Object *obj = evaluator.Eval(program, env);
			if (obj != __NULL)
				std::cout << obj->inspect() << std::endl;
		}

		parser.resetErrors();
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x2e0, %rsp            # imm = 0x2E0
leaq -0x21(%rbp), %rdi
movq %rdi, -0x2a8(%rbp)
callq 0x54a0
movq -0x2a8(%rbp), %rdx
leaq 0x31ff1(%rip), %rsi     # 0x450ea
leaq -0x20(%rbp), %rdi
callq 0x134c0
jmp 0x13104
leaq -0x21(%rbp), %rdi
callq 0x52f0
leaq -0x68(%rbp), %rdi
callq 0x13570
leaq -0x1d8(%rbp), %rdi
callq 0x1ea50
jmp 0x13124
movl $0x40, %edi
callq 0x52a0
movq %rax, -0x2b0(%rbp)
jmp 0x13137
movq -0x2b0(%rbp), %rdi
xorl %esi, %esi
movl $0x40, %edx
callq 0x5170
movq -0x2b0(%rbp), %rdi
callq 0x13590
movq -0x2b0(%rbp), %rax
movq %rax, -0x1e8(%rbp)
leaq -0x208(%rbp), %rdi
callq 0x53a0
jmp 0x13172
movq 0x50e47(%rip), %rdi     # 0x63fc0
leaq -0x20(%rbp), %rsi
callq 0x5260
jmp 0x13184
movq 0x50e55(%rip), %rdi     # 0x63fe0
leaq -0x208(%rbp), %rsi
callq 0x50a0
jmp 0x13199
leaq -0x208(%rbp), %rdi
callq 0x5460
testb $0x1, %al
jne 0x131ab
jmp 0x131fa
jmp 0x13170
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x21(%rbp), %rdi
callq 0x52f0
jmp 0x13493
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x13481
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x13475
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x13469
leaq -0x68(%rbp), %rdi
leaq -0x208(%rbp), %rsi
callq 0x176a0
jmp 0x1320c
leaq -0x1d8(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x1ef10
jmp 0x1321e
leaq -0x1d8(%rbp), %rdi
callq 0x21520
movq %rax, -0x2b8(%rbp)
jmp 0x13233
movq -0x2b8(%rbp), %rax
movq %rax, -0x210(%rbp)
leaq -0x228(%rbp), %rdi
leaq -0x1d8(%rbp), %rsi
callq 0x22250
jmp 0x13256
leaq -0x228(%rbp), %rdi
callq 0x135b0
movq %rax, -0x2c0(%rbp)
leaq -0x228(%rbp), %rdi
callq 0x135d0
movq -0x2c0(%rbp), %rax
cmpq $0x0, %rax
je 0x1339e
leaq -0x248(%rbp), %rdi
leaq -0x1d8(%rbp), %rsi
callq 0x22250
jmp 0x1329b
leaq -0x248(%rbp), %rax
movq %rax, -0x230(%rbp)
movq -0x230(%rbp), %rdi
callq 0x13630
movq %rax, -0x250(%rbp)
movq -0x230(%rbp), %rdi
callq 0x13660
movq %rax, -0x258(%rbp)
leaq -0x250(%rbp), %rdi
leaq -0x258(%rbp), %rsi
callq 0x13690
testb $0x1, %al
jne 0x132f7
leaq -0x248(%rbp), %rdi
callq 0x135d0
jmp 0x13399
leaq -0x250(%rbp), %rdi
callq 0x136d0
movq %rax, %rsi
leaq -0x278(%rbp), %rdi
callq 0x5130
jmp 0x13314
movq 0x50ca5(%rip), %rdi     # 0x63fc0
leaq -0x278(%rbp), %rsi
callq 0x5260
movq %rax, -0x2c8(%rbp)
jmp 0x13330
movq -0x2c8(%rbp), %rdi
movq 0x50c5a(%rip), %rsi     # 0x63f98
callq 0x52d0
jmp 0x13345
leaq -0x278(%rbp), %rdi
callq 0x5518
leaq -0x250(%rbp), %rdi
callq 0x136f0
jmp 0x132cf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x13388
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x278(%rbp), %rdi
callq 0x5518
leaq -0x248(%rbp), %rdi
callq 0x135d0
jmp 0x13469
jmp 0x13456
movq -0x210(%rbp), %rsi
movq -0x1e8(%rbp), %rdx
leaq -0x1d9(%rbp), %rdi
callq 0x32080
movq %rax, -0x2d0(%rbp)
jmp 0x133c1
movq -0x2d0(%rbp), %rax
movq %rax, -0x280(%rbp)
movq -0x280(%rbp), %rax
leaq 0x531e3(%rip), %rcx     # 0x665c0
cmpq (%rcx), %rax
je 0x13454
movq -0x280(%rbp), %rsi
movq (%rsi), %rax
movq 0x8(%rax), %rax
leaq -0x2a0(%rbp), %rdi
callq *%rax
jmp 0x133fb
movq 0x50bbe(%rip), %rdi     # 0x63fc0
leaq -0x2a0(%rbp), %rsi
callq 0x5260
movq %rax, -0x2d8(%rbp)
jmp 0x13417
movq -0x2d8(%rbp), %rdi
movq 0x50b73(%rip), %rsi     # 0x63f98
callq 0x52d0
jmp 0x1342c
leaq -0x2a0(%rbp), %rdi
callq 0x5518
jmp 0x13454
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x2a0(%rbp), %rdi
callq 0x5518
jmp 0x13469
jmp 0x13456
leaq -0x1d8(%rbp), %rdi
callq 0x22290
jmp 0x13464
jmp 0x13170
leaq -0x208(%rbp), %rdi
callq 0x5518
leaq -0x1d8(%rbp), %rdi
callq 0x13710
leaq -0x68(%rbp), %rdi
callq 0x13790
leaq -0x20(%rbp), %rdi
callq 0x5518
movq -0x30(%rbp), %rdi
callq 0x5490
nopl (%rax)