// File: iamlouk[P]asbi/src/parser.cc
// Function: asbi::Parser::parse_block()
ast::Block* Parser::parse_block() {
	if (tokenizer.peek().type == tok::RightCurlyBracket) {
		tokenizer.next();
		return new ast::Block(std::vector<ast::Node*>());
	}

	std::vector<ast::Node*> exprs;
	exprs.push_back(parse_expr());
	auto t = tokenizer.next();
	while (t.type == tok::Semicolon) {
		if (tokenizer.peek().type == tok::RightCurlyBracket) {
			t = tokenizer.next();
			break;
		}

		exprs.push_back(parse_expr());
		t = tokenizer.next();
	}

	if (t.type != tok::RightCurlyBracket)
		throw utils::parser_error("expected ';' or '}'", t);

	return new ast::Block(std::move(exprs));
}

// Assembly:
subq $0x188, %rsp            # imm = 0x188
movq %rdi, 0x178(%rsp)
movq 0x178(%rsp), %rdi
movq %rdi, 0x88(%rsp)
callq 0x92b0
movq %rax, 0x168(%rsp)
movq %rdx, 0x170(%rsp)
cmpl $0x1a, 0x168(%rsp)
jne 0xef83
movq 0x88(%rsp), %rdi
callq 0x9340
movq %rax, 0x158(%rsp)
movq %rdx, 0x160(%rsp)
movl $0x20, %edi
callq 0x6460
movq %rax, 0x78(%rsp)
movq %rax, 0x70(%rsp)
movb $0x1, 0x133(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x140(%rsp)
movq $0x0, 0x150(%rsp)
leaq 0x140(%rsp), %rdi
movq %rdi, 0x80(%rsp)
callq 0x11ce0
movq 0x78(%rsp), %rdi
movq 0x80(%rsp), %rsi
callq 0x11e60
jmp 0xef1b
movq 0x70(%rsp), %rax
movb $0x0, 0x133(%rsp)
movq %rax, 0x180(%rsp)
leaq 0x140(%rsp), %rdi
callq 0x11ed0
jmp 0xf29a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x138(%rsp)
movl %eax, 0x134(%rsp)
leaq 0x140(%rsp), %rdi
callq 0x11ed0
testb $0x1, 0x133(%rsp)
jne 0xef6f
jmp 0xef7e
movq 0x70(%rsp), %rdi
movl $0x20, %esi
callq 0x6470
jmp 0xf2aa
leaq 0x118(%rsp), %rdi
callq 0x11ce0
movq 0x88(%rsp), %rdi
callq 0xe090
movq %rax, 0x68(%rsp)
jmp 0xefa4
movq 0x68(%rsp), %rax
movq %rax, 0x110(%rsp)
leaq 0x118(%rsp), %rdi
leaq 0x110(%rsp), %rsi
callq 0x11cf0
jmp 0xefc8
movq 0x88(%rsp), %rdi
callq 0x9340
movq %rdx, 0x58(%rsp)
movq %rax, 0x60(%rsp)
jmp 0xefe1
movq 0x58(%rsp), %rax
movq 0x60(%rsp), %rcx
movq %rcx, 0x100(%rsp)
movq %rax, 0x108(%rsp)
cmpl $0x1e, 0x100(%rsp)
jne 0xf147
movq 0x88(%rsp), %rdi
callq 0x92b0
movq %rdx, 0x48(%rsp)
movq %rax, 0x50(%rsp)
jmp 0xf022
movq 0x48(%rsp), %rax
movq 0x50(%rsp), %rcx
movq %rcx, 0xf0(%rsp)
movq %rax, 0xf8(%rsp)
cmpl $0x1a, 0xf0(%rsp)
jne 0xf0b7
movq 0x88(%rsp), %rdi
callq 0x9340
movq %rdx, 0x38(%rsp)
movq %rax, 0x40(%rsp)
jmp 0xf05f
movq 0x38(%rsp), %rax
movq 0x40(%rsp), %rcx
movq %rcx, 0xe0(%rsp)
movq %rax, 0xe8(%rsp)
movq 0xe0(%rsp), %rax
movq %rax, 0x100(%rsp)
movq 0xe8(%rsp), %rax
movq %rax, 0x108(%rsp)
jmp 0xf147
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x138(%rsp)
movl %eax, 0x134(%rsp)
jmp 0xf28b
movq 0x88(%rsp), %rdi
callq 0xe090
movq %rax, 0x30(%rsp)
jmp 0xf0cb
movq 0x30(%rsp), %rax
movq %rax, 0xd8(%rsp)
leaq 0x118(%rsp), %rdi
leaq 0xd8(%rsp), %rsi
callq 0x11cf0
jmp 0xf0ef
movq 0x88(%rsp), %rdi
callq 0x9340
movq %rdx, 0x20(%rsp)
movq %rax, 0x28(%rsp)
jmp 0xf108
movq 0x20(%rsp), %rax
movq 0x28(%rsp), %rcx
movq %rcx, 0xc8(%rsp)
movq %rax, 0xd0(%rsp)
movq 0xc8(%rsp), %rax
movq %rax, 0x100(%rsp)
movq 0xd0(%rsp), %rax
movq %rax, 0x108(%rsp)
jmp 0xeffb
cmpl $0x1a, 0x100(%rsp)
je 0xf1d8
movl $0x48, %edi
callq 0x6200
movq %rax, %rdi
movq %rdi, %rax
movq %rax, 0x18(%rsp)
movups 0x100(%rsp), %xmm0
movaps %xmm0, 0xb0(%rsp)
movq 0xb0(%rsp), %rdx
movq 0xb8(%rsp), %rcx
leaq 0x29827(%rip), %rsi     # 0x389b8
callq 0x17350
jmp 0xf198
movq 0x18(%rsp), %rdi
leaq 0x3c384(%rip), %rsi     # 0x4b528
leaq 0x2af5(%rip), %rdx      # 0x11ca0
callq 0x6780
jmp 0xf2b7
movq 0x18(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x138(%rsp)
movl %eax, 0x134(%rsp)
callq 0x6320
jmp 0xf28b
movl $0x20, %edi
callq 0x6460
movq %rax, 0x10(%rsp)
jmp 0xf1e9
movb $0x1, 0x97(%rsp)
leaq 0x98(%rsp), %rdi
movq %rdi, 0x8(%rsp)
leaq 0x118(%rsp), %rsi
callq 0x12220
movq 0x10(%rsp), %rdi
movq 0x8(%rsp), %rsi
callq 0x11e60
jmp 0xf21c
movq 0x10(%rsp), %rax
movb $0x0, 0x97(%rsp)
movq %rax, 0x180(%rsp)
leaq 0x98(%rsp), %rdi
callq 0x11ed0
leaq 0x118(%rsp), %rdi
callq 0x11ed0
jmp 0xf29a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x138(%rsp)
movl %eax, 0x134(%rsp)
leaq 0x98(%rsp), %rdi
callq 0x11ed0
testb $0x1, 0x97(%rsp)
jne 0xf27a
jmp 0xf289
movq 0x10(%rsp), %rdi
movl $0x20, %esi
callq 0x6470
jmp 0xf28b
leaq 0x118(%rsp), %rdi
callq 0x11ed0
jmp 0xf2aa
movq 0x180(%rsp), %rax
addq $0x188, %rsp            # imm = 0x188
retq
movq 0x138(%rsp), %rdi
callq 0x67a0
nopw (%rax,%rax)