// File: 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
movq %rsp, %rbp
subq $0x260, %rsp            # imm = 0x260
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x1e0(%rbp)
movb $0x1, -0x9(%rbp)
movb $0x0, -0xa(%rbp)
movq 0x98(%rax), %rax
movq %rax, -0x1d8(%rbp)
leaq -0x51(%rbp), %rdi
movq %rdi, -0x1d0(%rbp)
callq 0x3430
movq -0x1d0(%rbp), %rdx
leaq 0x1b63d(%rip), %rsi     # 0x256ab
leaq -0x50(%rbp), %rdi
callq 0x62d0
jmp 0xa079
movq -0x1d8(%rbp), %rsi
leaq -0x30(%rbp), %rdi
leaq -0x50(%rbp), %rdx
callq 0x1ded0
jmp 0xa08f
leaq -0x50(%rbp), %rdi
callq 0x31a0
leaq -0x51(%rbp), %rdi
callq 0x32e0
jmp 0xa0a3
jmp 0xa0a5
movq -0x1e0(%rbp), %rdi
leaq -0xa(%rbp), %rsi
callq 0xa8b0
movb %al, -0x1e1(%rbp)
jmp 0xa0bd
movb -0x1e1(%rbp), %al
testb $0x1, %al
jne 0xa0cc
jmp 0xa2a5
testb $0x1, -0xa(%rbp)
je 0xa1db
movq -0x1e0(%rbp), %rdi
movl $0x12c, %esi            # imm = 0x12C
callq 0x9300
movb %al, -0x1e2(%rbp)
jmp 0xa0ef
movb -0x1e2(%rbp), %al
testb $0x1, %al
jne 0xa1d6
jmp 0xa0ff
leaq -0x89(%rbp), %rdi
movq %rdi, -0x1f0(%rbp)
callq 0x3430
movq -0x1f0(%rbp), %rdx
leaq 0x1b599(%rip), %rsi     # 0x256b9
leaq -0x88(%rbp), %rdi
callq 0x62d0
jmp 0xa12e
movq -0x1e0(%rbp), %rdi
leaq -0x88(%rbp), %rsi
callq 0x8510
jmp 0xa143
leaq -0x88(%rbp), %rdi
callq 0x31a0
leaq -0x89(%rbp), %rdi
callq 0x32e0
jmp 0xa1d6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0xa180
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x31a0
leaq -0x51(%rbp), %rdi
callq 0x32e0
jmp 0xa7f3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0xa7ea
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0xa1c5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x88(%rbp), %rdi
callq 0x31a0
leaq -0x89(%rbp), %rdi
callq 0x32e0
jmp 0xa7ea
jmp 0xa2a0
movq -0x1e0(%rbp), %rdi
movl $0x12c, %esi            # imm = 0x12C
callq 0x9300
movb %al, -0x1f1(%rbp)
jmp 0xa1f4
movb -0x1f1(%rbp), %al
testb $0x1, %al
jne 0xa29e
jmp 0xa204
leaq -0xb1(%rbp), %rdi
movq %rdi, -0x200(%rbp)
callq 0x3430
movq -0x200(%rbp), %rdx
leaq 0x1b4ca(%rip), %rsi     # 0x256ef
leaq -0xb0(%rbp), %rdi
callq 0x62d0
jmp 0xa233
movq -0x1e0(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
movl $0x1, %edx
callq 0x8b50
jmp 0xa24d
leaq -0xb0(%rbp), %rdi
callq 0x31a0
leaq -0xb1(%rbp), %rdi
callq 0x32e0
jmp 0xa29e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0xa28d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0xb0(%rbp), %rdi
callq 0x31a0
leaq -0xb1(%rbp), %rdi
callq 0x32e0
jmp 0xa7ea
jmp 0xa2a0
jmp 0xa0a5
movq -0x1e0(%rbp), %rdi
movl $0x103, %esi            # imm = 0x103
callq 0x9300
movb %al, -0x201(%rbp)
jmp 0xa2be
movb -0x201(%rbp), %al
testb $0x1, %al
jne 0xa2cd
jmp 0xa6a6
movq -0x1e0(%rbp), %rax
movq 0x98(%rax), %rax
movq %rax, -0x210(%rbp)
leaq -0xd8(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x3130
jmp 0xa2f4
movq -0x210(%rbp), %rdi
leaq -0xd8(%rbp), %rsi
callq 0x1e060
jmp 0xa309
leaq -0xd8(%rbp), %rdi
callq 0x31a0
movq -0x1e0(%rbp), %rax
movq 0x90(%rax), %rdi
movq 0x98(%rax), %rax
movq %rax, -0x220(%rbp)
callq 0x189b0
movl %eax, -0x214(%rbp)
jmp 0xa33e
movl -0x214(%rbp), %esi
movq -0x220(%rbp), %rdi
callq 0x1e630
jmp 0xa352
movb $0x0, -0x9(%rbp)
jmp 0xa358
jmp 0xa35a
movq -0x1e0(%rbp), %rdi
callq 0xac60
movb %al, -0x221(%rbp)
jmp 0xa36e
movb -0x221(%rbp), %al
testb $0x1, %al
jne 0xa37d
jmp 0xa462
movq -0x1e0(%rbp), %rdi
movl $0x12c, %esi            # imm = 0x12C
callq 0x9300
movb %al, -0x222(%rbp)
jmp 0xa396
movb -0x222(%rbp), %al
testb $0x1, %al
jne 0xa45d
jmp 0xa3a6
leaq -0xf9(%rbp), %rdi
movq %rdi, -0x230(%rbp)
callq 0x3430
movq -0x230(%rbp), %rdx
leaq 0x1b35d(%rip), %rsi     # 0x25724
leaq -0xf8(%rbp), %rdi
callq 0x62d0
jmp 0xa3d5
movq -0x1e0(%rbp), %rdi
leaq -0xf8(%rbp), %rsi
movl $0x1, %edx
callq 0x8b50
jmp 0xa3ef
leaq -0xf8(%rbp), %rdi
callq 0x31a0
leaq -0xf9(%rbp), %rdi
callq 0x32e0
jmp 0xa45d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0xd8(%rbp), %rdi
callq 0x31a0
jmp 0xa7ea
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0xa44c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0xf8(%rbp), %rdi
callq 0x31a0
leaq -0xf9(%rbp), %rdi
callq 0x32e0
jmp 0xa7ea
jmp 0xa35a
movq -0x1e0(%rbp), %rdi
movl $0x104, %esi            # imm = 0x104
callq 0x9300
movb %al, -0x231(%rbp)
jmp 0xa47b
movb -0x231(%rbp), %al
testb $0x1, %al
jne 0xa48a
jmp 0xa55f
movq -0x1e0(%rbp), %rdi
movl $0x101, %esi            # imm = 0x101
callq 0x9300
movb %al, -0x232(%rbp)
jmp 0xa4a3
movb -0x232(%rbp), %al
testb $0x1, %al
jne 0xa4af
jmp 0xa4c5
leaq -0x30(%rbp), %rdi
callq 0x31a0
movb $0x1, %al
andb $0x1, %al
addq $0x260, %rsp            # imm = 0x260
popq %rbp
retq
leaq -0x121(%rbp), %rdi
movq %rdi, -0x240(%rbp)
callq 0x3430
movq -0x240(%rbp), %rdx
leaq 0x1b270(%rip), %rsi     # 0x25756
leaq -0x120(%rbp), %rdi
callq 0x62d0
jmp 0xa4f4
movq -0x1e0(%rbp), %rdi
leaq -0x120(%rbp), %rsi
callq 0x9060
jmp 0xa509
leaq -0x120(%rbp), %rdi
callq 0x31a0
leaq -0x121(%rbp), %rdi
callq 0x32e0
jmp 0xa55a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0xa549
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x120(%rbp), %rdi
callq 0x31a0
leaq -0x121(%rbp), %rdi
callq 0x32e0
jmp 0xa7ea
jmp 0xa6a1
testb $0x1, -0x9(%rbp)
je 0xa60a
movb $0x0, -0x9(%rbp)
leaq -0x149(%rbp), %rdi
movq %rdi, -0x248(%rbp)
callq 0x3430
movq -0x248(%rbp), %rdx
leaq 0x1b1fb(%rip), %rsi     # 0x25789
leaq -0x148(%rbp), %rdi
callq 0x62d0
jmp 0xa59c
movq -0x1e0(%rbp), %rdi
leaq -0x148(%rbp), %rsi
movl $0x1, %edx
callq 0x8b50
jmp 0xa5b6
leaq -0x148(%rbp), %rdi
callq 0x31a0
leaq -0x149(%rbp), %rdi
callq 0x32e0
jmp 0xa69f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0xa5f9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x148(%rbp), %rdi
callq 0x31a0
leaq -0x149(%rbp), %rdi
callq 0x32e0
jmp 0xa7ea
leaq -0x171(%rbp), %rdi
movq %rdi, -0x250(%rbp)
callq 0x3430
movq -0x250(%rbp), %rdx
leaq 0x1b1a6(%rip), %rsi     # 0x257d1
leaq -0x170(%rbp), %rdi
callq 0x62d0
jmp 0xa639
movq -0x1e0(%rbp), %rdi
leaq -0x170(%rbp), %rsi
callq 0x88a0
jmp 0xa64e
leaq -0x170(%rbp), %rdi
callq 0x31a0
leaq -0x171(%rbp), %rdi
callq 0x32e0
jmp 0xa69f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0xa68e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x170(%rbp), %rdi
callq 0x31a0
leaq -0x171(%rbp), %rdi
callq 0x32e0
jmp 0xa7ea
jmp 0xa6a1
jmp 0xa356
testb $0x1, -0x9(%rbp)
je 0xa751
movb $0x0, -0x9(%rbp)
leaq -0x199(%rbp), %rdi
movq %rdi, -0x258(%rbp)
callq 0x3430
movq -0x258(%rbp), %rdx
leaq 0x1b14c(%rip), %rsi     # 0x25821
leaq -0x198(%rbp), %rdi
callq 0x62d0
jmp 0xa6e3
movq -0x1e0(%rbp), %rdi
leaq -0x198(%rbp), %rsi
movl $0x1, %edx
callq 0x8b50
jmp 0xa6fd
leaq -0x198(%rbp), %rdi
callq 0x31a0
leaq -0x199(%rbp), %rdi
callq 0x32e0
jmp 0xa7e3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0xa740
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x198(%rbp), %rdi
callq 0x31a0
leaq -0x199(%rbp), %rdi
callq 0x32e0
jmp 0xa7ea
leaq -0x1c1(%rbp), %rdi
movq %rdi, -0x260(%rbp)
callq 0x3430
movq -0x260(%rbp), %rdx
leaq 0x1b0fb(%rip), %rsi     # 0x2586d
leaq -0x1c0(%rbp), %rdi
callq 0x62d0
jmp 0xa780
movq -0x1e0(%rbp), %rdi
leaq -0x1c0(%rbp), %rsi
callq 0x88a0
jmp 0xa795
leaq -0x1c0(%rbp), %rdi
callq 0x31a0
leaq -0x1c1(%rbp), %rdi
callq 0x32e0
jmp 0xa7e3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0xa7d5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x1c0(%rbp), %rdi
callq 0x31a0
leaq -0x1c1(%rbp), %rdi
callq 0x32e0
jmp 0xa7ea
jmp 0xa7e5
jmp 0xa0a1
leaq -0x30(%rbp), %rdi
callq 0x31a0
movq -0x60(%rbp), %rdi
callq 0x3420
nopl (%rax)