// File: Blaze2305[P]Compiler-Design-2021-Assignment/src/Scanner/Scanner.cpp
// Function: Scanner::scanToken()
TokenType Scanner::scanToken(){
	TokenType result;
	switch(this->currentChar){
		case ')':
			result = RParen;
			acceptChar();
			break;
		case '(':
			result = LParen;
			acceptChar();
			break;
		case '\u0000':
			result = EOT;
			break;
		default:
			if(isLetter(this->currentChar)){
				while(isLetter(this->currentChar)){
					acceptChar();
					if(isKeyword(this->currentString)){
						try{
							result = TOKEN_MAP.at(this->currentString);
						}catch(std::out_of_range err){
							result = Identifier;
						}
					}else if(isType(this->currentString)){
						result = Type;
					}else if(isStatement(this->currentString)){
						try{
							result = TOKEN_MAP.at(this->currentString);
						}catch(std::out_of_range err){
							result = Statement;
						}
					}else if(isConditional(this->currentString)){
						result = Conditional;
					}else{
						result = Identifier;
					}
				}
			}else if(isDigit(this->currentChar)){
				while(isDigit(this->currentChar)){
					acceptChar();
					result = Number;
				}
			}else if(isOperator(std::string(1,this->currentChar))){
				while(isOperator(std::string(1,this->currentChar))){
					acceptChar();
				}
				
				// get semicolon ,assignment and colon
				try{
					result = TOKEN_MAP.at(this->currentString);
				}catch(std::out_of_range err){
					if(isOperator(this->currentString)){
						result = Operator;
					}else{
						result = None;
					}
				}
			}
			else{
				result = None;
			}
			break;
	}
	return result;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1f0, %rsp            # imm = 0x1F0
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x150(%rbp)
movsbl (%rax), %eax
movl %eax, -0x144(%rbp)
testl %eax, %eax
je 0x11b33
jmp 0x11ae9
movl -0x144(%rbp), %eax
subl $0x28, %eax
je 0x11b1b
jmp 0x11af6
movl -0x144(%rbp), %eax
subl $0x29, %eax
jne 0x11b3f
jmp 0x11b03
movq -0x150(%rbp), %rdi
movl $0x7, -0xc(%rbp)
callq 0x119f0
jmp 0x1213e
movq -0x150(%rbp), %rdi
movl $0x6, -0xc(%rbp)
callq 0x119f0
jmp 0x1213e
movl $0x8, -0xc(%rbp)
jmp 0x1213e
movq -0x150(%rbp), %rax
movsbl (%rax), %edi
callq 0x15210
testb $0x1, %al
jne 0x11b57
jmp 0x11e54
jmp 0x11b59
movq -0x150(%rbp), %rax
movsbl (%rax), %edi
callq 0x15210
testb $0x1, %al
jne 0x11b71
jmp 0x11e4f
movq -0x150(%rbp), %rdi
callq 0x119f0
movq -0x150(%rbp), %rsi
addq $0x8, %rsi
leaq -0x30(%rbp), %rdi
movq %rdi, -0x160(%rbp)
callq 0x3120
movq -0x160(%rbp), %rdi
callq 0x15460
movb %al, -0x151(%rbp)
jmp 0x11bac
leaq -0x30(%rbp), %rdi
callq 0x3558
movb -0x151(%rbp), %al
testb $0x1, %al
jne 0x11bc4
jmp 0x11c6a
movq -0x150(%rbp), %rsi
addq $0x8, %rsi
leaq 0x11f5a(%rip), %rdi     # 0x23b30
callq 0x122d0
movq %rax, -0x168(%rbp)
jmp 0x11be4
movq -0x168(%rbp), %rax
movl (%rax), %eax
movl %eax, -0xc(%rbp)
jmp 0x11c65
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x3558
jmp 0x1214a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
movl $0x1, %ecx
cmpl %ecx, %eax
jne 0x1214a
movq -0x38(%rbp), %rdi
movq %rdi, -0x170(%rbp)
callq 0x33a0
movq %rax, %rsi
leaq -0x50(%rbp), %rdi
callq 0x12370
movq -0x170(%rbp), %rdi
callq 0x30f0
movl $0x0, -0xc(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x3420
callq 0x3480
jmp 0x11e4a
movq -0x150(%rbp), %rsi
addq $0x8, %rsi
leaq -0x70(%rbp), %rdi
movq %rdi, -0x180(%rbp)
callq 0x3120
movq -0x180(%rbp), %rdi
callq 0x152e0
movb %al, -0x171(%rbp)
jmp 0x11c99
leaq -0x70(%rbp), %rdi
callq 0x3558
movb -0x171(%rbp), %al
testb $0x1, %al
jne 0x11cae
jmp 0x11cd4
movl $0x2, -0xc(%rbp)
jmp 0x11e48
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x70(%rbp), %rdi
callq 0x3558
jmp 0x1214a
movq -0x150(%rbp), %rsi
addq $0x8, %rsi
leaq -0x90(%rbp), %rdi
movq %rdi, -0x190(%rbp)
callq 0x3120
movq -0x190(%rbp), %rdi
callq 0x15350
movb %al, -0x181(%rbp)
jmp 0x11d06
leaq -0x90(%rbp), %rdi
callq 0x3558
movb -0x181(%rbp), %al
testb $0x1, %al
jne 0x11d21
jmp 0x11dcd
movq -0x150(%rbp), %rsi
addq $0x8, %rsi
leaq 0x11dfd(%rip), %rdi     # 0x23b30
callq 0x122d0
movq %rax, -0x198(%rbp)
jmp 0x11d41
movq -0x198(%rbp), %rax
movl (%rax), %eax
movl %eax, -0xc(%rbp)
jmp 0x11dcb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x90(%rbp), %rdi
callq 0x3558
jmp 0x1214a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
movl $0x1, %ecx
cmpl %ecx, %eax
jne 0x1214a
movq -0x38(%rbp), %rdi
movq %rdi, -0x1a0(%rbp)
callq 0x33a0
movq %rax, %rsi
leaq -0xa0(%rbp), %rdi
callq 0x12370
movq -0x1a0(%rbp), %rdi
callq 0x30f0
movl $0x5, -0xc(%rbp)
leaq -0xa0(%rbp), %rdi
callq 0x3420
callq 0x3480
jmp 0x11e46
movq -0x150(%rbp), %rsi
addq $0x8, %rsi
leaq -0xc0(%rbp), %rdi
movq %rdi, -0x1b0(%rbp)
callq 0x3120
movq -0x1b0(%rbp), %rdi
callq 0x153c0
movb %al, -0x1a1(%rbp)
jmp 0x11dff
leaq -0xc0(%rbp), %rdi
callq 0x3558
movb -0x1a1(%rbp), %al
testb $0x1, %al
jne 0x11e17
jmp 0x11e3d
movl $0x9, -0xc(%rbp)
jmp 0x11e44
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0xc0(%rbp), %rdi
callq 0x3558
jmp 0x1214a
movl $0x0, -0xc(%rbp)
jmp 0x11e46
jmp 0x11e48
jmp 0x11e4a
jmp 0x11b59
jmp 0x1213c
movq -0x150(%rbp), %rax
movsbl (%rax), %edi
callq 0x151e0
testb $0x1, %al
jne 0x11e69
jmp 0x11e9a
jmp 0x11e6b
movq -0x150(%rbp), %rax
movsbl (%rax), %edi
callq 0x151e0
testb $0x1, %al
jne 0x11e80
jmp 0x11e95
movq -0x150(%rbp), %rdi
callq 0x119f0
movl $0x1, -0xc(%rbp)
jmp 0x11e6b
jmp 0x1213a
movq -0x150(%rbp), %rax
movsbl (%rax), %eax
movl %eax, -0x1bc(%rbp)
leaq -0xe1(%rbp), %rdi
movq %rdi, -0x1b8(%rbp)
callq 0x3510
movl -0x1bc(%rbp), %edx
movq -0x1b8(%rbp), %rcx
leaq -0xe0(%rbp), %rdi
movl $0x1, %esi
callq 0x123b0
jmp 0x11edd
leaq -0xe0(%rbp), %rdi
callq 0x15270
movb %al, -0x1bd(%rbp)
jmp 0x11ef1
leaq -0xe0(%rbp), %rdi
callq 0x3558
leaq -0xe1(%rbp), %rdi
callq 0x3300
movb -0x1bd(%rbp), %al
testb $0x1, %al
jne 0x11f18
jmp 0x12131
jmp 0x11f1a
movq -0x150(%rbp), %rax
movsbl (%rax), %eax
movl %eax, -0x1cc(%rbp)
leaq -0x109(%rbp), %rdi
movq %rdi, -0x1c8(%rbp)
callq 0x3510
movl -0x1cc(%rbp), %edx
movq -0x1c8(%rbp), %rcx
leaq -0x108(%rbp), %rdi
movl $0x1, %esi
callq 0x123b0
jmp 0x11f5d
leaq -0x108(%rbp), %rdi
callq 0x15270
movb %al, -0x1cd(%rbp)
jmp 0x11f71
leaq -0x108(%rbp), %rdi
callq 0x3558
leaq -0x109(%rbp), %rdi
callq 0x3300
movb -0x1cd(%rbp), %al
testb $0x1, %al
jne 0x11f95
jmp 0x12014
movq -0x150(%rbp), %rdi
callq 0x119f0
jmp 0x11f1a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x11fcc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0xe0(%rbp), %rdi
callq 0x3558
leaq -0xe1(%rbp), %rdi
callq 0x3300
jmp 0x1214a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x12003
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x108(%rbp), %rdi
callq 0x3558
leaq -0x109(%rbp), %rdi
callq 0x3300
jmp 0x1214a
movq -0x150(%rbp), %rsi
addq $0x8, %rsi
leaq 0x11b0a(%rip), %rdi     # 0x23b30
callq 0x122d0
movq %rax, -0x1d8(%rbp)
jmp 0x12034
movq -0x1d8(%rbp), %rax
movl (%rax), %eax
movl %eax, -0xc(%rbp)
jmp 0x1211a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
movl $0x1, %ecx
cmpl %ecx, %eax
jne 0x1214a
movq -0x38(%rbp), %rdi
movq %rdi, -0x1e0(%rbp)
callq 0x33a0
movq %rax, %rsi
leaq -0x120(%rbp), %rdi
callq 0x12370
movq -0x1e0(%rbp), %rdi
callq 0x30f0
movq -0x150(%rbp), %rsi
addq $0x8, %rsi
leaq -0x140(%rbp), %rdi
callq 0x3120
jmp 0x120a5
leaq -0x140(%rbp), %rdi
callq 0x15270
movb %al, -0x1e1(%rbp)
jmp 0x120b9
leaq -0x140(%rbp), %rdi
callq 0x3558
movb -0x1e1(%rbp), %al
testb $0x1, %al
jne 0x120d1
jmp 0x12102
movl $0x3, -0xc(%rbp)
jmp 0x12109
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x1211c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x140(%rbp), %rdi
callq 0x3558
jmp 0x1211c
movl $0x16, -0xc(%rbp)
leaq -0x120(%rbp), %rdi
callq 0x3420
callq 0x3480
jmp 0x12138
leaq -0x120(%rbp), %rdi
callq 0x3420
callq 0x3480
jmp 0x1212f
jmp 0x1214a
movl $0x16, -0xc(%rbp)
jmp 0x1213a
jmp 0x1213c
jmp 0x1213e
movl -0xc(%rbp), %eax
addq $0x1f0, %rsp            # imm = 0x1F0
popq %rbp
retq
movq -0x38(%rbp), %rdi
callq 0x3500
movq %rax, %rdi
callq 0xbc80
nopl (%rax,%rax)