// File: /workspace/github_cpp_makefile_star2_O3/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %r8, %r15
movq %rcx, %r12
movq %rdx, %r13
movq %rsi, %rbp
movq %rdi, %rbx
xorps %xmm0, %xmm0
movups %xmm0, 0x40(%rdi)
movups %xmm0, 0x30(%rdi)
movups %xmm0, 0x20(%rdi)
movups %xmm0, 0x10(%rdi)
movups %xmm0, (%rdi)
xorl %esi, %esi
callq 0xe1b6
leaq 0x58(%rbx), %r14
leaq 0x68(%rbx), %rax
movq %rax, (%rsp)
movq %rax, 0x58(%rbx)
movq $0x0, 0x60(%rbx)
movb $0x0, 0x68(%rbx)
movq %rbp, 0x80(%rbx)
movq %r12, 0x90(%rbx)
movq %r13, 0x88(%rbx)
movq %r15, 0x98(%rbx)
leaq 0x168a0(%rip), %rcx     # 0x1a95d
movq %r14, %rdi
xorl %esi, %esi
xorl %edx, %edx
xorl %r8d, %r8d
callq 0x22e0
movl $0x0, 0x78(%rbx)
movw $0x0, 0x50(%rbx)
xorl %eax, %eax
movb %al, 0x52(%rbx)
movb %al, 0x7c(%rbx)
movq %rbx, %rdi
callq 0x4218
movq 0x80(%rbx), %rax
cmpl $0x15d, 0x20(%rax)      # imm = 0x15D
je 0x413f
leaq 0x18(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x15046(%rip), %rsi     # 0x19150
leaq 0x1509d(%rip), %rdx     # 0x191ae
leaq 0x8(%rsp), %rdi
callq 0x3c42
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0x4388
movq 0x8(%rsp), %rdi
cmpq %r12, %rdi
je 0x413f
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x2200
movq %rbx, %rdi
callq 0x48f0
movb 0x50(%rbx), %al
leaq 0x150a0(%rip), %rcx     # 0x191f1
leaq 0x150de(%rip), %rdx     # 0x19236
testb $0x1, %al
cmovneq %rcx, %rdx
notb %al
movzbl %al, %eax
andl $0x1, %eax
leaq 0x15042(%rip), %rsi     # 0x191af
cmpb $0x0, 0x51(%rbx)
cmoveq %rdx, %rsi
leaq 0x44(,%rax,4), %rax
movl $0x41, %edx
cmoveq %rax, %rdx
movq 0x1de4b(%rip), %r15     # 0x21fd8
movq %r15, %rdi
callq 0x2230
movq (%r15), %rax
addq -0x18(%rax), %r15
movq %r15, %rdi
movl $0xa, %esi
callq 0x21d0
movsbl %al, %esi
movq 0x1de25(%rip), %rdi     # 0x21fd8
callq 0x2030
movq %rax, %rdi
callq 0x2140
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r15
movq 0x8(%rsp), %rdi
cmpq %r12, %rdi
je 0x41f0
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x2200
jmp 0x41f0
jmp 0x41ed
movq %rax, %r15
movq (%r14), %rdi
cmpq (%rsp), %rdi
je 0x4208
movq (%rsp), %rax
movq (%rax), %rsi
incq %rsi
callq 0x2200
movq %rbx, %rdi
callq 0xddd4
movq %r15, %rdi
callq 0x2330