// File: /workspace/github_cpp_makefile_star2_O2/pranavmodx[P]modlang/test/parser_test.cpp
// Function: TestLetStatement()
void TestLetStatement()
{
	std::string input =
		"let x = 5;"
		"let y = 10;"
		"let foobar = 838383;";

	std::vector<std::string> expectedIdent{"x", "y", "foobar"};

	// struct LetTest {
	// 	std::string input;
	// 	std::string expectedIdent;
	// 	Expression *value;
	// };

	// std::vector<LetTest> tests {
	// 	{"let x = 5;", "x", 5},
	// 	{"let y = true;", "y", true},
	// 	{"let foobar = y;", "foobar", "y"},
	// }

	Lexer lexer;
	lexer.New(input);

	Parser parser;
	parser.New(lexer);

	Program *program = parser.ParseProgram();

	checkParserErrors(parser);

	if (program == nullptr)
		std::cout << "ParseProgram() returned null" << std::endl;

	if (program->statements.size() != 3)
		std::cout << "program->statements does not contain 3 statements, got " << program->statements.size() << std::endl;

	Statement *stmt;
	for (int i = 0; i < program->statements.size(); i++)
	{
		stmt = program->statements[i];

		if (!testLetStatement((LetStatement *)stmt, expectedIdent[i]))
			return;
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x208, %rsp            # imm = 0x208
leaq 0xa7f7(%rip), %rsi      # 0x110c4
leaq 0x58(%rsp), %rdi
leaq 0x98(%rsp), %rdx
callq 0x7470
leaq 0xa808(%rip), %rsi      # 0x110ee
leaq 0x98(%rsp), %r14
leaq 0x28(%rsp), %rdx
movq %r14, %rdi
callq 0x7470
leaq 0xb8(%rsp), %r15
leaq 0xa7e6(%rip), %rsi      # 0x110f0
leaq 0xf(%rsp), %rdx
movq %r15, %rdi
callq 0x7470
leaq 0xd8(%rsp), %r15
leaq 0xa7cc(%rip), %rsi      # 0x110f2
leaq 0xe(%rsp), %rdx
movq %r15, %rdi
callq 0x7470
leaq 0x10(%rsp), %rdi
leaq 0x98(%rsp), %rsi
pushq $0x3
popq %rdx
leaq 0xd(%rsp), %rcx
callq 0x74ce
pushq $0x40
popq %rbx
leaq (%rsp,%rbx), %rdi
addq $0x98, %rdi
callq 0x4368
addq $-0x20, %rbx
cmpq $-0x20, %rbx
jne 0x6950
leaq 0x38(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq 0x28(%rsp), %rdi
leaq 0x58(%rsp), %rsi
callq 0x83a6
leaq 0x98(%rsp), %rdi
callq 0xb630
leaq 0x98(%rsp), %rdi
leaq 0x28(%rsp), %rsi
callq 0xb9cc
leaq 0x98(%rsp), %rdi
callq 0xd1ee
movq %rax, %rbx
leaq 0x98(%rsp), %rdi
callq 0x71d4
testq %rbx, %rbx
jne 0x69e6
movq 0x135fe(%rip), %rdi     # 0x19fd0
leaq 0xa720(%rip), %rsi      # 0x110f9
callq 0x41b0
movq %rax, %rdi
callq 0x40e0
movq 0x10(%rbx), %rax
subq 0x8(%rbx), %rax
cmpq $0x18, %rax
je 0x6a23
movq 0x135d5(%rip), %rdi     # 0x19fd0
leaq 0xa714(%rip), %rsi      # 0x11116
callq 0x41b0
movq 0x10(%rbx), %rsi
subq 0x8(%rbx), %rsi
sarq $0x3, %rsi
movq %rax, %rdi
callq 0x4130
movq %rax, %rdi
callq 0x40e0
xorl %r12d, %r12d
leaq 0x78(%rsp), %r14
xorl %r13d, %r13d
movq 0x8(%rbx), %rax
movq 0x10(%rbx), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
cmpq %r13, %rcx
jbe 0x6a77
movq (%rax,%r13,8), %r15
movq 0x10(%rsp), %rsi
addq %r12, %rsi
movq %r14, %rdi
callq 0x4260
movq %r15, %rdi
movq %r14, %rsi
callq 0x72d8
movl %eax, %ebp
movq %r14, %rdi
callq 0x4368
incq %r13
addq $0x20, %r12
testb %bpl, %bpl
jne 0x6a2e
leaq 0x98(%rsp), %rdi
callq 0x7508
leaq 0x28(%rsp), %rdi
callq 0x4368
leaq 0x10(%rsp), %rdi
callq 0x74ac
leaq 0x58(%rsp), %rdi
callq 0x4368
addq $0x208, %rsp            # imm = 0x208
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x6b0e
jmp 0x6ab8
movq %rax, %rbx
jmp 0x6b1e
movq %rax, %rbx
pushq $0x40
popq %r14
leaq (%rsp,%r14), %rdi
addq $0x98, %rdi
callq 0x4368
addq $-0x20, %r14
cmpq $-0x20, %r14
jne 0x6ac4
jmp 0x6b32
jmp 0x6ae2
movq %rax, %rbx
addq $-0x20, %r15
movq %r15, %rdi
callq 0x4368
cmpq %r14, %r15
jne 0x6ae5
jmp 0x6b32
movq %rax, %rbx
jmp 0x6b32
jmp 0x6b0e
movq %rax, %rbx
leaq 0x78(%rsp), %rdi
callq 0x4368
jmp 0x6b11
movq %rax, %rbx
leaq 0x98(%rsp), %rdi
callq 0x7508
leaq 0x28(%rsp), %rdi
callq 0x4368
leaq 0x10(%rsp), %rdi
callq 0x74ac
leaq 0x58(%rsp), %rdi
callq 0x4368
movq %rbx, %rdi
callq 0x4320