// File: /workspace/github_cpp_makefile_star2_O2/AndrewAlbert[P]Compiler-Theory/SourceCode/parser.cpp
// Function: Parser::ReportLineError(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, bool)
void Parser::ReportLineError(string message, bool skipSemicolon = true){
	generator->stopCodeGeneration();
	error = true;
	lineError = true;
	
	// Use a '^' under the error text line to indicate where the error was encountered
	int error_location = textLine.size();
	string error_callout = "";
	while(error_location > 0){
		error_location--;
		error_callout.append(" ");
	}
	error_callout.append("^");

	// Get the rest of the line of tokens ( looks for newline or a semicolon )
	bool getNext = true;
	while(getNext){
		textLine.append(" " + token->ascii);
		// attempt to resync for structure keywords
		if(skipSemicolon){
			if( token->type == T_SEMICOLON){
				*token = scanner->getToken();
				getNext = false;
			}
		}
		switch(token->type){
			case T_SEMICOLON: case T_BEGIN: case T_END: case T_PROCEDURE: case T_THEN: case T_ELSE: case T_FOR:
				getNext = false;
				break;
			default:
				break;
		}
		if(token->line != currentLine) getNext = false;
		if(getNext) *token = scanner->getToken();
	}
	error_queue.push("Line Error: line - " + to_string(currentLine) + "\n\t" + message +"\n\tFound: " + textLine + "\n\t       " + error_callout);
	textLine = "";
	currentLine = token->line;
	return;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x238, %rsp            # imm = 0x238
movl %edx, %ebp
movq %rsi, %r15
movq %rdi, %rbx
movq 0x98(%rdi), %rdi
callq 0xbb62
movw $0x101, 0x51(%rbx)      # imm = 0x101
leaq 0x58(%rbx), %rax
movq %rax, (%rsp)
movl 0x60(%rbx), %r14d
leaq 0xe4b3(%rip), %rsi      # 0x1293d
leaq 0x10(%rsp), %r12
leaq 0x110(%rsp), %rdx
movq %r12, %rdi
callq 0x36b8
incl %r14d
leaq 0xce13(%rip), %r13      # 0x112bc
decl %r14d
testl %r14d, %r14d
jle 0x44be
movq %r12, %rdi
movq %r13, %rsi
callq 0x2360
jmp 0x44a9
movq %r15, 0x8(%rsp)
leaq 0xcdd4(%rip), %rsi      # 0x1129e
leaq 0x10(%rsp), %rdi
callq 0x2360
movb $0x1, %r12b
leaq 0x110(%rsp), %r13
movl $0xfffffefd, %r15d      # imm = 0xFFFFFEFD
xorl %r14d, %r14d
testb $0x1, %r12b
je 0x45c2
movq 0x80(%rbx), %rdx
movq %r13, %rdi
leaq 0xcdb9(%rip), %rsi      # 0x112bc
callq 0x970c
movq (%rsp), %rdi
movq %r13, %rsi
callq 0x2390
movq %r13, %rdi
callq 0x20f0
movq 0x80(%rbx), %rax
testb %bpl, %bpl
je 0x4561
cmpl $0x12c, 0x20(%rax)      # imm = 0x12C
jne 0x4561
movq 0x88(%rbx), %rsi
movq %r13, %rdi
callq 0x2f1e
movq 0x80(%rbx), %rdi
movq %r13, %rsi
callq 0x9782
movq %r13, %rdi
callq 0x20f0
movq 0x80(%rbx), %rax
xorl %r12d, %r12d
movl 0x20(%rax), %ecx
addl %r15d, %ecx
cmpl $0x29, %ecx
ja 0x457f
movabsq $0x2000001c00b, %rdx    # imm = 0x2000001C00B
btq %rcx, %rdx
jae 0x457f
xorl %r12d, %r12d
movl 0x24(%rax), %eax
cmpl 0x78(%rbx), %eax
movzbl %r12b, %r12d
cmovnel %r14d, %r12d
testb $0x1, %r12b
je 0x44e8
movq 0x88(%rbx), %rsi
movq %r13, %rdi
callq 0x2f1e
movq 0x80(%rbx), %rdi
movq %r13, %rsi
callq 0x9782
movq %r13, %rdi
callq 0x20f0
jmp 0x44e8
movl 0x78(%rbx), %esi
leaq 0x30(%rsp), %rdi
callq 0x96b3
leaq 0xccca(%rip), %rsi      # 0x112a0
leaq 0x50(%rsp), %rdi
leaq 0x30(%rsp), %rdx
callq 0x968f
movq 0x8(%rsp), %r14
leaq 0xe34a(%rip), %rdx      # 0x1293b
leaq 0x70(%rsp), %rdi
leaq 0x50(%rsp), %rsi
callq 0x9670
leaq 0x90(%rsp), %rdi
leaq 0x70(%rsp), %rsi
movq %r14, %rdx
callq 0x9651
leaq 0xcc78(%rip), %rdx      # 0x11294
leaq 0xb0(%rsp), %rdi
leaq 0x90(%rsp), %rsi
callq 0x9670
leaq 0xd0(%rsp), %rdi
leaq 0xb0(%rsp), %rsi
movq (%rsp), %rdx
callq 0x9651
leaq 0xcc63(%rip), %rdx      # 0x112b4
leaq 0xf0(%rsp), %rdi
leaq 0xd0(%rsp), %rsi
callq 0x9670
leaq 0x110(%rsp), %rdi
leaq 0xf0(%rsp), %rsi
leaq 0x10(%rsp), %rdx
callq 0x9651
leaq 0x110(%rsp), %rsi
movq %rbx, %rdi
callq 0x9e7a
leaq 0x110(%rsp), %rdi
callq 0x20f0
leaq 0xf0(%rsp), %rdi
callq 0x20f0
leaq 0xd0(%rsp), %rdi
callq 0x20f0
leaq 0xb0(%rsp), %rdi
callq 0x20f0
leaq 0x90(%rsp), %rdi
callq 0x20f0
leaq 0x70(%rsp), %rdi
callq 0x20f0
leaq 0x50(%rsp), %rdi
callq 0x20f0
leaq 0x30(%rsp), %rdi
callq 0x20f0
leaq 0xe247(%rip), %rsi      # 0x1293d
movq (%rsp), %rdi
callq 0x2370
movq 0x80(%rbx), %rax
movl 0x24(%rax), %eax
movl %eax, 0x78(%rbx)
leaq 0x10(%rsp), %rdi
callq 0x20f0
addq $0x238, %rsp            # imm = 0x238
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x47cb
movq %rax, %rbx
leaq 0x110(%rsp), %rdi
callq 0x20f0
jmp 0x4742
movq %rax, %rbx
leaq 0xf0(%rsp), %rdi
callq 0x20f0
jmp 0x4754
movq %rax, %rbx
leaq 0xd0(%rsp), %rdi
callq 0x20f0
jmp 0x4766
movq %rax, %rbx
leaq 0xb0(%rsp), %rdi
callq 0x20f0
jmp 0x4778
movq %rax, %rbx
leaq 0x90(%rsp), %rdi
callq 0x20f0
leaq 0x70(%rsp), %rdi
callq 0x20f0
leaq 0x50(%rsp), %rdi
callq 0x20f0
leaq 0x30(%rsp), %rdi
jmp 0x47c2
movq %rax, %rbx
jmp 0x4785
movq %rax, %rbx
jmp 0x478f
movq %rax, %rbx
jmp 0x4799
jmp 0x47cb
jmp 0x47cb
jmp 0x47cb
jmp 0x47cb
movq %rax, %rbx
leaq 0x110(%rsp), %rdi
callq 0x20f0
jmp 0x47ce
jmp 0x47cb
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x20f0
movq %rbx, %rdi
callq 0x2310