// File: /workspace/github_cpp_makefile_star2_O2/iamlouk[P]asbi/src/parser.cc
// Function: asbi::Parser::parse_factor()
ast::Node* Parser::parse_factor() {
	auto node = parse_final();
	auto t = tokenizer.peek().type;
	while (t == tok::LeftBracket || t == tok::Dot || t == tok::Colon || t == tok::DoubleColon) {
		tokenizer.next();
		if (t == tok::LeftBracket) {
			std::vector<ast::Node*> args;
			parse_arglist(args);
			node = new ast::Call(node, args);
		} else if (t == tok::Colon) {
			auto token = tokenizer.next();
			if (token.type != tok::Identifier)
				throw utils::parser_error("expected identifier/symbol after ':'", token);

			node = new ast::Access(node, new ast::Symbol(ctx->new_stringconstant(*token.str)));
			delete token.str;
		} else if (t == tok::DoubleColon) {
			/*auto token = tokenizer.next();
			if (token.type != tok::Identifier)
				throw utils::parser_error("expected identifier/symbol after '::'", token);

			auto acs = new ast::Access(node, new ast::Symbol(token.str));
			expect(tok::LeftBracket);
			std::vector<ast::Node*> args;
			parse_arglist(args);
			node = new ast::OOCall(acs, args);*/
			throw std::runtime_error("unimplemented");
		} else {
			node = new ast::Access(node, parse_final());
		}
		t = tokenizer.peek().type;
	}
	return node;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rdi, %rbx
callq 0x87fe
movq %rax, 0x8(%rsp)
movq %rbx, %rdi
callq 0x668a
movq %rax, %r13
movabsq $0x380800000, %r14      # imm = 0x380800000
leaq 0x20(%rsp), %r12
leaq 0x40(%rsp), %r15
leaq 0x1734f(%rip), %rax     # 0x1f910
addq $0x10, %rax
movq %rax, 0x18(%rsp)
leaq 0x170b7(%rip), %rax     # 0x1f688
addq $0x10, %rax
movq %rax, 0x10(%rsp)
cmpl $0x21, %r13d
ja 0x8725
movl %r13d, %eax
btq %rax, %r14
jae 0x8725
movq %rbx, %rdi
callq 0x66b4
cmpl $0x17, %r13d
je 0x86c1
cmpl $0x1f, %r13d
je 0x8641
cmpl $0x21, %r13d
je 0x8739
pushq $0x18
popq %rdi
callq 0x5390
movq %rax, %rbp
movq %rbx, %rdi
callq 0x87fe
movq 0x10(%rsp), %rcx
movq %rcx, (%rbp)
movq 0x8(%rsp), %rcx
movq %rcx, 0x8(%rbp)
movq %rax, 0x10(%rbp)
jmp 0x8710
movq %rbx, %rdi
movq %r12, %r15
movq %r14, %r12
callq 0x66b4
movq %rax, %rbp
movq %rdx, %r13
testl %ebp, %ebp
jne 0x8763
pushq $0x18
popq %rdi
callq 0x5390
movq %rax, %rbp
pushq $0x10
popq %rdi
callq 0x5390
movq %rax, %r14
movq 0x30(%rbx), %rdi
movq %r13, %rsi
callq 0xec64
movq 0x18(%rsp), %rcx
movq %rcx, (%r14)
movq %rax, 0x8(%r14)
movq 0x10(%rsp), %rax
movq %rax, (%rbp)
movq 0x8(%rsp), %rax
movq %rax, 0x8(%rbp)
movq %r14, 0x10(%rbp)
movq %r13, %rdi
callq 0x5170
movq %r13, %rdi
pushq $0x20
popq %rsi
callq 0x53a0
movq %r12, %r14
movq %r15, %r12
leaq 0x40(%rsp), %r15
jmp 0x8710
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rsp)
andq $0x0, 0x30(%rsp)
movq %rbx, %rdi
movq %r12, %rsi
callq 0x8e96
pushq $0x28
popq %rdi
callq 0x5390
movq %rax, %rbp
movq %r15, %rdi
movq %r12, %rsi
callq 0x9318
movq %rbp, %rdi
movq 0x8(%rsp), %rsi
movq %r15, %rdx
callq 0x93c4
movq %r15, %rdi
callq 0x9768
movq %r12, %rdi
callq 0x9768
movq %rbx, %rdi
callq 0x668a
movq %rax, %r13
movq %rbp, 0x8(%rsp)
jmp 0x85da
movq 0x8(%rsp), %rax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
pushq $0x10
popq %rdi
callq 0x51b0
movq %rax, %r14
leaq 0xc0da(%rip), %rsi      # 0x14825
movq %rax, %rdi
callq 0x5120
movq 0x17896(%rip), %rsi     # 0x1fff0
movq 0x17847(%rip), %rdx     # 0x1ffa8
jmp 0x8791
pushq $0x48
popq %rdi
callq 0x51b0
movq %rax, %r14
leaq 0xc03f(%rip), %rsi      # 0x147b4
movq %rax, %rdi
movq %rbp, %rdx
movq %r13, %rcx
callq 0x9e26
leaq 0x16de6(%rip), %rsi     # 0x1f570
leaq 0xb67(%rip), %rdx       # 0x92f8
movq %r14, %rdi
callq 0x55f0
jmp 0x879b
movq %rax, %rbx
movq %r14, %rdi
callq 0x5290
jmp 0x87f6
jmp 0x87aa
movq %rax, %rbx
jmp 0x87dc
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
callq 0x9768
jmp 0x87c1
movq %rax, %rbx
pushq $0x28
popq %rsi
movq %rbp, %rdi
callq 0x53a0
jmp 0x87ec
movq %rax, %rbx
pushq $0x10
popq %rsi
movq %r14, %rdi
callq 0x53a0
pushq $0x18
popq %rsi
movq %rbp, %rdi
callq 0x53a0
jmp 0x87f6
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x9768
movq %rbx, %rdi
callq 0x5600