// File: ssubrandon[P]460Project2/SyntacticalAnalyzer.cpp
// Function: SyntacticalAnalyzer::define()
int SyntacticalAnalyzer::define(){
  //This function deals with the defines rules(4) and will check for syntactical correctness,
  //this function will, depending on the token seen, send the program to param_list after
  //checking for the presence of some needed tokens for this rule.
  ruleFile << "Entering define function; Current token is: " << lex ->GetTokenName(token) << ", lexeme: " << lex->GetLexeme() << endl;

	int errors = 0;

	ruleFile << "Using  Rule 4" << endl;

	if(token != DEFINE_T){
		errors++;
		ReportError(string("expected a DEFINE_T in define, but found  " + lex->GetTokenName(token)));
	}

	token = lex->GetToken();
	if(token != LPAREN_T){
		errors++;
		ReportError(string("expected a LPAREN_T in define, but found  " + lex->GetTokenName(token)));
	}

	token = lex->GetToken();
	if(token != IDENT_T){
		errors++;
		ReportError(string("expected a IDENT_T in define, but found  " + lex->GetTokenName(token)));
	}

	token = lex->GetToken();
	errors += param_list();


	if(token != RPAREN_T){
		errors++;
		ReportError(string("expected a RPAREN_T in define, but found  " + lex->GetTokenName(token)));
	}
	token = lex->GetToken();
	errors += stmt();
	errors += stmt_list();


	if(token != RPAREN_T){
	  errors++;
	  ReportError(string("expected a RPAREN_T in define, but found  " + lex->GetTokenName(token)));
		token = lex->GetToken();
	}
	token = lex->GetToken();
	ruleFile << "Exiting Define function; current token is: " << lex ->GetTokenName (token) << endl;


	return errors;

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x230, %rsp            # imm = 0x230
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x1e0(%rbp)
addq $0x420, %rdi            # imm = 0x420
leaq 0x731e(%rip), %rsi      # 0x10626
callq 0x3270
movq %rax, %rcx
movq -0x1e0(%rbp), %rax
movq %rcx, -0x1d8(%rbp)
movq 0x8(%rax), %rsi
movl 0x10(%rax), %edx
leaq -0x28(%rbp), %rdi
movq %rdi, -0x1d0(%rbp)
callq 0x6f40
movq -0x1d8(%rbp), %rdi
movq -0x1d0(%rbp), %rsi
callq 0x3240
movq %rax, -0x1c8(%rbp)
jmp 0x9351
movq -0x1c8(%rbp), %rdi
leaq 0x70f5(%rip), %rsi      # 0x10454
callq 0x3270
movq %rax, -0x1e8(%rbp)
jmp 0x936d
movq -0x1e0(%rbp), %rax
movq 0x8(%rax), %rsi
leaq -0x58(%rbp), %rdi
callq 0x6f80
jmp 0x9383
movq -0x1e8(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x3240
movq %rax, -0x1f0(%rbp)
jmp 0x939c
movq -0x1f0(%rbp), %rdi
movq 0xbc16(%rip), %rsi      # 0x14fc0
callq 0x32c0
jmp 0x93b1
leaq -0x58(%rbp), %rdi
callq 0x34b8
leaq -0x28(%rbp), %rdi
callq 0x34b8
movq -0x1e0(%rbp), %rdi
movl $0x0, -0x5c(%rbp)
addq $0x420, %rdi            # imm = 0x420
leaq 0x7274(%rip), %rsi      # 0x10653
callq 0x3270
movq %rax, %rdi
movq 0xbbd2(%rip), %rsi      # 0x14fc0
callq 0x32c0
movq -0x1e0(%rbp), %rax
cmpl $0xd, 0x10(%rax)
je 0x94d4
movq -0x1e0(%rbp), %rax
movl -0x5c(%rbp), %ecx
incl %ecx
movl %ecx, -0x5c(%rbp)
movq 0x8(%rax), %rsi
movl 0x10(%rax), %edx
leaq -0xa0(%rbp), %rdi
movq %rdi, -0x1f8(%rbp)
callq 0x6f40
movq -0x1f8(%rbp), %rdx
leaq 0x7226(%rip), %rsi      # 0x10661
leaq -0x80(%rbp), %rdi
callq 0xf1b0
jmp 0x9446
movq -0x1e0(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0x91a0
jmp 0x9458
leaq -0x80(%rbp), %rdi
callq 0x34b8
leaq -0xa0(%rbp), %rdi
callq 0x34b8
jmp 0x94d4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x9492
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x34b8
leaq -0x28(%rbp), %rdi
callq 0x34b8
jmp 0x9923
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x94c3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x34b8
leaq -0xa0(%rbp), %rdi
callq 0x34b8
jmp 0x9923
movq -0x1e0(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x5fd0
movl %eax, %ecx
movq -0x1e0(%rbp), %rax
movl %ecx, 0x10(%rax)
cmpl $0x1f, 0x10(%rax)
je 0x95a5
movq -0x1e0(%rbp), %rax
movl -0x5c(%rbp), %ecx
incl %ecx
movl %ecx, -0x5c(%rbp)
movq 0x8(%rax), %rsi
movl 0x10(%rax), %edx
leaq -0xe0(%rbp), %rdi
movq %rdi, -0x200(%rbp)
callq 0x6f40
movq -0x200(%rbp), %rdx
leaq 0x715b(%rip), %rsi      # 0x1068c
leaq -0xc0(%rbp), %rdi
callq 0xf1b0
jmp 0x953f
movq -0x1e0(%rbp), %rdi
leaq -0xc0(%rbp), %rsi
callq 0x91a0
jmp 0x9554
leaq -0xc0(%rbp), %rdi
callq 0x34b8
leaq -0xe0(%rbp), %rdi
callq 0x34b8
jmp 0x95a5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x9594
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0xc0(%rbp), %rdi
callq 0x34b8
leaq -0xe0(%rbp), %rdi
callq 0x34b8
jmp 0x9923
movq -0x1e0(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x5fd0
movl %eax, %ecx
movq -0x1e0(%rbp), %rax
movl %ecx, 0x10(%rax)
cmpl $0x1, 0x10(%rax)
je 0x9676
movq -0x1e0(%rbp), %rax
movl -0x5c(%rbp), %ecx
incl %ecx
movl %ecx, -0x5c(%rbp)
movq 0x8(%rax), %rsi
movl 0x10(%rax), %edx
leaq -0x120(%rbp), %rdi
movq %rdi, -0x208(%rbp)
callq 0x6f40
movq -0x208(%rbp), %rdx
leaq 0x70b5(%rip), %rsi      # 0x106b7
leaq -0x100(%rbp), %rdi
callq 0xf1b0
jmp 0x9610
movq -0x1e0(%rbp), %rdi
leaq -0x100(%rbp), %rsi
callq 0x91a0
jmp 0x9625
leaq -0x100(%rbp), %rdi
callq 0x34b8
leaq -0x120(%rbp), %rdi
callq 0x34b8
jmp 0x9676
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x9665
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x100(%rbp), %rdi
callq 0x34b8
leaq -0x120(%rbp), %rdi
callq 0x34b8
jmp 0x9923
movq -0x1e0(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x5fd0
movq -0x1e0(%rbp), %rdi
movl %eax, 0x10(%rdi)
callq 0xa270
movl %eax, %ecx
movq -0x1e0(%rbp), %rax
addl -0x5c(%rbp), %ecx
movl %ecx, -0x5c(%rbp)
cmpl $0x20, 0x10(%rax)
je 0x9759
movq -0x1e0(%rbp), %rax
movl -0x5c(%rbp), %ecx
incl %ecx
movl %ecx, -0x5c(%rbp)
movq 0x8(%rax), %rsi
movl 0x10(%rax), %edx
leaq -0x160(%rbp), %rdi
movq %rdi, -0x210(%rbp)
callq 0x6f40
movq -0x210(%rbp), %rdx
leaq 0x6ffc(%rip), %rsi      # 0x106e1
leaq -0x140(%rbp), %rdi
callq 0xf1b0
jmp 0x96f3
movq -0x1e0(%rbp), %rdi
leaq -0x140(%rbp), %rsi
callq 0x91a0
jmp 0x9708
leaq -0x140(%rbp), %rdi
callq 0x34b8
leaq -0x160(%rbp), %rdi
callq 0x34b8
jmp 0x9759
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x9748
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x140(%rbp), %rdi
callq 0x34b8
leaq -0x160(%rbp), %rdi
callq 0x34b8
jmp 0x9923
movq -0x1e0(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x5fd0
movq -0x1e0(%rbp), %rdi
movl %eax, 0x10(%rdi)
callq 0xa6e0
movq -0x1e0(%rbp), %rdi
addl -0x5c(%rbp), %eax
movl %eax, -0x5c(%rbp)
callq 0x9e00
movl %eax, %ecx
movq -0x1e0(%rbp), %rax
addl -0x5c(%rbp), %ecx
movl %ecx, -0x5c(%rbp)
cmpl $0x20, 0x10(%rax)
je 0x986a
movq -0x1e0(%rbp), %rax
movl -0x5c(%rbp), %ecx
incl %ecx
movl %ecx, -0x5c(%rbp)
movq 0x8(%rax), %rsi
movl 0x10(%rax), %edx
leaq -0x1a0(%rbp), %rdi
movq %rdi, -0x218(%rbp)
callq 0x6f40
movq -0x218(%rbp), %rdx
leaq 0x6f07(%rip), %rsi      # 0x106e1
leaq -0x180(%rbp), %rdi
callq 0xf1b0
jmp 0x97e8
movq -0x1e0(%rbp), %rdi
leaq -0x180(%rbp), %rsi
callq 0x91a0
jmp 0x97fd
leaq -0x180(%rbp), %rdi
callq 0x34b8
leaq -0x1a0(%rbp), %rdi
callq 0x34b8
movq -0x1e0(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x5fd0
movl %eax, %ecx
movq -0x1e0(%rbp), %rax
movl %ecx, 0x10(%rax)
jmp 0x986a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x9859
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x180(%rbp), %rdi
callq 0x34b8
leaq -0x1a0(%rbp), %rdi
callq 0x34b8
jmp 0x9923
movq -0x1e0(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x5fd0
movq -0x1e0(%rbp), %rdi
movl %eax, 0x10(%rdi)
addq $0x420, %rdi            # imm = 0x420
leaq 0x6e7a(%rip), %rsi      # 0x1070c
callq 0x3270
movq %rax, %rcx
movq -0x1e0(%rbp), %rax
movq %rcx, -0x230(%rbp)
movq 0x8(%rax), %rsi
movl 0x10(%rax), %edx
leaq -0x1c0(%rbp), %rdi
movq %rdi, -0x228(%rbp)
callq 0x6f40
movq -0x230(%rbp), %rdi
movq -0x228(%rbp), %rsi
callq 0x3240
movq %rax, -0x220(%rbp)
jmp 0x98de
movq -0x220(%rbp), %rdi
movq 0xb6d4(%rip), %rsi      # 0x14fc0
callq 0x32c0
jmp 0x98f3
leaq -0x1c0(%rbp), %rdi
callq 0x34b8
movl -0x5c(%rbp), %eax
addq $0x230, %rsp            # imm = 0x230
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x1c0(%rbp), %rdi
callq 0x34b8
movq -0x30(%rbp), %rdi
callq 0x3430
nopl (%rax)