// File: kram[P]kram/./src/lexer/lexer.cpp
// Function: lexer::Lexer::string()
Token* Lexer::string() {
	std::string s = "";

	this->index += 1;

	while(true) {

		// End of string
		if (this->char_at_pos(this->index) == '"') {
			break;
		}

		// Escaping
		if (this->char_at_pos(this->index) == '\\') {

			// In case of eg. \n or \t

			switch (this->char_at_pos(this->index + 1)) {
				case 't': s += '\t'; break;
				case 'n': s += '\n'; break;
				case 'r': s += '\r'; break;
				default: 
					s += this->char_at_pos(this->index + 1);
					break;
			}

			this->index += 2;
			continue;
		}

		s += this->char_at_pos(this->index);
		this->index += 1;
	}

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

// Assembly:
subq $0x98, %rsp
movq %rdi, 0x90(%rsp)
movq 0x90(%rsp), %rax
movq %rax, 0x20(%rsp)
leaq 0x6f(%rsp), %rdi
movq %rdi, 0x28(%rsp)
callq 0x34a0
movq 0x28(%rsp), %rdx
leaq 0x22eeb(%rip), %rsi     # 0x2b862
leaq 0x70(%rsp), %rdi
callq 0x3390
jmp 0x8983
leaq 0x6f(%rsp), %rdi
callq 0x3310
movq 0x20(%rsp), %rax
movq 0x58(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x58(%rax)
jmp 0x89a0
movq 0x20(%rsp), %rdi
movq 0x58(%rdi), %rsi
callq 0x81e0
movb %al, 0x1f(%rsp)
jmp 0x89b4
movb 0x1f(%rsp), %al
movsbl %al, %eax
cmpl $0x22, %eax
jne 0x89f5
jmp 0x8b10
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x60(%rsp)
movl %eax, 0x5c(%rsp)
leaq 0x6f(%rsp), %rdi
callq 0x3310
jmp 0x8bba
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x60(%rsp)
movl %eax, 0x5c(%rsp)
jmp 0x8bb0
movq 0x20(%rsp), %rdi
movq 0x58(%rdi), %rsi
callq 0x81e0
movb %al, 0x1e(%rsp)
jmp 0x8a09
movb 0x1e(%rsp), %al
movsbl %al, %eax
cmpl $0x5c, %eax
jne 0x8ad3
movq 0x20(%rsp), %rdi
movq 0x58(%rdi), %rsi
incq %rsi
callq 0x81e0
movb %al, 0x1d(%rsp)
jmp 0x8a30
movb 0x1d(%rsp), %al
movsbl %al, %eax
movl %eax, 0x18(%rsp)
subl $0x6e, %eax
je 0x8a6b
jmp 0x8a42
movl 0x18(%rsp), %eax
subl $0x72, %eax
je 0x8a7e
jmp 0x8a4d
movl 0x18(%rsp), %eax
subl $0x74, %eax
jne 0x8a91
jmp 0x8a58
leaq 0x70(%rsp), %rdi
movl $0x9, %esi
callq 0x3200
jmp 0x8a69
jmp 0x8abd
leaq 0x70(%rsp), %rdi
movl $0xa, %esi
callq 0x3200
jmp 0x8a7c
jmp 0x8abd
leaq 0x70(%rsp), %rdi
movl $0xd, %esi
callq 0x3200
jmp 0x8a8f
jmp 0x8abd
movq 0x20(%rsp), %rdi
movq 0x58(%rdi), %rsi
incq %rsi
callq 0x81e0
movb %al, 0x17(%rsp)
jmp 0x8aa8
movb 0x17(%rsp), %al
movsbl %al, %esi
leaq 0x70(%rsp), %rdi
callq 0x3200
jmp 0x8abb
jmp 0x8abd
movq 0x20(%rsp), %rax
movq 0x58(%rax), %rcx
addq $0x2, %rcx
movq %rcx, 0x58(%rax)
jmp 0x899e
movq 0x20(%rsp), %rdi
movq 0x58(%rdi), %rsi
callq 0x81e0
movb %al, 0x16(%rsp)
jmp 0x8ae7
movb 0x16(%rsp), %al
movsbl %al, %esi
leaq 0x70(%rsp), %rdi
callq 0x3200
jmp 0x8afa
movq 0x20(%rsp), %rax
movq 0x58(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x58(%rax)
jmp 0x899e
movl $0x28, %edi
callq 0x32e0
movq %rax, 0x8(%rsp)
jmp 0x8b21
movb $0x1, 0x37(%rsp)
leaq 0x38(%rsp), %rdi
leaq 0x70(%rsp), %rsi
callq 0x3140
jmp 0x8b37
movq 0x8(%rsp), %rdi
movl $0x3, %esi
leaq 0x38(%rsp), %rdx
callq 0xaf60
jmp 0x8b4d
movb $0x0, 0x37(%rsp)
leaq 0x38(%rsp), %rdi
callq 0x31f0
leaq 0x70(%rsp), %rdi
callq 0x31f0
movq 0x8(%rsp), %rax
addq $0x98, %rsp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x60(%rsp)
movl %eax, 0x5c(%rsp)
jmp 0x8b9b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x60(%rsp)
movl %eax, 0x5c(%rsp)
leaq 0x38(%rsp), %rdi
callq 0x31f0
testb $0x1, 0x37(%rsp)
jne 0x8ba4
jmp 0x8bae
movq 0x8(%rsp), %rdi
callq 0x32b0
jmp 0x8bb0
leaq 0x70(%rsp), %rdi
callq 0x31f0
movq 0x60(%rsp), %rdi
callq 0x3490
nopw %cs:(%rax,%rax)