// File: ssubrandon[P]460Project2/SyntacticalAnalyzer.cpp
// Function: SyntacticalAnalyzer::literal()
int SyntacticalAnalyzer::literal(){
  //This function deals with the literal rules (10-12) and will check for syntactical correctness,
  //this function will then, depending on the token seen, send the program to quoted lit or return.
	ruleFile << "Entering literal function; Current token is: " << lex ->GetTokenName(token) << ", lexeme: " << lex->GetLexeme() << endl;

	int errors =0;
	
	if (token == NUMLIT_T)
	{ 
		ruleFile << "Using Rule 10" << endl;
		token = lex->GetToken();
		ruleFile << "Exiting literal function; current token is: " << lex ->GetTokenName (token) << endl;
		return errors;
	}

	
	if (token == STRLIT_T)
	{
		ruleFile << "Using Rule 11" << endl;
		token = lex->GetToken();
		ruleFile << "Exiting literal function; current token is: " << lex ->GetTokenName (token) << endl;
		return errors;
	}


	if ( token == SQUOTE_T )
	{
		ruleFile << "Using Rule 12" << endl;
		ruleFile << "literal function complete. Current token is: " << lex->GetTokenName(token) << endl;
		token = lex->GetToken();
		errors += quoted_lit(); 
	}
	else{
	  if ( token != RPAREN_T){
	    errors++;
	    ReportError(string("expected either NUMLIT_T, STRLIT_T, or SQUOTE_T in literal but got: " + lex->GetTokenName(token)));
	  }
	}
	ruleFile << "Exiting literal function; current token is: " << lex ->GetTokenName (token) << endl;
	return errors;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1e0, %rsp            # imm = 0x1E0
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rdi
movq %rdi, -0x148(%rbp)
addq $0x420, %rdi            # imm = 0x420
leaq 0x3d29(%rip), %rsi      # 0x108f1
callq 0x3270
movq %rax, %rcx
movq -0x148(%rbp), %rax
movq %rcx, -0x140(%rbp)
movq 0x8(%rax), %rsi
movl 0x10(%rax), %edx
leaq -0x30(%rbp), %rdi
movq %rdi, -0x138(%rbp)
callq 0x6f40
movq -0x140(%rbp), %rdi
movq -0x138(%rbp), %rsi
callq 0x3240
movq %rax, -0x130(%rbp)
jmp 0xcc11
movq -0x130(%rbp), %rdi
leaq 0x3835(%rip), %rsi      # 0x10454
callq 0x3270
movq %rax, -0x150(%rbp)
jmp 0xcc2d
movq -0x148(%rbp), %rax
movq 0x8(%rax), %rsi
leaq -0x60(%rbp), %rdi
callq 0x6f80
jmp 0xcc43
movq -0x150(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0x3240
movq %rax, -0x158(%rbp)
jmp 0xcc5c
movq -0x158(%rbp), %rdi
movq 0x8356(%rip), %rsi      # 0x14fc0
callq 0x32c0
jmp 0xcc71
leaq -0x60(%rbp), %rdi
callq 0x34b8
leaq -0x30(%rbp), %rdi
callq 0x34b8
movq -0x148(%rbp), %rax
movl $0x0, -0x64(%rbp)
cmpl $0x2, 0x10(%rax)
jne 0xcdbb
movq -0x148(%rbp), %rdi
addq $0x420, %rdi            # imm = 0x420
movq %rdi, -0x178(%rbp)
leaq 0x3c68(%rip), %rsi      # 0x1091f
callq 0x3270
movq %rax, %rdi
movq 0x82fa(%rip), %rsi      # 0x14fc0
callq 0x32c0
movq -0x148(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x5fd0
movq -0x178(%rbp), %rdi
movl %eax, %ecx
movq -0x148(%rbp), %rax
movl %ecx, 0x10(%rax)
leaq 0x3c38(%rip), %rsi      # 0x1092d
callq 0x3270
movq %rax, %rcx
movq -0x148(%rbp), %rax
movq %rcx, -0x170(%rbp)
movq 0x8(%rax), %rsi
movl 0x10(%rax), %edx
leaq -0x88(%rbp), %rdi
movq %rdi, -0x168(%rbp)
callq 0x6f40
movq -0x170(%rbp), %rdi
movq -0x168(%rbp), %rsi
callq 0x3240
movq %rax, -0x160(%rbp)
jmp 0xcd41
movq -0x160(%rbp), %rdi
movq 0x8271(%rip), %rsi      # 0x14fc0
callq 0x32c0
jmp 0xcd56
leaq -0x88(%rbp), %rdi
callq 0x34b8
movl -0x64(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0xd120
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0xcd90
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x60(%rbp), %rdi
callq 0x34b8
leaq -0x30(%rbp), %rdi
callq 0x34b8
jmp 0xd12c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x88(%rbp), %rdi
callq 0x34b8
jmp 0xd12c
movq -0x148(%rbp), %rax
cmpl $0x3, 0x10(%rax)
jne 0xcebb
movq -0x148(%rbp), %rdi
addq $0x420, %rdi            # imm = 0x420
movq %rdi, -0x198(%rbp)
leaq 0x3b72(%rip), %rsi      # 0x1095a
callq 0x3270
movq %rax, %rdi
movq 0x81c9(%rip), %rsi      # 0x14fc0
callq 0x32c0
movq -0x148(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x5fd0
movq -0x198(%rbp), %rdi
movl %eax, %ecx
movq -0x148(%rbp), %rax
movl %ecx, 0x10(%rax)
leaq 0x3b07(%rip), %rsi      # 0x1092d
callq 0x3270
movq %rax, %rcx
movq -0x148(%rbp), %rax
movq %rcx, -0x190(%rbp)
movq 0x8(%rax), %rsi
movl 0x10(%rax), %edx
leaq -0xa8(%rbp), %rdi
movq %rdi, -0x188(%rbp)
callq 0x6f40
movq -0x190(%rbp), %rdi
movq -0x188(%rbp), %rsi
callq 0x3240
movq %rax, -0x180(%rbp)
jmp 0xce72
movq -0x180(%rbp), %rdi
movq 0x8140(%rip), %rsi      # 0x14fc0
callq 0x32c0
jmp 0xce87
leaq -0xa8(%rbp), %rdi
callq 0x34b8
movl -0x64(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0xd120
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0xa8(%rbp), %rdi
callq 0x34b8
jmp 0xd12c
movq -0x148(%rbp), %rax
cmpl $0x21, 0x10(%rax)
jne 0xcfbe
movq -0x148(%rbp), %rdi
addq $0x420, %rdi            # imm = 0x420
movq %rdi, -0x1b8(%rbp)
leaq 0x3a80(%rip), %rsi      # 0x10968
callq 0x3270
movq %rax, %rdi
movq 0x80c9(%rip), %rsi      # 0x14fc0
callq 0x32c0
movq -0x1b8(%rbp), %rdi
leaq 0x3a6c(%rip), %rsi      # 0x10976
callq 0x3270
movq %rax, %rcx
movq -0x148(%rbp), %rax
movq %rcx, -0x1b0(%rbp)
movq 0x8(%rax), %rsi
movl 0x10(%rax), %edx
leaq -0xc8(%rbp), %rdi
movq %rdi, -0x1a8(%rbp)
callq 0x6f40
movq -0x1b0(%rbp), %rdi
movq -0x1a8(%rbp), %rsi
callq 0x3240
movq %rax, -0x1a0(%rbp)
jmp 0xcf56
movq -0x1a0(%rbp), %rdi
movq 0x805c(%rip), %rsi      # 0x14fc0
callq 0x32c0
jmp 0xcf6b
leaq -0xc8(%rbp), %rdi
callq 0x34b8
movq -0x148(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x5fd0
movq -0x148(%rbp), %rdi
movl %eax, 0x10(%rdi)
callq 0xd140
addl -0x64(%rbp), %eax
movl %eax, -0x64(%rbp)
jmp 0xd07c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0xc8(%rbp), %rdi
callq 0x34b8
jmp 0xd12c
movq -0x148(%rbp), %rax
cmpl $0x20, 0x10(%rax)
je 0xd07a
movq -0x148(%rbp), %rax
movl -0x64(%rbp), %ecx
incl %ecx
movl %ecx, -0x64(%rbp)
movq 0x8(%rax), %rsi
movl 0x10(%rax), %edx
leaq -0x108(%rbp), %rdi
movq %rdi, -0x1c0(%rbp)
callq 0x6f40
movq -0x1c0(%rbp), %rdx
leaq 0x399e(%rip), %rsi      # 0x109a4
leaq -0xe8(%rbp), %rdi
callq 0xf1b0
jmp 0xd014
movq -0x148(%rbp), %rdi
leaq -0xe8(%rbp), %rsi
callq 0x91a0
jmp 0xd029
leaq -0xe8(%rbp), %rdi
callq 0x34b8
leaq -0x108(%rbp), %rdi
callq 0x34b8
jmp 0xd07a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0xd069
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0xe8(%rbp), %rdi
callq 0x34b8
leaq -0x108(%rbp), %rdi
callq 0x34b8
jmp 0xd12c
jmp 0xd07c
movq -0x148(%rbp), %rdi
addq $0x420, %rdi            # imm = 0x420
leaq 0x389c(%rip), %rsi      # 0x1092d
callq 0x3270
movq %rax, %rcx
movq -0x148(%rbp), %rax
movq %rcx, -0x1d8(%rbp)
movq 0x8(%rax), %rsi
movl 0x10(%rax), %edx
leaq -0x128(%rbp), %rdi
movq %rdi, -0x1d0(%rbp)
callq 0x6f40
movq -0x1d8(%rbp), %rdi
movq -0x1d0(%rbp), %rsi
callq 0x3240
movq %rax, -0x1c8(%rbp)
jmp 0xd0dd
movq -0x1c8(%rbp), %rdi
movq 0x7ed5(%rip), %rsi      # 0x14fc0
callq 0x32c0
jmp 0xd0f2
leaq -0x128(%rbp), %rdi
callq 0x34b8
movl -0x64(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0xd120
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x128(%rbp), %rdi
callq 0x34b8
jmp 0xd12c
movl -0x4(%rbp), %eax
addq $0x1e0, %rsp            # imm = 0x1E0
popq %rbp
retq
movq -0x38(%rbp), %rdi
callq 0x3430
nopw %cs:(%rax,%rax)