// File: /workspace/github_cpp_makefile_star2_O2/CoinXu[P]reviser-compiler/src/tokenizer.cpp
// Function: reviser::compiler::Tokenizer::Next()
bool Tokenizer::Next() {
  previous = current;

  if (pos >= input.size()) {
    current.type = TOKEN_CODE_END;
    current.text = "";
    return false;
  }

  ConsumeCharacters<Whitespace>();
  ConsumeComment();

  current.text = peek;

  int start_line = line;
  int start_column = column;
  int start_pos = pos;

  switch (peek) {
    case EOF:
      current.type = TOKEN_CODE_END;
      current.text = "";
      break;

    case TOKEN_ASSIGN:
    case TOKEN_LEFT_BRACE:
    case TOKEN_RIGHT_BRACE:
    case TOKEN_SEMICOLON:
    case TOKEN_COMMA:
    case TOKEN_CONNECTION:
    case TOKEN_LEFT_BRACKET:
    case TOKEN_RIGHT_BRACKET:
      current.type = (TokenType)peek;
      NextChar();
      break;

    case TOKEN_QUOTE:
      current.type = TOKEN_LETTER;
      NextChar();
      TryConsumeCharacters<CharQuote>();
      NextChar();
      current.text = input.substr(start_pos, pos - start_pos - 2);
      break;

    case TOKEN_PLUS:
    case TOKEN_HYPHEN:
      current.type = TOKEN_DIGIT;
      NextChar();
      ConsumeNumber();
      current.text = input.substr(start_pos - 1, pos - start_pos);
      break;

    default:
      if (InCharacters<CharDigit>()) {
        current.type = TOKEN_DIGIT;
        ConsumeNumber();
        current.text = input.substr(start_pos - 1, pos - start_pos);
      } else if (InCharacters<Identifier>()) {
        ConsumeCharacters<Identifier>();
        current.text = input.substr(start_pos - 1, pos - start_pos);

        if (TypeIdentifier(current.text)) {
          current.type = TOKEN_DATA_TYPE;
        } else if (DecoraterIdentifier(current.text)) {
          current.type = TOKEN_DECORATER;
        } else if (current.text == ReservedWordMap[RESERVED_STRUCT]) {
          current.type = TOKEN_STRUCT;
        } else if (current.text == ReservedWordMap[RESERVED_ENUM]) {
          current.type = TOKEN_ENUM;
        } else {
          current.type = TOKEN_ID;
        }
      } else {
        TryConsumeCharacters<NewLine>();
        const string content = input.substr(start_pos - 1,  pos - start_pos);
        message.Runtime("unkown token error: \n  " + content + "\n  ^");
      }
  }

  current.start_line = start_line;
  current.end_line = line;
  current.column_start = start_column;
  current.column_end = column - 1;
  current.pos_start = start_pos;
  current.pos_end = pos;

  return current.type != TOKEN_CODE_END;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb8, %rsp
movq %rdi, %rbx
leaq 0x78(%rdi), %r15
addq $0xb8, %rdi
movq %r15, %rsi
callq 0x3ccc2
movslq 0xfc(%rbx), %rax
cmpq %rax, 0x8(%rbx)
jbe 0x3dd79
movq %rbx, %rdi
callq 0x3e44c
movq %rbx, %rdi
callq 0x3d980
movsbl 0xf8(%rbx), %esi
leaq 0x80(%rbx), %r14
movq %r14, %rdi
callq 0x35590
movl 0xfc(%rbx), %r13d
movl 0x100(%rbx), %edi
movl 0x104(%rbx), %esi
movslq %r13d, %r12
movzbl 0xf8(%rbx), %eax
leal -0x2b(%rax), %ecx
cmpl $0x3, %ecx
jbe 0x3dd9a
leal -0x3b(%rax), %ecx
cmpl $0x22, %ecx
ja 0x3dd2c
movabsq $0x500000005, %rdx      # imm = 0x500000005
btq %rcx, %rdx
jb 0x3ddd6
cmpl $0x22, %eax
je 0x3ddf2
cmpl $0x7b, %eax
je 0x3ddd6
cmpl $0x7d, %eax
je 0x3ddd6
cmpl $0xff, %eax
jne 0x3de56
movl $0x9, (%r15)
movl %esi, %r15d
leaq 0x1addc(%rip), %rsi     # 0x58b3f
movl %edi, %r12d
movq %r14, %rdi
callq 0x35650
movl %r12d, %eax
movl %r15d, %ecx
jmp 0x3dfac
movl $0x9, 0x78(%rbx)
subq $-0x80, %rbx
leaq 0x1adb4(%rip), %rsi     # 0x58b3f
movq %rbx, %rdi
callq 0x35650
xorl %eax, %eax
jmp 0x3dfee
leaq 0x199e7(%rip), %rdx     # 0x57788
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
movl $0x6, 0x78(%rbx)
movl %edi, -0x2c(%rbp)
movq %rbx, %rdi
movl %esi, -0x30(%rbp)
callq 0x3d844
movq %rbx, %rdi
callq 0x3da0a
movslq 0xfc(%rbx), %rcx
subq %r12, %rcx
decq %r12
jmp 0x3de26
movl %eax, 0x78(%rbx)
movl %edi, %r15d
movq %rbx, %rdi
movl %esi, %r14d
callq 0x3d844
movl %r15d, %eax
movl %r14d, %ecx
jmp 0x3dfac
movl $0x5, 0x78(%rbx)
movl %edi, -0x2c(%rbp)
movq %rbx, %rdi
movl %esi, -0x30(%rbp)
callq 0x3d844
movq %rbx, %rdi
callq 0x3e50e
movq %rbx, %rdi
callq 0x3d844
movl 0xfc(%rbx), %eax
subl %r12d, %eax
addl $-0x2, %eax
movslq %eax, %rcx
leaq -0x58(%rbp), %r15
movq %r15, %rdi
movq %rbx, %rsi
movq %r12, %rdx
callq 0x35360
movq %r14, %rdi
movq %r15, %rsi
callq 0x35400
movq %r15, %rdi
callq 0x35180
movl -0x2c(%rbp), %eax
movl -0x30(%rbp), %ecx
jmp 0x3dfac
movl %edi, -0x2c(%rbp)
movl %esi, -0x30(%rbp)
addl $-0x30, %eax
cmpb $0x9, %al
ja 0x3dea4
movl $0x6, 0x78(%rbx)
movq %rbx, %rdi
callq 0x3da0a
movslq 0xfc(%rbx), %rcx
subq %r12, %rcx
decq %r12
leaq -0x58(%rbp), %r15
movq %r15, %rdi
movq %rbx, %rsi
movq %r12, %rdx
callq 0x35360
movq %r14, %rdi
movq %r15, %rsi
callq 0x35400
movq %r15, %rdi
jmp 0x3dfa1
movq %rbx, %rdi
callq 0x3e532
leaq -0x1(%r12), %rcx
movq %rcx, -0x38(%rbp)
movq %rbx, %rdi
testb %al, %al
je 0x3df2c
callq 0x3e544
movslq 0xfc(%rbx), %rcx
subq %r12, %rcx
leaq -0x58(%rbp), %r12
movq %r12, %rdi
movq %rbx, %rsi
movq -0x38(%rbp), %rdx
callq 0x35360
movq %r14, %rdi
movq %r12, %rsi
callq 0x35400
movq %r12, %rdi
callq 0x35180
leaq -0xd8(%rbp), %r12
movq %r12, %rdi
movq %r14, %rsi
callq 0x35470
movq %rbx, %rdi
movq %r12, %rsi
callq 0x3d930
movl %eax, %r12d
leaq -0xd8(%rbp), %rdi
callq 0x35180
testb %r12b, %r12b
je 0x3e000
andl $0x0, (%r15)
jmp 0x3dfa6
callq 0x3e404
movslq 0xfc(%rbx), %rcx
subq %r12, %rcx
leaq -0x58(%rbp), %r14
movq %r14, %rdi
movq %rbx, %rsi
movq -0x38(%rbp), %rdx
callq 0x35360
leaq 0x19941(%rip), %rsi     # 0x57896
leaq -0x78(%rbp), %rdi
movq %r14, %rdx
callq 0x3aa1e
leaq 0x19946(%rip), %rdx     # 0x578ae
leaq -0x98(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0x38f1f
leaq 0x50(%rbx), %rdi
leaq -0x98(%rbp), %rsi
callq 0x3a8c2
leaq -0x98(%rbp), %rdi
callq 0x35180
leaq -0x78(%rbp), %rdi
callq 0x35180
leaq -0x58(%rbp), %rdi
callq 0x35180
movl -0x30(%rbp), %ecx
movl -0x2c(%rbp), %eax
movl %eax, 0xa0(%rbx)
movl 0x100(%rbx), %eax
movl %eax, 0xa4(%rbx)
movl %ecx, 0xa8(%rbx)
movl 0x104(%rbx), %eax
decl %eax
movl %eax, 0xac(%rbx)
movl %r13d, 0xb0(%rbx)
movl 0x78(%rbx), %eax
movl 0xfc(%rbx), %ecx
movl %ecx, 0xb4(%rbx)
cmpl $0x9, %eax
setne %al
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq -0xb8(%rbp), %r12
movq %r12, %rdi
movq %r14, %rsi
callq 0x35470
movq %rbx, %rdi
movq %r12, %rsi
callq 0x3d958
movl %eax, %r12d
leaq -0xb8(%rbp), %rdi
callq 0x35180
testb %r12b, %r12b
je 0x3e03d
movl $0x1, (%r15)
jmp 0x3dfa6
leaq -0x58(%rbp), %rsi
andl $0x0, (%rsi)
leaq 0x2e8b5(%rip), %rdi     # 0x6c900
callq 0x39c9c
movq %r14, %rdi
movq %rax, %rsi
callq 0x39c78
testb %al, %al
je 0x3e06b
movl $0x2, (%r15)
jmp 0x3dfa6
leaq -0x58(%rbp), %rsi
movl $0x1, (%rsi)
leaq 0x2e884(%rip), %rdi     # 0x6c900
callq 0x39c9c
movq %r14, %rdi
movq %rax, %rsi
callq 0x39c78
testb %al, %al
je 0x3e09c
movl $0x3, (%r15)
jmp 0x3dfa6
movl $0x4, (%r15)
jmp 0x3dfa6
movq %rax, %rbx
leaq -0xb8(%rbp), %rdi
jmp 0x3e0e6
movq %rax, %rbx
leaq -0x98(%rbp), %rdi
callq 0x35180
jmp 0x3e0c8
movq %rax, %rbx
leaq -0x78(%rbp), %rdi
callq 0x35180
jmp 0x3e0d6
movq %rax, %rbx
leaq -0x58(%rbp), %rdi
jmp 0x3e0e6
movq %rax, %rbx
leaq -0xd8(%rbp), %rdi
callq 0x35180
movq %rbx, %rdi
callq 0x355f0
nop