// File: kram[P]kram/./src/lexer/lexer.cpp
// Function: lexer::Lexer::name()
Token* Lexer::name() {
	std::string s(1, this->current);

	while (true) {
		char c = this->char_at_pos(this->index + 1);

		// After the beginning, a name can be a-Z0-9_
		if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') || c == '_') {
			s += c;
			this->index += 1;
		} else {
			break;
		}
	}

	if (s == "true" || s == "false") {
		return new Token(Type::BOOL, s);
	}

	if (this->keywords.find(s) != this->keywords.end()) {
		return new Token(Type::KEYWORD, s);
	}

	return new Token(Type::NAME, s);
}

// Assembly:
subq $0x118, %rsp            # imm = 0x118
movq %rdi, 0x108(%rsp)
movq 0x108(%rsp), %rax
movq %rax, 0x30(%rsp)
movsbl 0x60(%rax), %eax
movl %eax, 0x3c(%rsp)
leaq 0xe7(%rsp), %rdi
movq %rdi, 0x40(%rsp)
callq 0x34a0
movl 0x3c(%rsp), %edx
movq 0x40(%rsp), %rcx
leaq 0xe8(%rsp), %rdi
movl $0x1, %esi
callq 0x3210
jmp 0x8343
leaq 0xe7(%rsp), %rdi
callq 0x3310
jmp 0x8352
movq 0x30(%rsp), %rdi
movq 0x58(%rdi), %rsi
incq %rsi
callq 0x81e0
movb %al, 0x2f(%rsp)
jmp 0x8369
movb 0x2f(%rsp), %al
movb %al, 0xd3(%rsp)
movsbl 0xd3(%rsp), %eax
cmpl $0x61, %eax
jl 0x838e
movsbl 0xd3(%rsp), %eax
cmpl $0x7a, %eax
jle 0x83cf
movsbl 0xd3(%rsp), %eax
cmpl $0x41, %eax
jl 0x83a8
movsbl 0xd3(%rsp), %eax
cmpl $0x5a, %eax
jle 0x83cf
movsbl 0xd3(%rsp), %eax
cmpl $0x30, %eax
jl 0x83c2
movsbl 0xd3(%rsp), %eax
cmpl $0x39, %eax
jle 0x83cf
movsbl 0xd3(%rsp), %eax
cmpl $0x5f, %eax
jne 0x8438
movsbl 0xd3(%rsp), %esi
leaq 0xe8(%rsp), %rdi
callq 0x3200
jmp 0x83e6
movq 0x30(%rsp), %rax
movq 0x58(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x58(%rax)
jmp 0x843a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd8(%rsp)
movl %eax, 0xd4(%rsp)
leaq 0xe7(%rsp), %rdi
callq 0x3310
jmp 0x8741
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd8(%rsp)
movl %eax, 0xd4(%rsp)
jmp 0x8734
jmp 0x843f
jmp 0x8350
leaq 0x22e05(%rip), %rsi     # 0x2b24b
leaq 0xe8(%rsp), %rdi
callq 0x4070
movb %al, 0x2e(%rsp)
jmp 0x8459
movb 0x2e(%rsp), %al
testb $0x1, %al
jne 0x848a
jmp 0x8463
leaq 0x22de6(%rip), %rsi     # 0x2b250
leaq 0xe8(%rsp), %rdi
callq 0x4070
movb %al, 0x2d(%rsp)
jmp 0x847d
movb 0x2d(%rsp), %al
testb $0x1, %al
jne 0x848a
jmp 0x8557
movl $0x28, %edi
callq 0x32e0
movq %rax, 0x20(%rsp)
jmp 0x849b
movb $0x1, 0xaf(%rsp)
leaq 0xb0(%rsp), %rdi
leaq 0xe8(%rsp), %rsi
callq 0x3140
jmp 0x84ba
movq 0x20(%rsp), %rdi
movl $0x6, %esi
leaq 0xb0(%rsp), %rdx
callq 0xaf60
jmp 0x84d3
movq 0x20(%rsp), %rax
movb $0x0, 0xaf(%rsp)
movq %rax, 0x110(%rsp)
leaq 0xb0(%rsp), %rdi
callq 0x31f0
movl $0x1, 0xa8(%rsp)
jmp 0x8717
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd8(%rsp)
movl %eax, 0xd4(%rsp)
jmp 0x853c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd8(%rsp)
movl %eax, 0xd4(%rsp)
leaq 0xb0(%rsp), %rdi
callq 0x31f0
testb $0x1, 0xaf(%rsp)
jne 0x8548
jmp 0x8552
movq 0x20(%rsp), %rdi
callq 0x32b0
jmp 0x8734
movq 0x30(%rsp), %rdi
leaq 0xe8(%rsp), %rsi
callq 0x9050
movq %rax, 0x18(%rsp)
jmp 0x8570
movq 0x30(%rsp), %rdi
movq 0x18(%rsp), %rax
movq %rax, 0xa0(%rsp)
callq 0x9080
movq %rax, 0x98(%rsp)
leaq 0xa0(%rsp), %rdi
leaq 0x98(%rsp), %rsi
callq 0x9030
testb $0x1, %al
jne 0x85ad
jmp 0x8665
movl $0x28, %edi
callq 0x32e0
movq %rax, 0x10(%rsp)
jmp 0x85be
movb $0x1, 0x77(%rsp)
leaq 0x78(%rsp), %rdi
leaq 0xe8(%rsp), %rsi
callq 0x3140
jmp 0x85d7
movq 0x10(%rsp), %rdi
movl $0x9, %esi
leaq 0x78(%rsp), %rdx
callq 0xaf60
jmp 0x85ed
movq 0x10(%rsp), %rax
movb $0x0, 0x77(%rsp)
movq %rax, 0x110(%rsp)
leaq 0x78(%rsp), %rdi
callq 0x31f0
movl $0x1, 0xa8(%rsp)
jmp 0x8717
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd8(%rsp)
movl %eax, 0xd4(%rsp)
jmp 0x864d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd8(%rsp)
movl %eax, 0xd4(%rsp)
leaq 0x78(%rsp), %rdi
callq 0x31f0
testb $0x1, 0x77(%rsp)
jne 0x8656
jmp 0x8660
movq 0x10(%rsp), %rdi
callq 0x32b0
jmp 0x8734
movl $0x28, %edi
callq 0x32e0
movq %rax, 0x8(%rsp)
jmp 0x8676
movb $0x1, 0x4f(%rsp)
leaq 0x50(%rsp), %rdi
leaq 0xe8(%rsp), %rsi
callq 0x3140
jmp 0x868f
movq 0x8(%rsp), %rdi
movl $0x5, %esi
leaq 0x50(%rsp), %rdx
callq 0xaf60
jmp 0x86a5
movq 0x8(%rsp), %rax
movb $0x0, 0x4f(%rsp)
movq %rax, 0x110(%rsp)
leaq 0x50(%rsp), %rdi
callq 0x31f0
movl $0x1, 0xa8(%rsp)
jmp 0x8717
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd8(%rsp)
movl %eax, 0xd4(%rsp)
jmp 0x8702
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd8(%rsp)
movl %eax, 0xd4(%rsp)
leaq 0x50(%rsp), %rdi
callq 0x31f0
testb $0x1, 0x4f(%rsp)
jne 0x870b
jmp 0x8715
movq 0x8(%rsp), %rdi
callq 0x32b0
jmp 0x8734
leaq 0xe8(%rsp), %rdi
callq 0x31f0
movq 0x110(%rsp), %rax
addq $0x118, %rsp            # imm = 0x118
retq
leaq 0xe8(%rsp), %rdi
callq 0x31f0
movq 0xd8(%rsp), %rdi
callq 0x3490
nop