// File: /workspace/github_cpp_makefile_star2_O3/AndrewAlbert[P]Compiler-Theory/SourceCode/parser.cpp
// Function: Parser::ProgramBody()
bool Parser::ProgramBody(){
	bool resyncEnabled = true;
	bool procDec = false;
	string labelBegin = generator->newLabel("Begin_Program");
	//Get Procedure and Variable Declarations
	while(true){
		while( Declaration(procDec) ){
			if(procDec){
				if( !CheckToken(T_SEMICOLON) ) ReportWarning("expected ';' after procedure declaration in procedure");
			}
			else if( !CheckToken(T_SEMICOLON) ) ReportLineError("expected ';' after variable declaration in procedure", true);
		}
		if(CheckToken(T_BEGIN)){
			// GEN: Place label to procedure entry and set the Stack Pointer
			generator->placeLabel(labelBegin);
			generator->setSPfromFP( Scopes->getFrameSize() );
			//reset resync for statements
			resyncEnabled = false;
			while(true){
				//get all valid statements
				while( Statement() ){
					if( !CheckToken(T_SEMICOLON) ) ReportLineError("Expected ';' at end of statement in program body.", true);
				}
				//get program body's end
				if(CheckToken(T_END)){
					if( CheckToken(T_PROGRAM) ) return true;
					else ReportError("Expected 'end program' to close program execution.");
				}
				//use up resync attempt if parser can't find a statement or 'end'
				else if(resyncEnabled){
					resyncEnabled = false;
					ReportLineError("Bad line. Expected Statement or 'END' reserved keyword in program body.");
				}
				//if resync failed, report a fatal error
				else ReportFatalError("Parser resync failed. Could not find another valid statement or end of program.");
			}
		}
		//use up resync attempt if parser can't find a declaration or 'begin'
		else if(resyncEnabled){
			resyncEnabled = false;
			ReportLineError("Bad line. Expected Declaration or 'BEGIN' reserved keyword in program body.");
		}
		//if resync failed, report a fatal error
		else{
			ReportFatalError("Parser resync failed. Could not find another valid declaration or start of program execution.");
		}
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x148, %rsp            # imm = 0x148
movq %rdi, %rbx
movb $0x0, 0x3(%rsp)
movq 0x98(%rdi), %r14
leaq 0x138(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x12ea9(%rip), %rsi     # 0x1942d
leaq 0x12eaf(%rip), %rdx     # 0x1943a
leaq 0x128(%rsp), %r15
movq %r15, %rdi
callq 0x3c42
leaq 0xc8(%rsp), %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x15d26
movq 0x128(%rsp), %rdi
cmpq %r12, %rdi
je 0x65cb
movq 0x138(%rsp), %rsi
incq %rsi
callq 0x2200
leaq 0x98(%rsp), %rbp
leaq 0xb8(%rsp), %r15
movb $0x1, %al
movl %eax, 0x4(%rsp)
leaq 0x3(%rsp), %r14
leaq 0x88(%rsp), %r12
movq %rbx, %rdi
movq %r14, %rsi
callq 0x6b10
testb %al, %al
je 0x66bf
cmpb $0x1, 0x3(%rsp)
jne 0x665c
movq %rbx, %rdi
movl $0x12c, %esi            # imm = 0x12C
callq 0x5c08
testb %al, %al
jne 0x65ee
movq %r15, 0xa8(%rsp)
leaq 0xa8(%rsp), %r13
movq %r13, %rdi
leaq 0x12e08(%rip), %rsi     # 0x1943b
leaq 0x12e36(%rip), %rdx     # 0x19470
callq 0x3c42
movq %rbx, %rdi
movq %r13, %rsi
callq 0x4388
movq 0xa8(%rsp), %rdi
movq %r15, %rax
cmpq %r15, %rdi
jne 0x66af
jmp 0x65ee
movq %rbx, %rdi
movl $0x12c, %esi            # imm = 0x12C
callq 0x5c08
testb %al, %al
jne 0x65ee
movq %rbp, 0x88(%rsp)
movq %r12, %rdi
leaq 0x12df2(%rip), %rsi     # 0x19471
leaq 0x12e1f(%rip), %rdx     # 0x194a5
callq 0x3c42
movq %rbx, %rdi
movq %r12, %rsi
movl $0x1, %edx
callq 0x4e96
movq 0x88(%rsp), %rdi
movq %rbp, %rax
cmpq %rbp, %rdi
je 0x65ee
movq (%rax), %rsi
incq %rsi
callq 0x2200
jmp 0x65ee
movq %rbx, %rdi
movl $0x103, %esi            # imm = 0x103
callq 0x5c08
testb %al, %al
jne 0x6745
testb $0x1, 0x4(%rsp)
je 0x6903
leaq 0x18(%rsp), %rax
movq %rax, 0x8(%rsp)
leaq 0x8(%rsp), %r13
movq %r13, %rdi
leaq 0x12e67(%rip), %rsi     # 0x1955b
leaq 0x12eab(%rip), %rdx     # 0x195a6
callq 0x3c42
movq %rbx, %rdi
movq %r13, %rsi
movl $0x1, %edx
callq 0x4e96
movq 0x8(%rsp), %rdi
movl $0x0, 0x4(%rsp)
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x65ee
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x2200
movl $0x0, 0x4(%rsp)
jmp 0x65ee
movq 0x98(%rbx), %r14
leaq 0x78(%rsp), %r15
movq %r15, -0x10(%r15)
movq 0xc8(%rsp), %rsi
movq 0xd0(%rsp), %rdx
addq %rsi, %rdx
leaq 0x68(%rsp), %rdi
callq 0x3bac
leaq 0x68(%rsp), %rsi
movq %r14, %rdi
callq 0x15fc6
movq 0x68(%rsp), %rdi
cmpq %r15, %rdi
je 0x6796
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x2200
movq 0x90(%rbx), %rdi
movq 0x98(%rbx), %r14
callq 0x101ba
movq %r14, %rdi
movl %eax, %esi
callq 0x165d6
leaq 0x58(%rsp), %r15
leaq 0x28(%rsp), %r12
leaq 0x12d14(%rip), %r13     # 0x194d8
leaq 0x12d3f(%rip), %rbp     # 0x1950a
leaq 0x48(%rsp), %r14
movq %rbx, %rdi
callq 0x6efe
testb %al, %al
je 0x6833
movq %rbx, %rdi
movl $0x12c, %esi            # imm = 0x12C
callq 0x5c08
testb %al, %al
jne 0x67d0
leaq 0x38(%rsp), %rax
movq %rax, 0x28(%rsp)
movq %r12, %rdi
leaq 0x12ca5(%rip), %rsi     # 0x194a6
leaq 0x12ccf(%rip), %rdx     # 0x194d7
callq 0x3c42
movq %rbx, %rdi
movq %r12, %rsi
movl $0x1, %edx
callq 0x4e96
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x67d0
movq 0x38(%rsp), %rsi
jmp 0x688a
movq %rbx, %rdi
movl $0x104, %esi            # imm = 0x104
callq 0x5c08
testb %al, %al
je 0x68cc
movq %rbx, %rdi
movl $0x101, %esi            # imm = 0x101
callq 0x5c08
testb %al, %al
jne 0x6897
movq %r15, 0x48(%rsp)
movq %r14, %rdi
movq %r13, %rsi
movq %rbp, %rdx
callq 0x3c42
movq %rbx, %rdi
movq %r14, %rsi
callq 0x5694
movq 0x48(%rsp), %rdi
cmpq %r15, %rdi
je 0x67d0
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x2200
jmp 0x67d0
leaq 0xd8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x68b8
movq 0xd8(%rsp), %rsi
incq %rsi
callq 0x2200
movb $0x1, %al
addq $0x148, %rsp            # imm = 0x148
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x118(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0x12c2c(%rip), %rsi     # 0x1950b
leaq 0x12c74(%rip), %rdx     # 0x1955a
leaq 0x108(%rsp), %rdi
callq 0x3c42
leaq 0x108(%rsp), %rsi
movq %rbx, %rdi
callq 0x4a02
leaq 0xf8(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0x12c91(%rip), %rsi     # 0x195a7
leaq 0x12ce7(%rip), %rdx     # 0x19604
leaq 0xe8(%rsp), %rdi
callq 0x3c42
leaq 0xe8(%rsp), %rsi
movq %rbx, %rdi
callq 0x4a02
movq %rax, %rbx
movq 0x68(%rsp), %rdi
cmpq %r15, %rdi
je 0x6a4f
movq 0x78(%rsp), %rsi
jmp 0x6a3e
movq %rax, %rbx
movq 0x128(%rsp), %rdi
jmp 0x6a5c
jmp 0x6a4c
movq %rax, %rbx
movq 0xe8(%rsp), %rdi
cmpq %r14, %rdi
je 0x6a4f
movq 0xf8(%rsp), %rsi
jmp 0x6a3e
jmp 0x6a4c
movq %rax, %rbx
movq 0x108(%rsp), %rdi
cmpq %r14, %rdi
je 0x6a4f
movq 0x118(%rsp), %rsi
jmp 0x6a3e
jmp 0x6a4c
movq %rax, %rbx
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x6a4f
movq 0x38(%rsp), %rsi
jmp 0x6a3e
jmp 0x6a4c
jmp 0x6a4c
movq %rax, %rbx
movq 0x48(%rsp), %rdi
cmpq %r15, %rdi
je 0x6a4f
movq 0x58(%rsp), %rsi
jmp 0x6a3e
jmp 0x6a4c
movq %rax, %rbx
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x6a4f
movq 0x18(%rsp), %rsi
jmp 0x6a3e
jmp 0x6a4c
jmp 0x6a4c
jmp 0x6a4c
movq %rax, %rbx
movq 0x88(%rsp), %rdi
cmpq %rbp, %rdi
je 0x6a4f
movq 0x98(%rsp), %rsi
jmp 0x6a3e
movq %rax, %rbx
movq 0xa8(%rsp), %rdi
cmpq %r15, %rdi
je 0x6a4f
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x2200
jmp 0x6a4f
jmp 0x6a4c
jmp 0x6a4c
movq %rax, %rbx
leaq 0xd8(%rsp), %r12
movq -0x10(%r12), %rdi
cmpq %r12, %rdi
je 0x6a6d
movq (%r12), %rsi
incq %rsi
callq 0x2200
movq %rbx, %rdi
callq 0x2330
nop