// File: AndrewAlbert[P]Compiler-Theory/SourceCode/parser.cpp
// Function: Parser::VariableDeclaration(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>&, scopeValue&)
bool Parser::VariableDeclaration(string &id, scopeValue &varEntry){
	//get variable type, otherwise no variable should be declared
	if( !TypeMark(varEntry.type) ) return false;
	else{
		//get variable identifier
		if( Identifier(id) ){
			// Get size for array variable declarations
			if(CheckToken(T_LBRACKET)){
				if(CheckToken(TYPE_INTEGER)){
					varEntry.size = token->val.intValue;
					if( !CheckToken(T_RBRACKET) ) ReportError("expected ']' at end of array variable declaration.");
					return true;
				}
				else{
					ReportLineError("Expected integer for array size in variable declaration.");
					return true;
				}
			}
			else{
				varEntry.size = 0;
				return true;
			}
		}
		else{
			ReportLineError("Bad line. Expected variable identifier for declaration after type mark.");
			return true;
		}
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xd0, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq -0x10(%rbp), %rdi
movq %rdi, -0xb0(%rbp)
movq -0x20(%rbp), %rsi
callq 0xb180
testb $0x1, %al
jne 0xaf28
movb $0x0, -0x1(%rbp)
jmp 0xb163
movq -0xb0(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0xa800
testb $0x1, %al
jne 0xaf41
jmp 0xb0c8
movq -0xb0(%rbp), %rdi
movl $0x135, %esi            # imm = 0x135
callq 0x9300
testb $0x1, %al
jne 0xaf5b
jmp 0xb0b4
movq -0xb0(%rbp), %rdi
movl $0x10a, %esi            # imm = 0x10A
callq 0x9300
testb $0x1, %al
jne 0xaf75
jmp 0xb028
movq -0xb0(%rbp), %rdi
movq 0x80(%rdi), %rax
movl 0x28(%rax), %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x4(%rax)
movl $0x136, %esi            # imm = 0x136
callq 0x9300
testb $0x1, %al
jne 0xb01f
leaq -0x41(%rbp), %rdi
movq %rdi, -0xb8(%rbp)
callq 0x3430
movq -0xb8(%rbp), %rdx
leaq 0x1a969(%rip), %rsi     # 0x25926
leaq -0x40(%rbp), %rdi
callq 0x62d0
jmp 0xafc8
movq -0xb0(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x9060
jmp 0xafda
leaq -0x40(%rbp), %rdi
callq 0x31a0
leaq -0x41(%rbp), %rdi
callq 0x32e0
jmp 0xb01f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0xb011
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x31a0
leaq -0x41(%rbp), %rdi
callq 0x32e0
jmp 0xb171
movb $0x1, -0x1(%rbp)
jmp 0xb163
leaq -0x79(%rbp), %rdi
movq %rdi, -0xc0(%rbp)
callq 0x3430
movq -0xc0(%rbp), %rdx
leaq 0x1a913(%rip), %rsi     # 0x25959
leaq -0x78(%rbp), %rdi
callq 0x62d0
jmp 0xb051
movq -0xb0(%rbp), %rdi
leaq -0x78(%rbp), %rsi
movl $0x1, %edx
callq 0x8b50
jmp 0xb068
leaq -0x78(%rbp), %rdi
callq 0x31a0
leaq -0x79(%rbp), %rdi
callq 0x32e0
movb $0x1, -0x1(%rbp)
jmp 0xb163
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0xb0a6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x78(%rbp), %rdi
callq 0x31a0
leaq -0x79(%rbp), %rdi
callq 0x32e0
jmp 0xb171
movq -0x20(%rbp), %rax
movl $0x0, 0x4(%rax)
movb $0x1, -0x1(%rbp)
jmp 0xb163
leaq -0xa1(%rbp), %rdi
movq %rdi, -0xc8(%rbp)
callq 0x3430
movq -0xc8(%rbp), %rdx
leaq 0x1a8a9(%rip), %rsi     # 0x25992
leaq -0xa0(%rbp), %rdi
callq 0x62d0
jmp 0xb0f7
movq -0xb0(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
movl $0x1, %edx
callq 0x8b50
jmp 0xb111
leaq -0xa0(%rbp), %rdi
callq 0x31a0
leaq -0xa1(%rbp), %rdi
callq 0x32e0
movb $0x1, -0x1(%rbp)
jmp 0xb163
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0xb155
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0xa0(%rbp), %rdi
callq 0x31a0
leaq -0xa1(%rbp), %rdi
callq 0x32e0
jmp 0xb171
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0xd0, %rsp
popq %rbp
retq
movq -0x50(%rbp), %rdi
callq 0x3420
nopw (%rax,%rax)