// File: AndrewAlbert[P]Compiler-Theory/SourceCode/parser.cpp
// Function: Parser::Parser(token_type*, Scanner*, scopeTracker*, codeGenerator*)
Parser::Parser(token_type* tokenPtr, Scanner* scannerPtr, scopeTracker* scopes, codeGenerator* genPtr){
	//Set default values needed to begin parsing and attach other compiler classes to their pointers
	token = tokenPtr;
	Scopes = scopes;
	scanner = scannerPtr;
	generator = genPtr;
	textLine = "";
	currentLine = 0;
	warning = false;
	error = false;
	lineError = false;
	outArg = false;
	
	//Start program parsing
	Program();
	
	// Ensure the end of the file is reached
	if(token->type != T_EOF) ReportWarning("Tokens remaining. Parsing stopped at 'end program' and will not include any tokens after that.");
	
	// Display all errors / warnings
	DisplayErrorQueue();
	
	if(error) cout << "\nParser completed with some errors.\n   Code cannot be generated.\n" << endl;
	else if(warning) cout << "\nParser completed with some warnings.\n\tCode can still be generated.\n" << endl;
	else cout << "\nParser completed with no errors or warnings.\n\tCode has been generated.\n" << endl;

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x70(%rbp)
movq %rdi, %rax
movq %rax, -0x78(%rbp)
callq 0x12260
movq -0x70(%rbp), %rdi
addq $0x58, %rdi
movq %rdi, -0x68(%rbp)
callq 0x3370
movq -0x70(%rbp), %rax
movq -0x68(%rbp), %rdi
movq -0x10(%rbp), %rcx
movq %rcx, 0x80(%rax)
movq -0x20(%rbp), %rcx
movq %rcx, 0x90(%rax)
movq -0x18(%rbp), %rcx
movq %rcx, 0x88(%rax)
movq -0x28(%rbp), %rcx
movq %rcx, 0x98(%rax)
leaq 0x1ec02(%rip), %rsi     # 0x26c81
callq 0x3360
jmp 0x8086
movq -0x78(%rbp), %rdi
movl $0x0, 0x78(%rdi)
movb $0x0, 0x50(%rdi)
movb $0x0, 0x51(%rdi)
movb $0x0, 0x52(%rdi)
movb $0x0, 0x7c(%rdi)
callq 0x8230
jmp 0x80a8
movq -0x78(%rbp), %rax
movq 0x80(%rax), %rax
cmpl $0x15d, 0x20(%rax)      # imm = 0x15D
je 0x8148
leaq -0x59(%rbp), %rdi
movq %rdi, -0x80(%rbp)
callq 0x3430
movq -0x80(%rbp), %rdx
leaq 0x1d2e0(%rip), %rsi     # 0x253b8
leaq -0x58(%rbp), %rdi
callq 0x62d0
jmp 0x80e3
movq -0x78(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x8510
jmp 0x80f2
leaq -0x58(%rbp), %rdi
callq 0x31a0
leaq -0x59(%rbp), %rdi
callq 0x32e0
jmp 0x8148
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x820b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x813a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x31a0
leaq -0x59(%rbp), %rdi
callq 0x32e0
jmp 0x820b
movq -0x78(%rbp), %rdi
callq 0x87a0
jmp 0x8153
movq -0x78(%rbp), %rax
testb $0x1, 0x51(%rax)
je 0x8190
movq 0x2ae6c(%rip), %rdi     # 0x32fd0
leaq 0x1d2ac(%rip), %rsi     # 0x25417
callq 0x3270
movq %rax, -0x88(%rbp)
jmp 0x8179
movq -0x88(%rbp), %rdi
movq 0x2ae31(%rip), %rsi     # 0x32fb8
callq 0x32c0
jmp 0x818e
jmp 0x8202
movq -0x78(%rbp), %rax
testb $0x1, 0x50(%rax)
je 0x81cd
movq 0x2ae2f(%rip), %rdi     # 0x32fd0
leaq 0x1d2b1(%rip), %rsi     # 0x25459
callq 0x3270
movq %rax, -0x90(%rbp)
jmp 0x81b6
movq -0x90(%rbp), %rdi
movq 0x2adf4(%rip), %rsi     # 0x32fb8
callq 0x32c0
jmp 0x81cb
jmp 0x8200
movq 0x2adfc(%rip), %rdi     # 0x32fd0
leaq 0x1d2c3(%rip), %rsi     # 0x2549e
callq 0x3270
movq %rax, -0x98(%rbp)
jmp 0x81e9
movq -0x98(%rbp), %rdi
movq 0x2adc1(%rip), %rsi     # 0x32fb8
callq 0x32c0
jmp 0x81fe
jmp 0x8200
jmp 0x8202
addq $0xa0, %rsp
popq %rbp
retq
movq -0x68(%rbp), %rdi
callq 0x31a0
movq -0x70(%rbp), %rdi
callq 0x12290
movq -0x30(%rbp), %rdi
callq 0x3420
nopw %cs:(%rax,%rax)