// File: kram[P]kram/./src/parser/parser.cpp
// Function: Parser::Parser(std::vector<lexer::Token*, std::allocator<lexer::Token*>>)
Parser::Parser(std::vector<lexer::Token*> tokens) {

	// Initialize variables
	this->tokens = tokens;
	this->lenght = tokens.size();
	this->index = 0;
	this->has_advanced = false;

	// Hashmap of comparisions
	this->comparisions[lexer::Type::OPERATOR_EQEQ] = true;
	this->comparisions[lexer::Type::OPERATOR_GT] = true;
	this->comparisions[lexer::Type::OPERATOR_GTEQ] = true;
	this->comparisions[lexer::Type::OPERATOR_LT] = true;
	this->comparisions[lexer::Type::OPERATOR_LTEQ] = true;
	this->comparisions[lexer::Type::OPERATOR_DOUBLE_AND] = true;
	this->comparisions[lexer::Type::OPERATOR_DOUBLE_OR] = true;
	this->comparisions[lexer::Type::OPERATOR_NOT_EQ] = true;

	// 123++
	this->leftOnlyInfix[lexer::Type::OPERATOR_PLUS_PLUS] = true;
	this->leftOnlyInfix[lexer::Type::OPERATOR_MINUS_MINUS] = true;

	// -123
	this->rightOnlyInfix[lexer::Type::OPERATOR_MINUS] = true;

	// List of all operators starting a new sub-expression
	this->startOperators[lexer::Type::OPERATOR_EQEQ] = true;
	this->startOperators[lexer::Type::OPERATOR_GT] = true;
	this->startOperators[lexer::Type::OPERATOR_GTEQ] = true;
	this->startOperators[lexer::Type::OPERATOR_LT] = true;
	this->startOperators[lexer::Type::OPERATOR_LTEQ] = true;
	this->startOperators[lexer::Type::OPERATOR_DOUBLE_AND] = true;
	this->startOperators[lexer::Type::OPERATOR_DOUBLE_OR] = true;
	this->startOperators[lexer::Type::OPERATOR_PLUS_PLUS] = true;
	this->startOperators[lexer::Type::OPERATOR_MINUS_MINUS] = true;
	this->startOperators[lexer::Type::OPERATOR_MINUS] = true;
	this->startOperators[lexer::Type::OPERATOR_PLUS] = true;
	this->startOperators[lexer::Type::OPERATOR_MUL] = true;
	this->startOperators[lexer::Type::OPERATOR_DIV] = true;
	this->startOperators[lexer::Type::OPERATOR_PAREN_L] = true;
	this->startOperators[lexer::Type::OPERATOR_EQ] = true;
	this->startOperators[lexer::Type::OPERATOR_2DOT] = true;
	this->startOperators[lexer::Type::OPERATOR_3DOT] = true;
	this->startOperators[lexer::Type::OPERATOR_NOT_EQ] = true;
}

// Assembly:
subq $0x1b8, %rsp            # imm = 0x1B8
movq %rsi, 0x120(%rsp)
movq %rdi, 0x1b0(%rsp)
movq %rsi, 0x1a8(%rsp)
movq 0x1b0(%rsp), %rdi
movq %rdi, 0x118(%rsp)
movq %rdi, %rax
movq %rax, 0xf0(%rsp)
callq 0x8f80
movq 0x118(%rsp), %rdi
addq $0x28, %rdi
movq %rdi, 0xf8(%rsp)
callq 0x26640
movq 0x118(%rsp), %rdi
addq $0x60, %rdi
movq %rdi, 0x100(%rsp)
callq 0x26640
movq 0x118(%rsp), %rdi
addq $0x98, %rdi
movq %rdi, 0x108(%rsp)
callq 0x26640
movq 0x118(%rsp), %rdi
addq $0xd0, %rdi
movq %rdi, 0x110(%rsp)
callq 0x26640
movq 0x118(%rsp), %rdi
movq 0x120(%rsp), %rsi
callq 0x26650
jmp 0x20270
movq 0x120(%rsp), %rdi
callq 0x6910
movq 0xf0(%rsp), %rdi
movl %eax, 0x1c(%rdi)
movl $0x0, 0x18(%rdi)
movb $0x0, 0x20(%rdi)
addq $0x28, %rdi
movl $0x18, 0x198(%rsp)
leaq 0x198(%rsp), %rsi
callq 0x26910
movq %rax, 0xe8(%rsp)
jmp 0x202b9
movq 0xf0(%rsp), %rdi
movq 0xe8(%rsp), %rax
movb $0x1, (%rax)
addq $0x28, %rdi
movl $0x19, 0x194(%rsp)
leaq 0x194(%rsp), %rsi
callq 0x26910
movq %rax, 0xe0(%rsp)
jmp 0x202f2
movq 0xf0(%rsp), %rdi
movq 0xe0(%rsp), %rax
movb $0x1, (%rax)
addq $0x28, %rdi
movl $0x1a, 0x190(%rsp)
leaq 0x190(%rsp), %rsi
callq 0x26910
movq %rax, 0xd8(%rsp)
jmp 0x2032b
movq 0xf0(%rsp), %rdi
movq 0xd8(%rsp), %rax
movb $0x1, (%rax)
addq $0x28, %rdi
movl $0x1b, 0x18c(%rsp)
leaq 0x18c(%rsp), %rsi
callq 0x26910
movq %rax, 0xd0(%rsp)
jmp 0x20364
movq 0xf0(%rsp), %rdi
movq 0xd0(%rsp), %rax
movb $0x1, (%rax)
addq $0x28, %rdi
movl $0x1c, 0x188(%rsp)
leaq 0x188(%rsp), %rsi
callq 0x26910
movq %rax, 0xc8(%rsp)
jmp 0x2039d
movq 0xf0(%rsp), %rdi
movq 0xc8(%rsp), %rax
movb $0x1, (%rax)
addq $0x28, %rdi
movl $0x1d, 0x184(%rsp)
leaq 0x184(%rsp), %rsi
callq 0x26910
movq %rax, 0xc0(%rsp)
jmp 0x203d6
movq 0xf0(%rsp), %rdi
movq 0xc0(%rsp), %rax
movb $0x1, (%rax)
addq $0x28, %rdi
movl $0x1e, 0x180(%rsp)
leaq 0x180(%rsp), %rsi
callq 0x26910
movq %rax, 0xb8(%rsp)
jmp 0x2040f
movq 0xf0(%rsp), %rdi
movq 0xb8(%rsp), %rax
movb $0x1, (%rax)
addq $0x28, %rdi
movl $0x17, 0x17c(%rsp)
leaq 0x17c(%rsp), %rsi
callq 0x26910
movq %rax, 0xb0(%rsp)
jmp 0x20448
movq 0xf0(%rsp), %rdi
movq 0xb0(%rsp), %rax
movb $0x1, (%rax)
addq $0x98, %rdi
movl $0x1f, 0x178(%rsp)
leaq 0x178(%rsp), %rsi
callq 0x26910
movq %rax, 0xa8(%rsp)
jmp 0x20484
movq 0xf0(%rsp), %rdi
movq 0xa8(%rsp), %rax
movb $0x1, (%rax)
addq $0x98, %rdi
movl $0x20, 0x174(%rsp)
leaq 0x174(%rsp), %rsi
callq 0x26910
movq %rax, 0xa0(%rsp)
jmp 0x204c0
movq 0xf0(%rsp), %rdi
movq 0xa0(%rsp), %rax
movb $0x1, (%rax)
addq $0xd0, %rdi
movl $0x22, 0x170(%rsp)
leaq 0x170(%rsp), %rsi
callq 0x26910
movq %rax, 0x98(%rsp)
jmp 0x204fc
movq 0xf0(%rsp), %rdi
movq 0x98(%rsp), %rax
movb $0x1, (%rax)
addq $0x60, %rdi
movl $0x18, 0x16c(%rsp)
leaq 0x16c(%rsp), %rsi
callq 0x26910
movq %rax, 0x90(%rsp)
jmp 0x20535
movq 0xf0(%rsp), %rdi
movq 0x90(%rsp), %rax
movb $0x1, (%rax)
addq $0x60, %rdi
movl $0x19, 0x168(%rsp)
leaq 0x168(%rsp), %rsi
callq 0x26910
movq %rax, 0x88(%rsp)
jmp 0x2056e
movq 0xf0(%rsp), %rdi
movq 0x88(%rsp), %rax
movb $0x1, (%rax)
addq $0x60, %rdi
movl $0x1a, 0x164(%rsp)
leaq 0x164(%rsp), %rsi
callq 0x26910
movq %rax, 0x80(%rsp)
jmp 0x205a7
movq 0xf0(%rsp), %rdi
movq 0x80(%rsp), %rax
movb $0x1, (%rax)
addq $0x60, %rdi
movl $0x1b, 0x160(%rsp)
leaq 0x160(%rsp), %rsi
callq 0x26910
movq %rax, 0x78(%rsp)
jmp 0x205dd
movq 0xf0(%rsp), %rdi
movq 0x78(%rsp), %rax
movb $0x1, (%rax)
addq $0x60, %rdi
movl $0x1c, 0x15c(%rsp)
leaq 0x15c(%rsp), %rsi
callq 0x26910
movq %rax, 0x70(%rsp)
jmp 0x20610
movq 0xf0(%rsp), %rdi
movq 0x70(%rsp), %rax
movb $0x1, (%rax)
addq $0x60, %rdi
movl $0x1d, 0x158(%rsp)
leaq 0x158(%rsp), %rsi
callq 0x26910
movq %rax, 0x68(%rsp)
jmp 0x20643
movq 0xf0(%rsp), %rdi
movq 0x68(%rsp), %rax
movb $0x1, (%rax)
addq $0x60, %rdi
movl $0x1e, 0x154(%rsp)
leaq 0x154(%rsp), %rsi
callq 0x26910
movq %rax, 0x60(%rsp)
jmp 0x20676
movq 0xf0(%rsp), %rdi
movq 0x60(%rsp), %rax
movb $0x1, (%rax)
addq $0x60, %rdi
movl $0x1f, 0x150(%rsp)
leaq 0x150(%rsp), %rsi
callq 0x26910
movq %rax, 0x58(%rsp)
jmp 0x206a9
movq 0xf0(%rsp), %rdi
movq 0x58(%rsp), %rax
movb $0x1, (%rax)
addq $0x60, %rdi
movl $0x20, 0x14c(%rsp)
leaq 0x14c(%rsp), %rsi
callq 0x26910
movq %rax, 0x50(%rsp)
jmp 0x206dc
movq 0xf0(%rsp), %rdi
movq 0x50(%rsp), %rax
movb $0x1, (%rax)
addq $0x60, %rdi
movl $0x22, 0x148(%rsp)
leaq 0x148(%rsp), %rsi
callq 0x26910
movq %rax, 0x48(%rsp)
jmp 0x2070f
movq 0xf0(%rsp), %rdi
movq 0x48(%rsp), %rax
movb $0x1, (%rax)
addq $0x60, %rdi
movl $0x21, 0x144(%rsp)
leaq 0x144(%rsp), %rsi
callq 0x26910
movq %rax, 0x40(%rsp)
jmp 0x20742
movq 0xf0(%rsp), %rdi
movq 0x40(%rsp), %rax
movb $0x1, (%rax)
addq $0x60, %rdi
movl $0x23, 0x140(%rsp)
leaq 0x140(%rsp), %rsi
callq 0x26910
movq %rax, 0x38(%rsp)
jmp 0x20775
movq 0xf0(%rsp), %rdi
movq 0x38(%rsp), %rax
movb $0x1, (%rax)
addq $0x60, %rdi
movl $0x24, 0x13c(%rsp)
leaq 0x13c(%rsp), %rsi
callq 0x26910
movq %rax, 0x30(%rsp)
jmp 0x207a8
movq 0xf0(%rsp), %rdi
movq 0x30(%rsp), %rax
movb $0x1, (%rax)
addq $0x60, %rdi
movl $0x26, 0x138(%rsp)
leaq 0x138(%rsp), %rsi
callq 0x26910
movq %rax, 0x28(%rsp)
jmp 0x207db
movq 0xf0(%rsp), %rdi
movq 0x28(%rsp), %rax
movb $0x1, (%rax)
addq $0x60, %rdi
movl $0x16, 0x134(%rsp)
leaq 0x134(%rsp), %rsi
callq 0x26910
movq %rax, 0x20(%rsp)
jmp 0x2080e
movq 0xf0(%rsp), %rdi
movq 0x20(%rsp), %rax
movb $0x1, (%rax)
addq $0x60, %rdi
movl $0x2c, 0x130(%rsp)
leaq 0x130(%rsp), %rsi
callq 0x26910
movq %rax, 0x18(%rsp)
jmp 0x20841
movq 0xf0(%rsp), %rdi
movq 0x18(%rsp), %rax
movb $0x1, (%rax)
addq $0x60, %rdi
movl $0x2d, 0x12c(%rsp)
leaq 0x12c(%rsp), %rsi
callq 0x26910
movq %rax, 0x10(%rsp)
jmp 0x20874
movq 0xf0(%rsp), %rdi
movq 0x10(%rsp), %rax
movb $0x1, (%rax)
addq $0x60, %rdi
movl $0x17, 0x128(%rsp)
leaq 0x128(%rsp), %rsi
callq 0x26910
movq %rax, 0x8(%rsp)
jmp 0x208a7
movq 0x8(%rsp), %rax
movb $0x1, (%rax)
addq $0x1b8, %rsp            # imm = 0x1B8
retq
movq 0x110(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1a0(%rsp)
movl %eax, 0x19c(%rsp)
callq 0x5c40
movq 0x108(%rsp), %rdi
callq 0x5c40
movq 0x100(%rsp), %rdi
callq 0x5c40
movq 0xf8(%rsp), %rdi
callq 0x5c40
movq 0x118(%rsp), %rdi
callq 0x41e0
movq 0x1a0(%rsp), %rdi
callq 0x3490
nopl (%rax)