// File: AndrewAlbert[P]Compiler-Theory/SourceCode/parser.cpp
// Function: Parser::ExpressionPrime(int&, int&, bool, bool)
bool Parser::ExpressionPrime(int &inputType, int &inputSize, bool catchTypeError, bool catchSizeError){
	int arithOpType, arithOpSize;
	
	// Get the operator to pass to the codegenerator evaluation stack
	string op = token->ascii;
	
	if( CheckToken(T_BITWISE) ){
		CheckToken(T_NOT); //'NOT' is always optional and will be good for both integer-bitwise and boolean-boolean expressions.
		if( ArithOp(arithOpType, arithOpSize) ){
			if( catchTypeError ){
				if(inputType == TYPE_INTEGER){
					if(arithOpType != TYPE_INTEGER){
						ReportError("Only integer ArithOps can be used for bitwise operators '&' and '|'.");
						catchTypeError = false;
					}
				}
				else if(inputType == TYPE_BOOL){
					if(arithOpType != TYPE_BOOL){
						ReportError("Only boolean ArithOps can be used for boolean operators '&' and '|'.");
						catchTypeError = false;
					}
				}
				else ReportError("Only integer / boolean ArithOps can be used for bitwise / boolean operators '&' and '|'.");
			}
			if( catchSizeError ){
				//Ensure compatible sizes are used.
				if( (inputSize != arithOpSize) && (inputSize != 0) && (arithOpSize != 0) ){
					ReportError("Expected ArithOp of size " + to_string(inputSize) + ", but found one of size " + to_string(arithOpSize) + ".");
					catchSizeError = false;
				}
				//Set new inputSize if the next ArithOp's size was non-zero and inputSize was zero.
				else if(arithOpSize != 0) inputSize = arithOpSize;
			}
		}
		else{
			ReportError("Expected ArithOp after '&' or '|' operator.");
			catchTypeError = false;
			catchSizeError = false;
		}
		ExpressionPrime(inputType, inputSize, catchTypeError, catchSizeError);
		
		// GEN: Evaluate expression and push register onto the stack to pass to upper expression
		// Do not need resulting string since expression result is pushed back onto the stack
		generator->evalExpr( op, inputSize, arithOpSize, inputType, arithOpType );
		
		return true;
	}
	else return false;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x250, %rsp            # imm = 0x250
movb %r8b, %al
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
andb $0x1, %cl
movb %cl, -0x21(%rbp)
andb $0x1, %al
movb %al, -0x22(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x210(%rbp)
movq 0x80(%rax), %rsi
leaq -0x50(%rbp), %rdi
callq 0x3130
movq -0x210(%rbp), %rdi
movl $0x13b, %esi            # imm = 0x13B
callq 0x9300
movb %al, -0x205(%rbp)
jmp 0xf949
movb -0x205(%rbp), %al
testb $0x1, %al
jne 0xf958
jmp 0xfefa
movq -0x210(%rbp), %rdi
movl $0x10f, %esi            # imm = 0x10F
callq 0x9300
jmp 0xf96b
movq -0x210(%rbp), %rdi
leaq -0x28(%rbp), %rsi
leaq -0x2c(%rbp), %rdx
callq 0xf890
movb %al, -0x211(%rbp)
jmp 0xf987
movb -0x211(%rbp), %al
testb $0x1, %al
jne 0xf996
jmp 0xfd99
testb $0x1, -0x21(%rbp)
je 0xfbb4
movq -0x18(%rbp), %rax
cmpl $0x10a, (%rax)          # imm = 0x10A
jne 0xfa60
cmpl $0x10a, -0x28(%rbp)     # imm = 0x10A
je 0xfa5b
leaq -0x81(%rbp), %rdi
movq %rdi, -0x220(%rbp)
callq 0x3430
movq -0x220(%rbp), %rdx
leaq 0x16b73(%rip), %rsi     # 0x26551
leaq -0x80(%rbp), %rdi
callq 0x62d0
jmp 0xf9e9
movq -0x210(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0x9060
jmp 0xf9fb
leaq -0x80(%rbp), %rdi
callq 0x31a0
leaq -0x81(%rbp), %rdi
callq 0x32e0
movb $0x0, -0x21(%rbp)
jmp 0xfa5b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0xff1f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0xfa4a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x31a0
leaq -0x81(%rbp), %rdi
callq 0x32e0
jmp 0xff1f
jmp 0xfbb2
movq -0x18(%rbp), %rax
cmpl $0x10c, (%rax)          # imm = 0x10C
jne 0xfb1b
cmpl $0x10c, -0x28(%rbp)     # imm = 0x10C
je 0xfb16
leaq -0xa9(%rbp), %rdi
movq %rdi, -0x228(%rbp)
callq 0x3430
movq -0x228(%rbp), %rdx
leaq 0x16af8(%rip), %rsi     # 0x26596
leaq -0xa8(%rbp), %rdi
callq 0x62d0
jmp 0xfaac
movq -0x210(%rbp), %rdi
leaq -0xa8(%rbp), %rsi
callq 0x9060
jmp 0xfac1
leaq -0xa8(%rbp), %rdi
callq 0x31a0
leaq -0xa9(%rbp), %rdi
callq 0x32e0
movb $0x0, -0x21(%rbp)
jmp 0xfb16
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0xfb05
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0xa8(%rbp), %rdi
callq 0x31a0
leaq -0xa9(%rbp), %rdi
callq 0x32e0
jmp 0xff1f
jmp 0xfbb0
leaq -0xd1(%rbp), %rdi
movq %rdi, -0x230(%rbp)
callq 0x3430
movq -0x230(%rbp), %rdx
leaq 0x16a9f(%rip), %rsi     # 0x265db
leaq -0xd0(%rbp), %rdi
callq 0x62d0
jmp 0xfb4a
movq -0x210(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
callq 0x9060
jmp 0xfb5f
leaq -0xd0(%rbp), %rdi
callq 0x31a0
leaq -0xd1(%rbp), %rdi
callq 0x32e0
jmp 0xfbb0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0xfb9f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0xd0(%rbp), %rdi
callq 0x31a0
leaq -0xd1(%rbp), %rdi
callq 0x32e0
jmp 0xff1f
jmp 0xfbb2
jmp 0xfbb4
testb $0x1, -0x22(%rbp)
je 0xfd94
movq -0x20(%rbp), %rax
movl (%rax), %eax
cmpl -0x2c(%rbp), %eax
je 0xfd81
movq -0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0xfd81
cmpl $0x0, -0x2c(%rbp)
je 0xfd81
movq -0x20(%rbp), %rax
movl (%rax), %esi
leaq -0x178(%rbp), %rdi
callq 0x123d0
jmp 0xfbf8
leaq 0x16a35(%rip), %rsi     # 0x26634
leaq -0x158(%rbp), %rdi
leaq -0x178(%rbp), %rdx
callq 0x12380
jmp 0xfc14
leaq 0x16a33(%rip), %rdx     # 0x2664e
leaq -0x138(%rbp), %rdi
leaq -0x158(%rbp), %rsi
callq 0x12330
jmp 0xfc30
movl -0x2c(%rbp), %esi
leaq -0x198(%rbp), %rdi
callq 0x123d0
jmp 0xfc41
leaq -0x118(%rbp), %rdi
leaq -0x138(%rbp), %rsi
leaq -0x198(%rbp), %rdx
callq 0x12990
jmp 0xfc5d
leaq 0x16b0e(%rip), %rdx     # 0x26772
leaq -0xf8(%rbp), %rdi
leaq -0x118(%rbp), %rsi
callq 0x12330
jmp 0xfc79
movq -0x210(%rbp), %rdi
leaq -0xf8(%rbp), %rsi
callq 0x9060
jmp 0xfc8e
leaq -0xf8(%rbp), %rdi
callq 0x31a0
leaq -0x118(%rbp), %rdi
callq 0x31a0
leaq -0x198(%rbp), %rdi
callq 0x31a0
leaq -0x138(%rbp), %rdi
callq 0x31a0
leaq -0x158(%rbp), %rdi
callq 0x31a0
leaq -0x178(%rbp), %rdi
callq 0x31a0
movb $0x0, -0x22(%rbp)
jmp 0xfd92
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0xfd70
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0xfd64
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0xfd58
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0xfd4c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0xfd40
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0xf8(%rbp), %rdi
callq 0x31a0
leaq -0x118(%rbp), %rdi
callq 0x31a0
leaq -0x198(%rbp), %rdi
callq 0x31a0
leaq -0x138(%rbp), %rdi
callq 0x31a0
leaq -0x158(%rbp), %rdi
callq 0x31a0
leaq -0x178(%rbp), %rdi
callq 0x31a0
jmp 0xff1f
cmpl $0x0, -0x2c(%rbp)
je 0xfd90
movl -0x2c(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
jmp 0xfd92
jmp 0xfd94
jmp 0xfe36
leaq -0x1b9(%rbp), %rdi
movq %rdi, -0x238(%rbp)
callq 0x3430
movq -0x238(%rbp), %rdx
leaq 0x168ad(%rip), %rsi     # 0x26667
leaq -0x1b8(%rbp), %rdi
callq 0x62d0
jmp 0xfdc8
movq -0x210(%rbp), %rdi
leaq -0x1b8(%rbp), %rsi
callq 0x9060
jmp 0xfddd
leaq -0x1b8(%rbp), %rdi
callq 0x31a0
leaq -0x1b9(%rbp), %rdi
callq 0x32e0
movb $0x0, -0x21(%rbp)
movb $0x0, -0x22(%rbp)
jmp 0xfe36
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0xfe25
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x1b8(%rbp), %rdi
callq 0x31a0
leaq -0x1b9(%rbp), %rdi
callq 0x32e0
jmp 0xff1f
movq -0x210(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
movzbl -0x22(%rbp), %r8d
movzbl -0x21(%rbp), %ecx
andl $0x1, %ecx
andl $0x1, %r8d
callq 0xf8f0
jmp 0xfe5c
movq -0x210(%rbp), %rax
movq 0x98(%rax), %rax
movq %rax, -0x240(%rbp)
leaq -0x200(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x3130
jmp 0xfe83
movq -0x240(%rbp), %rsi
movq -0x20(%rbp), %rax
movl (%rax), %ecx
movl -0x2c(%rbp), %r8d
movq -0x18(%rbp), %rax
movl (%rax), %r9d
movl -0x28(%rbp), %edx
movq %rsp, %rax
movl %edx, (%rax)
leaq -0x1e0(%rbp), %rdi
leaq -0x200(%rbp), %rdx
callq 0x1abf0
jmp 0xfeb8
leaq -0x1e0(%rbp), %rdi
callq 0x31a0
leaq -0x200(%rbp), %rdi
callq 0x31a0
movb $0x1, -0x1(%rbp)
movl $0x1, -0x204(%rbp)
jmp 0xff08
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x200(%rbp), %rdi
callq 0x31a0
jmp 0xff1f
movb $0x0, -0x1(%rbp)
movl $0x1, -0x204(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x31a0
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x250, %rsp            # imm = 0x250
popq %rbp
retq
leaq -0x50(%rbp), %rdi
callq 0x31a0
movq -0x58(%rbp), %rdi
callq 0x3420
nopw %cs:(%rax,%rax)