// File: pranavmodx[P]modlang/src/parser.cpp
// Function: Parser::parseMinHeapLiteral()
Expression *Parser::parseMinHeapLiteral()
{
	MinHeapLiteral *exp = new MinHeapLiteral();
	exp->token = curToken;

	if (!expectPeek(LT))
	{
		delete exp;
		return nullptr;
	}

	if (peekToken.type != INTEGER && peekToken.type != STRING) {
		delete exp;
		peekTypeError();
		return nullptr;
	}

	nextToken();

	exp->type = curToken.type;

	if (!expectPeek(GT))
	{
		delete exp;
		return nullptr;
	}

	if (!expectPeek(LBRACE))
	{
		delete exp;
		return nullptr;
	}

	while (peekToken.type != RBRACE)
	{
		nextToken();

		Expression *value = parseExpression(LOWEST);

		if (value->getTokenType() != exp->type) {
			curTypeError(exp->type);
			return nullptr;
		}

		exp->elements.push_back(value);

		if (peekToken.type != RBRACE && !expectPeek(COMMA))
			return nullptr;
	}

	if (!expectPeek(RBRACE))
	{
		delete exp;
		return nullptr;
	}

	return exp;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xd0, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x98(%rbp)
movl $0x80, %edi
callq 0x52a0
movq %rax, %rdi
movq %rdi, -0x90(%rbp)
movq %rdi, %rax
movq %rax, -0x88(%rbp)
xorps %xmm0, %xmm0
movaps %xmm0, -0x80(%rbp)
movaps %xmm0, 0x70(%rdi)
movaps %xmm0, 0x60(%rdi)
movaps %xmm0, 0x50(%rdi)
movaps %xmm0, 0x40(%rdi)
movaps %xmm0, 0x30(%rdi)
movaps %xmm0, 0x20(%rdi)
movaps %xmm0, 0x10(%rdi)
movaps %xmm0, (%rdi)
callq 0x23e70
jmp 0x20b35
movq -0x98(%rbp), %rsi
movq -0x88(%rbp), %rax
movq %rax, -0x18(%rbp)
addq $0x30, %rsi
movq -0x18(%rbp), %rdi
addq $0x8, %rdi
callq 0x22d00
movq -0x98(%rbp), %rdi
leaq 0x44f9a(%rip), %rsi     # 0x65b00
callq 0x21d00
testb $0x1, %al
jne 0x20bbc
movq -0x18(%rbp), %rax
movq %rax, -0xa0(%rbp)
cmpq $0x0, %rax
je 0x20b8d
movq -0xa0(%rbp), %rdi
movq (%rdi), %rax
callq *0x20(%rax)
movq $0x0, -0x8(%rbp)
jmp 0x20e47
movq -0x88(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
movl $0x80, %esi
callq 0x52b0
jmp 0x20e54
movq -0x98(%rbp), %rdi
addq $0x70, %rdi
leaq 0x44e12(%rip), %rsi     # 0x659e0
callq 0x22d80
testb $0x1, %al
jne 0x20bd9
jmp 0x20c2d
movq -0x98(%rbp), %rdi
addq $0x70, %rdi
leaq 0x44e15(%rip), %rsi     # 0x65a00
callq 0x22d80
testb $0x1, %al
jne 0x20bf6
jmp 0x20c2d
movq -0x18(%rbp), %rax
movq %rax, -0xa8(%rbp)
cmpq $0x0, %rax
je 0x20c14
movq -0xa8(%rbp), %rdi
movq (%rdi), %rax
callq *0x20(%rax)
movq -0x98(%rbp), %rdi
callq 0x222c0
movq $0x0, -0x8(%rbp)
jmp 0x20e47
movq -0x98(%rbp), %rdi
callq 0x1f390
movq -0x98(%rbp), %rsi
addq $0x30, %rsi
movq -0x18(%rbp), %rdi
addq $0x48, %rdi
callq 0x5050
movq -0x98(%rbp), %rdi
leaq 0x44ec1(%rip), %rsi     # 0x65b20
callq 0x21d00
testb $0x1, %al
jne 0x20c93
movq -0x18(%rbp), %rax
movq %rax, -0xb0(%rbp)
cmpq $0x0, %rax
je 0x20c86
movq -0xb0(%rbp), %rdi
movq (%rdi), %rax
callq *0x20(%rax)
movq $0x0, -0x8(%rbp)
jmp 0x20e47
movq -0x98(%rbp), %rdi
leaq 0x44fbf(%rip), %rsi     # 0x65c60
callq 0x21d00
testb $0x1, %al
jne 0x20cd5
movq -0x18(%rbp), %rax
movq %rax, -0xb8(%rbp)
cmpq $0x0, %rax
je 0x20cc8
movq -0xb8(%rbp), %rdi
movq (%rdi), %rax
callq *0x20(%rax)
movq $0x0, -0x8(%rbp)
jmp 0x20e47
jmp 0x20cd7
movq -0x98(%rbp), %rdi
addq $0x70, %rdi
leaq 0x44f97(%rip), %rsi     # 0x65c80
callq 0x22d80
testb $0x1, %al
jne 0x20cf7
jmp 0x20e00
movq -0x98(%rbp), %rdi
callq 0x1f390
movq -0x98(%rbp), %rdi
xorl %esi, %esi
callq 0x21d60
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rsi
movq (%rsi), %rax
leaq -0x50(%rbp), %rdi
callq *0x30(%rax)
movq -0x18(%rbp), %rsi
addq $0x48, %rsi
leaq -0x50(%rbp), %rdi
callq 0x22d80
movb %al, -0xb9(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x5518
movb -0xb9(%rbp), %al
testb $0x1, %al
jne 0x20d4f
jmp 0x20dac
movq -0x18(%rbp), %rsi
addq $0x48, %rsi
leaq -0x70(%rbp), %rdi
movq %rdi, -0xc8(%rbp)
callq 0x5130
movq -0x98(%rbp), %rdi
movq -0xc8(%rbp), %rsi
callq 0x22370
jmp 0x20d7c
leaq -0x70(%rbp), %rdi
callq 0x5518
movq $0x0, -0x8(%rbp)
jmp 0x20e47
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
leaq -0x70(%rbp), %rdi
callq 0x5518
jmp 0x20e54
movq -0x18(%rbp), %rdi
addq $0x68, %rdi
leaq -0x30(%rbp), %rsi
callq 0x23c30
movq -0x98(%rbp), %rdi
addq $0x70, %rdi
leaq 0x44eb1(%rip), %rsi     # 0x65c80
callq 0x22d80
testb $0x1, %al
jne 0x20dda
jmp 0x20dfb
movq -0x98(%rbp), %rdi
leaq 0x44dd8(%rip), %rsi     # 0x65bc0
callq 0x21d00
testb $0x1, %al
jne 0x20dfb
movq $0x0, -0x8(%rbp)
jmp 0x20e47
jmp 0x20cd7
movq -0x98(%rbp), %rdi
leaq 0x44e72(%rip), %rsi     # 0x65c80
callq 0x21d00
testb $0x1, %al
jne 0x20e3f
movq -0x18(%rbp), %rax
movq %rax, -0xd0(%rbp)
cmpq $0x0, %rax
je 0x20e35
movq -0xd0(%rbp), %rdi
movq (%rdi), %rax
callq *0x20(%rax)
movq $0x0, -0x8(%rbp)
jmp 0x20e47
movq -0x18(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0xd0, %rsp
popq %rbp
retq
movq -0x20(%rbp), %rdi
callq 0x5490
nopl (%rax)