// File: /workspace/github_cpp_makefile_star2_O2/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 0xcea9
movl 0x18(%r14), %eax
incl %eax
movl %eax, 0x18(%r14)
jmp 0xceb2
movb $0x1, 0x20(%r14)
movl 0x18(%r14), %eax
cltq
movq (%r14), %rcx
movq (%rcx,%rax,8), %r15
movl (%r15), %eax
cmpl $0x2, %edx
jne 0xced2
cmpl $0x11, %eax
jne 0xcfa3
movl 0x4(%r15), %eax
jmp 0xcef9
cmpl $0x11, %eax
jne 0xcfa3
movl 0x4(%r15), %eax
cmpl $0x25, %eax
je 0xcee9
cmpl $0x14, %eax
jne 0xcef9
movq %r14, %rdi
movq %rbx, %rsi
popq %rbx
popq %r14
popq %r15
jmp 0xcfb0
cmpl $0x13, %eax
je 0xcf3f
cmpl $0x16, %eax
je 0xcf1d
cmpl $0x2a, %eax
je 0xcf2f
cmpl $0x26, %eax
jne 0xcf4f
movq %r14, %rdi
movq %rbx, %rsi
popq %rbx
popq %r14
popq %r15
jmp 0xd0a2
movq %r14, %rdi
cmpl $0x4, %edx
jne 0xcf79
movq %rbx, %rsi
callq 0xd3e0
jmp 0xcfa7
movq %r14, %rdi
movq %rbx, %rsi
popq %rbx
popq %r14
popq %r15
jmp 0xd32c
movq %r14, %rdi
movq %rbx, %rsi
popq %rbx
popq %r14
popq %r15
jmp 0xd65a
addl $-0x3, %edx
cmpl $-0x3, %edx
ja 0xcf8c
leaq 0x4(%r15), %rsi
leaq 0x60(%r14), %rdi
callq 0x1012a
testq %rax, %rax
je 0xcf86
movq %r14, %rdi
movq %rbx, %rsi
popq %rbx
popq %r14
popq %r15
jmp 0xd82e
movq %rbx, %rsi
popq %rbx
popq %r14
popq %r15
jmp 0xd5a4
cmpl $0x11, (%r15)
jne 0xcfa3
cmpl $0x2e, 0x4(%r15)
jne 0xcfa3
movq %r14, %rdi
movq %rbx, %rsi
popq %rbx
popq %r14
popq %r15
jmp 0xd836
decl 0x18(%r14)
movq %rbx, %rax
popq %rbx
popq %r14
popq %r15
retq