// File: /workspace/github_cpp_makefile_star2_O1/princelab[P]emass/parser.cpp
// Function: Parser::Tokenizer::get_token()
void Parser::Tokenizer::get_token()
{
  States s = START;
  _last = _i;
  for(;;)
    {
      wchar_t c = _input[_i];
      switch(s) {
      case START:
	if(iswspace(c)) {
	  ; // skip whitespace
	} else if(iswdigit(c) || c == L'-') {
	  _ttype = NUM;	
	  _tval = c;
	  s = NUMBER;
	} else if(iswupper(c)) {
	  _ttype = ELEMENT;
	  _tval = c;
	  s = ALPHA;
	} else if(c == L'[') {
	  _ttype = ELEMENT;
	  _tval = L"";
	  s = LITERAL;
	} else if(c == L'(') {
	  _ttype = LPAREN;
	  s = STOP;
	} else if(c == L')') {
	  _ttype = RPAREN;
	  s = STOP;
	} else if(c == L'%') {
	  _ttype = EOS;
	  s = END;
	} else {
	  error(L"Parse error");
	}
	break;
      case ALPHA:
	if(iswlower(c)) {
	  _tval += c;
	} else {
	  return; // we're done
	}
	break;
      case LITERAL:
	if(c == L'%') {
	  error(L"Missing left bracket");
	} else if(c != L']') {
	  _tval += c;
	} else {
	  ++_i; // skip the ']'
	  return; // we're done
	}	
	break;
      case NUMBER:
	if(iswdigit(c)) {
	  _tval += c;
	} else {
	  return; // we're done
	}
	break;
      case END:
	if(_input.find(ENDTOKEN) == _i - 1) {
	  s = STOP;
	} else {
	  error(L"Illegal character: \'%\'");
	}
	break;
      case STOP:
	return; // exit
      }
      ++_i;
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rdi, %rbx
movq 0x28(%rdi), %rax
movq %rax, 0x30(%rdi)
leaq 0x38(%rdi), %r14
leaq 0x8(%rdi), %r15
xorl %eax, %eax
leaq 0x25b8(%rip), %r13      # 0x8178
movq 0x28(%rbx), %rdx
movq 0x38(%rbx), %rcx
movl (%rcx,%rdx,4), %ebp
xorl %r12d, %r12d
movl %eax, %ecx
movslq (%r13,%rcx,4), %rcx
addq %r13, %rcx
jmpq *%rcx
movl %ebp, %edi
callq 0x31f0
testl %eax, %eax
jne 0x5cb4
movl %ebp, %edi
callq 0x3510
testl %eax, %eax
setne %al
cmpl $0x2d, %ebp
sete %cl
orb %al, %cl
cmpb $0x1, %cl
jne 0x5ceb
movl $0x3, (%rbx)
movq 0x10(%rbx), %rdx
movl $0x1, %ecx
movq %r15, %rdi
xorl %esi, %esi
movl %ebp, %r8d
callq 0x3280
jmp 0x5c3d
movl %ebp, %edi
callq 0x3510
testl %eax, %eax
je 0x5cd0
movq %r15, %rdi
movl %ebp, %esi
callq 0x30f0
movl $0x3, %r12d
jmp 0x5cb4
movl %ebp, %edi
callq 0x34d0
testl %eax, %eax
je 0x5cd7
movq %r15, %rdi
movl %ebp, %esi
callq 0x30f0
movl $0x1, %r12d
jmp 0x5cb4
cmpl $0x5d, %ebp
je 0x5cc6
cmpl $0x25, %ebp
je 0x5dc3
movq %r15, %rdi
movl %ebp, %esi
callq 0x30f0
movl $0x2, %r12d
jmp 0x5cb4
movq 0x56e3(%rip), %rsi      # 0xb370
movq 0x56e4(%rip), %rcx      # 0xb378
movq %r14, %rdi
xorl %edx, %edx
callq 0x3470
movq 0x28(%rbx), %rcx
decq %rcx
movl $0x5, %r12d
cmpq %rcx, %rax
jne 0x5d94
movq 0x28(%rbx), %rdx
movb $0x1, %cl
incq %rdx
movq %rdx, 0x28(%rbx)
movl %r12d, %eax
jmp 0x5cde
movl $0x2, %r12d
xorl %ecx, %ecx
jmp 0x5cba
movl $0x3, %eax
jmp 0x5cdc
movl $0x1, %eax
xorl %ecx, %ecx
testb %cl, %cl
jne 0x5bc0
jmp 0x5d85
movl %ebp, %edi
callq 0x3420
testl %eax, %eax
je 0x5d17
movl $0x4, (%rbx)
movq 0x10(%rbx), %rdx
movl $0x1, %ecx
movq %r15, %rdi
xorl %esi, %esi
movl %ebp, %r8d
callq 0x3280
jmp 0x5c5e
cmpl $0x28, %ebp
jg 0x5d32
cmpl $0x25, %ebp
je 0x5d63
cmpl $0x28, %ebp
jne 0x5df2
movl $0x0, (%rbx)
jmp 0x5d7a
cmpl $0x29, %ebp
je 0x5d74
cmpl $0x5b, %ebp
jne 0x5df2
movl $0x4, (%rbx)
movq 0x10(%rbx), %rdx
movq %r15, %rdi
xorl %esi, %esi
leaq 0x258a(%rip), %rcx      # 0x82e0
xorl %r8d, %r8d
callq 0x34a0
jmp 0x5c7e
movl $0x2, (%rbx)
movl $0x4, %r12d
jmp 0x5cb4
movl $0x1, (%rbx)
movl $0x5, %r12d
jmp 0x5cb4
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x18(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x25d0(%rip), %rsi      # 0x8374
leaq 0x2621(%rip), %rdx      # 0x83cc
leaq 0x8(%rsp), %r14
movq %r14, %rdi
callq 0x68c6
movq %rbx, %rdi
movq %r14, %rsi
callq 0x610c
leaq 0x38(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x254d(%rip), %rsi      # 0x8320
leaq 0x2596(%rip), %rdx      # 0x8370
leaq 0x28(%rsp), %r14
movq %r14, %rdi
callq 0x68c6
movq %rbx, %rdi
movq %r14, %rsi
callq 0x610c
leaq 0x58(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x24ee(%rip), %rsi      # 0x82f0
leaq 0x2513(%rip), %rdx      # 0x831c
leaq 0x48(%rsp), %r14
movq %r14, %rdi
callq 0x68c6
movq %rbx, %rdi
movq %r14, %rsi
callq 0x610c
movq %rax, %rbx
movq 0x48(%rsp), %rdi
jmp 0x5e3d
movq %rax, %rbx
movq 0x28(%rsp), %rdi
jmp 0x5e3d
movq %rax, %rbx
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
je 0x5e52
movq (%r15), %rax
leaq 0x4(,%rax,4), %rsi
callq 0x32f0
movq %rbx, %rdi
callq 0x3480