// File: jaldhar[P]Lets-Build-a-Simple-Interpreter/calc3.cc
// Function: Interpreter::get_next_token()
Token Interpreter::get_next_token() {

    while (_current_char != '\0') {

        if (isspace(_current_char)) {
            skip_whitespace();
        }

        if (isdigit(_current_char)) {
            Token token(TOKENTYPE::INTEGER, integer());
            cerr << token << endl;
            return token;
        }

        if (_current_char == '+') {
            advance();
            Token token(TOKENTYPE::PLUS, '+');
            cerr << token << endl;
            return token;
        }

        if (_current_char == '-') {
            advance();
            Token token(TOKENTYPE::MINUS, '-');
            cerr << token << endl;
            return token;
        }

        ostringstream out;
        out << "Error parsing input. Got: " << _current_char;
        throw(out.str().c_str());
    }

    Token token(TOKENTYPE::ENDOFFILE, '\0');
    cerr << token << endl;
    return token;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1f0, %rsp            # imm = 0x1F0
movq %rdi, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x1d0(%rbp)
movq -0x1d0(%rbp), %rax
movsbl 0x10(%rax), %eax
cmpl $0x0, %eax
je 0x295f
movq -0x1d0(%rbp), %rax
movsbl 0x10(%rax), %edi
callq 0x2040
cmpl $0x0, %eax
je 0x274f
movq -0x1d0(%rbp), %rdi
callq 0x2be0
movq -0x1d0(%rbp), %rax
movsbl 0x10(%rax), %edi
callq 0x2170
cmpl $0x0, %eax
je 0x27a5
movq -0x1d0(%rbp), %rdi
callq 0x2c40
movq %rax, %rdx
leaq -0x10(%rbp), %rdi
movl $0x1, %esi
callq 0x2eb0
movq 0x3868(%rip), %rdi      # 0x5ff0
leaq -0x10(%rbp), %rsi
callq 0x2530
movq %rax, %rdi
movq 0x380d(%rip), %rsi      # 0x5fa8
callq 0x21a0
jmp 0x298d
movq -0x1d0(%rbp), %rax
movsbl 0x10(%rax), %eax
cmpl $0x2b, %eax
jne 0x27f8
movq -0x1d0(%rbp), %rdi
callq 0x2b70
leaq -0x10(%rbp), %rdi
movl $0x2, %esi
movl $0x2b, %edx
callq 0x2eb0
movq 0x3815(%rip), %rdi      # 0x5ff0
leaq -0x10(%rbp), %rsi
callq 0x2530
movq %rax, %rdi
movq 0x37ba(%rip), %rsi      # 0x5fa8
callq 0x21a0
jmp 0x298d
movq -0x1d0(%rbp), %rax
movsbl 0x10(%rax), %eax
cmpl $0x2d, %eax
jne 0x284b
movq -0x1d0(%rbp), %rdi
callq 0x2b70
leaq -0x10(%rbp), %rdi
movl $0x3, %esi
movl $0x2d, %edx
callq 0x2eb0
movq 0x37c2(%rip), %rdi      # 0x5ff0
leaq -0x10(%rbp), %rsi
callq 0x2530
movq %rax, %rdi
movq 0x3767(%rip), %rsi      # 0x5fa8
callq 0x21a0
jmp 0x298d
leaq -0x190(%rbp), %rdi
movq %rdi, -0x1e0(%rbp)
callq 0x2220
movq -0x1e0(%rbp), %rdi
leaq 0x17ee(%rip), %rsi      # 0x405a
callq 0x2180
movq %rax, -0x1d8(%rbp)
jmp 0x287a
movq -0x1d8(%rbp), %rdi
movq -0x1d0(%rbp), %rax
movsbl 0x10(%rax), %esi
callq 0x21f0
jmp 0x2893
movb $0x1, -0x1c1(%rbp)
movl $0x8, %edi
callq 0x20c0
movq %rax, -0x1e8(%rbp)
leaq -0x1c0(%rbp), %rdi
leaq -0x190(%rbp), %rsi
callq 0x2190
jmp 0x28c0
leaq -0x1c0(%rbp), %rdi
callq 0x20a0
movq -0x1e8(%rbp), %rdi
movq %rax, (%rdi)
movb $0x0, -0x1c1(%rbp)
movq 0x36cc(%rip), %rsi      # 0x5fb0
xorl %eax, %eax
movl %eax, %edx
callq 0x22a0
jmp 0x29a9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x198(%rbp)
movl %eax, -0x19c(%rbp)
jmp 0x2951
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x198(%rbp)
movl %eax, -0x19c(%rbp)
jmp 0x2938
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x198(%rbp)
movl %eax, -0x19c(%rbp)
leaq -0x1c0(%rbp), %rdi
callq 0x20e0
testb $0x1, -0x1c1(%rbp)
jne 0x2943
jmp 0x294f
movq -0x1e8(%rbp), %rdi
callq 0x2120
jmp 0x2951
leaq -0x190(%rbp), %rdi
callq 0x2070
jmp 0x299d
leaq -0x10(%rbp), %rdi
xorl %esi, %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x2eb0
movq 0x367b(%rip), %rdi      # 0x5ff0
leaq -0x10(%rbp), %rsi
callq 0x2530
movq %rax, %rdi
movq 0x3620(%rip), %rsi      # 0x5fa8
callq 0x21a0
movl -0x10(%rbp), %eax
movq -0x8(%rbp), %rdx
addq $0x1f0, %rsp            # imm = 0x1F0
popq %rbp
retq
movq -0x198(%rbp), %rdi
callq 0x22b0
nopl (%rax)