// File: /workspace/github_cpp_makefile_star2_O1/kram[P]kram/./src/parser/parser.cpp
// Function: Parser::lookahead(Instruction*, ON)
Instruction* Parser::lookahead(Instruction* prev, ON on) {
	this->advance();

	lexer::Token* next = this->get_token();

	// PushClass
	// IO::Println("123")
	//   ^^
	// IO.Println("123")
	//   ^
	if (on != ON::MATH_NEG) {
		if (next->type == lexer::Type::OPERATOR && (next->sub == lexer::Type::OPERATOR_DOT || next->sub == lexer::Type::OPERATOR_DOUBLE_COLON)) {
			return this->push_class(prev);
		}
	}

	// Call
	// IO::Println("123")
	//            ^
	if (next->type == lexer::Type::OPERATOR && next->sub == lexer::Type::OPERATOR_PAREN_L) {
		return this->call(prev, on);
	}

	// Assignment
	// num := 100
	//     ^^
	if (next->type == lexer::Type::OPERATOR && next->sub == lexer::Type::OPERATOR_COLON_EQ) {
		return this->assign(prev);
	}

	// Set
	// num = 100
	//     ^
	//
	// Parameter with default value
	// fn (a = 100)
	//
	if (next->type == lexer::Type::OPERATOR && next->sub == lexer::Type::OPERATOR_EQ) {
		if (on == ON::FUNCTION_PARAMETER_LIST) {
			return this->function_parameter_with_default_value(prev);
		} else {
			return this->set(prev);
		}
	}

	// Create new variable of type
	// num : Number
	//     ^
	if (next->type == lexer::Type::OPERATOR && next->sub == lexer::Type::OPERATOR_COLON) {
		return this->assign_with_type(prev);
	}

	if (on != ON::MATH_CONTINUATION && on != ON::MATH_NEG) {
		if (next->type == lexer::Type::OPERATOR) {
			if (this->startOperators.find(next->sub) != this->startOperators.end()) {
				return this->math(prev);
			}
		}
	}

	// List extraction
	// li[123]
	//   ^
	if (next->type == lexer::Type::OPERATOR && next->sub == lexer::Type::OPERATOR_SQUARE_PAREN_LEFT) {
		return this->oper_list_extraction(prev);
	}

	this->reverse();

	return prev;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rsi, %rbx
movq %rdi, %r14
cmpb $0x1, 0x20(%rdi)
jne 0xe427
incl 0x18(%r14)
jmp 0xe42c
movb $0x1, 0x20(%r14)
movslq 0x18(%r14), %rax
movq (%r14), %rcx
movq (%rcx,%rax,8), %r15
cmpl $0x2, %edx
je 0xe460
cmpl $0x11, (%r15)
jne 0xe460
movl 0x4(%r15), %eax
cmpl $0x25, %eax
je 0xe450
cmpl $0x14, %eax
jne 0xe460
movq %r14, %rdi
movq %rbx, %rsi
popq %rbx
popq %r14
popq %r15
jmp 0xe568
movl (%r15), %eax
cmpl $0x11, %eax
je 0xe4d1
decl %edx
cmpl $0x2, %edx
jb 0xe4b4
cmpl $0x11, %eax
jne 0xe4b4
leaq 0x60(%r14), %rdi
leaq 0x4(%r15), %rcx
movslq 0x4(%r15), %r8
movq %r8, %rax
xorl %edx, %edx
divq 0x68(%r14)
movq %rdx, %rsi
movq %rcx, %rdx
movq %r8, %rcx
callq 0x118ec
testq %rax, %rax
je 0xe4b4
cmpq $0x0, (%rax)
je 0xe4b4
movq %r14, %rdi
movq %rbx, %rsi
xorl %edx, %edx
popq %rbx
popq %r14
popq %r15
jmp 0xfaf4
cmpl $0x11, (%r15)
jne 0xe4e8
cmpl $0x2e, 0x4(%r15)
jne 0xe4e8
movq %r14, %rdi
movq %rbx, %rsi
popq %rbx
popq %r14
popq %r15
jmp 0xf02c
cmpl $0x26, 0x4(%r15)
jne 0xe4f5
movq %r14, %rdi
movq %rbx, %rsi
popq %rbx
popq %r14
popq %r15
jmp 0xe6b8
decl 0x18(%r14)
movq %rbx, %rax
popq %rbx
popq %r14
popq %r15
retq
cmpl $0x11, %eax
jne 0xe468
cmpl $0x2a, 0x4(%r15)
jne 0xe515
movq %r14, %rdi
movq %rbx, %rsi
popq %rbx
popq %r14
popq %r15
jmp 0xe9de
cmpl $0x11, %eax
jne 0xe468
cmpl $0x16, 0x4(%r15)
jne 0xe537
movq %r14, %rdi
cmpl $0x4, %edx
jne 0xe55b
movq %rbx, %rsi
callq 0xeac6
jmp 0xe4ec
cmpl $0x11, %eax
jne 0xe468
cmpl $0x13, 0x4(%r15)
jne 0xe468
movq %r14, %rdi
movq %rbx, %rsi
popq %rbx
popq %r14
popq %r15
jmp 0xede0
movq %rbx, %rsi
popq %rbx
popq %r14
popq %r15
jmp 0xecf8