// File: /workspace/github_cpp_makefile_star2_O2/pranavmodx[P]modlang/test/parser_test.cpp
// Function: TestIdentifierExpression()
void TestIdentifierExpression()
{
	std::string input = "foobar;";

	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() != 1)
		std::cout << "program->statements does not contain 1 statements, got " << program->statements.size() << std::endl;

	Statement *stmt;
	ExpressionStatement *expStmt;
	Identifier *ident;

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

		expStmt = ((ExpressionStatement *)stmt);

		if (expStmt->tokenLiteral() != "foobar")
			std::cout << "stmt->tokenLiteral() not 'foobar'"
					  << ", got " << stmt->tokenLiteral() << std::endl;

		ident = ((Identifier *)expStmt->expression);

		if (ident->value != "foobar")
			std::cout << "ident->value not 'foobar'"
					  << ", got " << stmt->tokenLiteral() << std::endl;
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1e8, %rsp            # imm = 0x1E8
leaq 0xa4a6(%rip), %rsi      # 0x111f1
leaq 0x58(%rsp), %rbx
leaq 0x78(%rsp), %rdx
movq %rbx, %rdi
callq 0x7470
leaq 0x38(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq 0x28(%rsp), %rdi
movq %rbx, %rsi
callq 0x83a6
leaq 0x78(%rsp), %rdi
callq 0xb630
leaq 0x78(%rsp), %rdi
leaq 0x28(%rsp), %rsi
callq 0xb9cc
leaq 0x78(%rsp), %rdi
callq 0xd1ee
movq %rax, %rbx
leaq 0x78(%rsp), %rdi
callq 0x71d4
testq %rbx, %rbx
jne 0x6dcb
movq 0x13219(%rip), %rdi     # 0x19fd0
leaq 0xa33b(%rip), %rsi      # 0x110f9
callq 0x41b0
movq %rax, %rdi
callq 0x40e0
movq 0x10(%rbx), %rax
subq 0x8(%rbx), %rax
cmpq $0x8, %rax
je 0x6e08
movq 0x131f0(%rip), %rdi     # 0x19fd0
leaq 0xa412(%rip), %rsi      # 0x111f9
callq 0x41b0
movq 0x10(%rbx), %rsi
subq 0x8(%rbx), %rsi
sarq $0x3, %rsi
movq %rax, %rdi
callq 0x4130
movq %rax, %rdi
callq 0x40e0
xorl %ebp, %ebp
leaq 0x8(%rsp), %r14
leaq 0xa2dc(%rip), %r15      # 0x110f2
movq 0x8(%rbx), %rax
movq 0x10(%rbx), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
cmpq %rbp, %rcx
jbe 0x6f0d
movq (%rax,%rbp,8), %r13
movq (%r13), %rax
movq %r14, %rdi
movq %r13, %rsi
callq *(%rax)
movq %r14, %rdi
movq %r15, %rsi
callq 0x7557
movl %eax, %r12d
movq %r14, %rdi
callq 0x4368
testb %r12b, %r12b
je 0x6ea5
movq 0x13170(%rip), %rdi     # 0x19fd0
leaq 0xa3ca(%rip), %rsi      # 0x11231
callq 0x41b0
movq %rax, %rdi
leaq 0xa3b4(%rip), %rsi      # 0x1122a
callq 0x41b0
movq %rax, %r12
movq (%r13), %rax
movq %r14, %rdi
movq %r13, %rsi
callq *(%rax)
movq %r12, %rdi
movq %r14, %rsi
callq 0x41a0
movq %rax, %rdi
callq 0x40e0
movq %r14, %rdi
callq 0x4368
movq 0x48(%r13), %rdi
addq $0x48, %rdi
movq %r15, %rsi
callq 0x7557
testb %al, %al
je 0x6f05
movq 0x13110(%rip), %rdi     # 0x19fd0
leaq 0xa38c(%rip), %rsi      # 0x11253
callq 0x41b0
movq %rax, %rdi
leaq 0xa354(%rip), %rsi      # 0x1122a
callq 0x41b0
movq %rax, %r12
movq (%r13), %rax
movq %r14, %rdi
movq %r13, %rsi
callq *(%rax)
movq %r12, %rdi
movq %r14, %rsi
callq 0x41a0
movq %rax, %rdi
callq 0x40e0
movq %r14, %rdi
callq 0x4368
incq %rbp
jmp 0x6e16
leaq 0x78(%rsp), %rdi
callq 0x7508
leaq 0x28(%rsp), %rdi
callq 0x4368
leaq 0x58(%rsp), %rdi
callq 0x4368
addq $0x1e8, %rsp            # imm = 0x1E8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x6f61
jmp 0x6f41
movq %rax, %rbx
jmp 0x6f6e
jmp 0x6f61
jmp 0x6f61
jmp 0x6f61
jmp 0x6f52
jmp 0x6f52
jmp 0x6f61
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x4368
jmp 0x6f64
movq %rax, %rbx
leaq 0x78(%rsp), %rdi
callq 0x7508
leaq 0x28(%rsp), %rdi
callq 0x4368
leaq 0x58(%rsp), %rdi
callq 0x4368
movq %rbx, %rdi
callq 0x4320