// File: /workspace/github_cpp_makefile_star2_O2/melop[P]admixem/./parser/parser.cpp
// Function: Parser::GetToken(bool)
const Parser::TokenType Parser::GetToken (const bool ignoreSign)
  {
  word_.erase (0, std::string::npos);
  
  // skip spaces
  while (*pWord_ && isspace (*pWord_))
    ++pWord_;

  pWordStart_ = pWord_;   // remember where word_ starts *now*
  
  // look out for unterminated statements and things
  if (*pWord_ == 0 &&  // we have EOF
      type_ == END)  // after already detecting it
    throw std::runtime_error ("Unexpected end of expression.");

  unsigned char cFirstCharacter = *pWord_;        // first character in new word_
  
  if (cFirstCharacter == 0)    // stop at end of file
    {
    word_ = "<end of expression>";
    return type_ = END;
    }
  
  unsigned char cNextCharacter  = *(pWord_ + 1);  // 2nd character in new word_
  
  // look for number
  // can be: + or - followed by a decimal point
  // or: + or - followed by a digit
  // or: starting with a digit
  // or: decimal point followed by a digit
  if ((!ignoreSign &&
	   (cFirstCharacter == '+' || cFirstCharacter == '-') &&
	   (isdigit (cNextCharacter) || cNextCharacter == '.')
	   )
	  || isdigit (cFirstCharacter)
	  // allow decimal numbers without a leading 0. e.g. ".5"
	  // Dennis Jones 01-30-2009
	  || (cFirstCharacter == '.' && isdigit (cNextCharacter)) )
	  {
    // skip sign for now
    if ((cFirstCharacter == '+' || cFirstCharacter == '-'))
      pWord_++;
    while (isdigit (*pWord_) || *pWord_ == '.')
      pWord_++;
    
    // allow for 1.53158e+15
    if (*pWord_ == 'e' || *pWord_ == 'E')
      {
      pWord_++; // skip 'e'
      if ((*pWord_  == '+' || *pWord_  == '-'))
        pWord_++; // skip sign after e
      while (isdigit (*pWord_))  // now digits after e
        pWord_++;      
      }
    
    word_ = std::string (pWordStart_, pWord_ - pWordStart_);
    
    std::istringstream is (word_);
    // parse std::string into double value
    is >> value_;
      
    if (is.fail () || !is.eof ())
      throw std::runtime_error ("Bad numeric literal: " + word_);
    return type_ = NUMBER;
    }   // end of number found

  // special test for 2-character sequences: <= >= == !=
  // also +=, -=, /=, *=
  if (cNextCharacter == '=')
    {
    switch (cFirstCharacter)
      {
      // comparisons
      case '=': type_ = EQ;   break;
      case '<': type_ = LE;   break;
      case '>': type_ = GE;   break;
      case '!': type_ = NE;   break;
      // assignments
      case '+': type_ = ASSIGN_ADD;   break;
      case '-': type_ = ASSIGN_SUB;   break;
      case '*': type_ = ASSIGN_MUL;   break;
      case '/': type_ = ASSIGN_DIV;   break;
      // none of the above
      default:  type_ = NONE; break;
      } // end of switch on cFirstCharacter
    
    if (type_ != NONE)
      {
      word_ = std::string (pWordStart_, 2);
      pWord_ += 2;   // skip both characters
      return type_;
      } // end of found one    
    } // end of *=
  
  switch (cFirstCharacter)
    {
    case '&': if (cNextCharacter == '&')    // &&
                {
                word_ = std::string (pWordStart_, 2);
                pWord_ += 2;   // skip both characters
                return type_ = AND;
                }
              break;
   case '|': if (cNextCharacter == '|')   // ||
                {
                word_ = std::string (pWordStart_, 2);
                pWord_ += 2;   // skip both characters
                return type_ = OR;
                }
              break;
    // single-character symboles
    case '=':
    case '<':
    case '>':
    case '+':
    case '-':
    case '/':
    case '*':
    case '(':
    case ')':
    case ',':
    case '!':
      word_ = std::string (pWordStart_, 1);
      ++pWord_;   // skip it
      return type_ = TokenType (cFirstCharacter);
    } // end of switch on cFirstCharacter
  
  if (!isalpha (cFirstCharacter))
    {
    if (cFirstCharacter < ' ')
      {
      std::ostringstream s;
      s << "Unexpected character (decimal " << int (cFirstCharacter) << ")";
      throw std::runtime_error (s.str ());    
      }
    else
      throw std::runtime_error ("Unexpected character: " + std::string (1, cFirstCharacter));
    }
  
  // we have a word (starting with A-Z) - pull it out
  while (isalnum (*pWord_) || *pWord_ == '_')
    ++pWord_;
  
  word_ = std::string (pWordStart_, pWord_ - pWordStart_);
  return type_ = NAME;
  }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1a8, %rsp            # imm = 0x1A8
movl %esi, %ebp
movq %rdi, %rbx
leaq 0x38(%rdi), %r14
pushq $-0x1
popq %rdx
movq %r14, %rdi
xorl %esi, %esi
callq 0x70c0
movq 0x20(%rbx), %r13
movq %r13, %r15
movsbl (%r15), %edi
testl %edi, %edi
je 0x8515
callq 0x7080
testl %eax, %eax
je 0x8515
incq %r15
movq %r15, 0x20(%rbx)
incq %r13
jmp 0x84f8
movq %r15, 0x28(%rbx)
movzbl (%r15), %r12d
testl %r12d, %r12d
jne 0x852c
cmpl $0x3, 0x30(%rbx)
je 0x87cb
testl %r12d, %r12d
je 0x8588
leaq 0x1(%r15), %rdx
movzbl 0x1(%r15), %ecx
testb %bpl, %bpl
jne 0x8562
cmpl $0x2d, %r12d
je 0x854b
cmpl $0x2b, %r12d
jne 0x8562
leal -0x30(%rcx), %eax
cmpl $0xa, %eax
setb %al
cmpb $0x2e, %cl
sete %sil
orb %al, %sil
jne 0x856c
jmp 0x85ba
leal -0x30(%r12), %eax
cmpl $0xa, %eax
jae 0x85a5
cmpl $0x2d, %r12d
je 0x8954
movq %r15, %rax
cmpl $0x2b, %r12d
je 0x8954
jmp 0x895b
leaq 0x24b45(%rip), %rsi     # 0x2d0d4
movq %r14, %rdi
callq 0x7730
movl $0x3, 0x30(%rbx)
pushq $0x3
jmp 0x8a39
cmpl $0x2e, %r12d
jne 0x85ba
leal -0x30(%rcx), %esi
movq %r15, %rax
cmpl $0xa, %esi
jb 0x895b
cmpl $0x3d, %ecx
jne 0x860f
leal -0x2a(%r12), %eax
cmpl $0x5, %eax
jbe 0x85f4
cmpl $0x21, %r12d
je 0x877f
cmpl $0x3e, %r12d
je 0x8787
cmpl $0x3d, %r12d
je 0x8783
cmpl $0x3c, %r12d
jne 0x860b
pushq $0x3f
jmp 0x8789
leaq 0x24a25(%rip), %rsi     # 0x2d020
movslq (%rsi,%rax,4), %rax
addq %rsi, %rax
jmpq *%rax
pushq $0x47
jmp 0x8789
andl $0x0, 0x30(%rbx)
cmpl $0x3e, %r12d
ja 0x86b7
movl %r12d, %eax
movabsq $0x7000bf0200000000, %rsi # imm = 0x7000BF0200000000
btq %rax, %rsi
jae 0x8665
leaq 0x38(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x28(%rsp), %r13
movq %r13, %rdi
movq %r15, %rsi
callq 0xa2ca
movq %r14, %rdi
movq %r13, %rsi
callq 0x74c0
movq %r13, %rdi
callq 0x71a0
incq 0x20(%rbx)
movl %r12d, 0x30(%rbx)
jmp 0x8a3b
cmpq $0x26, %rax
jne 0x86b7
cmpl $0x26, %ecx
jne 0x8705
leaq 0x38(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x2(%r15), %rdx
leaq 0x28(%rsp), %r12
movq %r12, %rdi
movq %r15, %rsi
callq 0xa2ca
movq %r14, %rdi
movq %r12, %rsi
callq 0x74c0
movq %r12, %rdi
callq 0x71a0
addq $0x2, 0x20(%rbx)
movl $0x43, 0x30(%rbx)
pushq $0x43
jmp 0x8a39
cmpl $0x7c, %r12d
jne 0x8705
cmpl $0x7c, %ecx
jne 0x8705
leaq 0x38(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x2(%r15), %rdx
leaq 0x28(%rsp), %r12
movq %r12, %rdi
movq %r15, %rsi
callq 0xa2ca
movq %r14, %rdi
movq %r12, %rsi
callq 0x74c0
movq %r12, %rdi
callq 0x71a0
addq $0x2, 0x20(%rbx)
movl $0x44, 0x30(%rbx)
pushq $0x44
jmp 0x8a39
movl %r12d, %edi
callq 0x7610
testl %eax, %eax
je 0x87fb
movq %r15, %r12
movsbl (%r12), %ebp
movl %ebp, %edi
callq 0x7410
cmpl $0x5f, %ebp
je 0x872d
testl %eax, %eax
je 0x8736
incq %r12
movq %r12, 0x20(%rbx)
jmp 0x8718
leaq 0x38(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x28(%rsp), %r13
movq %r13, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0xa2ca
movq %r14, %rdi
movq %r13, %rsi
callq 0x74c0
movq %r13, %rdi
callq 0x71a0
movl $0x1, 0x30(%rbx)
pushq $0x1
jmp 0x8a39
pushq $0x48
jmp 0x8789
pushq $0x46
jmp 0x8789
pushq $0x45
jmp 0x8789
pushq $0x42
jmp 0x8789
pushq $0x41
jmp 0x8789
pushq $0x40
popq %rax
movl %eax, 0x30(%rbx)
leaq 0x38(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x2(%r15), %rdx
leaq 0x28(%rsp), %r12
movq %r12, %rdi
movq %r15, %rsi
callq 0xa2ca
movq %r14, %rdi
movq %r12, %rsi
callq 0x74c0
movq %r12, %rdi
callq 0x71a0
addq $0x2, 0x20(%rbx)
movl 0x30(%rbx), %r12d
jmp 0x8a3b
pushq $0x10
popq %rdi
callq 0x71d0
movq %rax, %r14
leaq 0x248d9(%rip), %rsi     # 0x2d0b6
movq %rax, %rdi
callq 0x7150
movq 0x3c804(%rip), %rsi     # 0x44ff0
movq 0x3c795(%rip), %rdx     # 0x44f88
movq %r14, %rdi
callq 0x76a0
cmpb $0x1f, %r12b
ja 0x887e
leaq 0x28(%rsp), %rbx
movq %rbx, %rdi
callq 0x7530
leaq 0x248e9(%rip), %rsi     # 0x2d0fe
movq %rbx, %rdi
callq 0x73d0
movq %rax, %rdi
movl %r12d, %esi
callq 0x76b0
leaq 0x261d7(%rip), %rsi     # 0x2ea06
movq %rax, %rdi
callq 0x73d0
pushq $0x10
popq %rdi
callq 0x71d0
movq %rax, %r14
leaq 0x30(%rsp), %rsi
leaq 0x8(%rsp), %rdi
callq 0x75f0
movb $0x1, %bpl
leaq 0x8(%rsp), %rsi
movq %r14, %rdi
callq 0x7630
xorl %ebp, %ebp
movq 0x3c786(%rip), %rsi     # 0x44ff0
movq 0x3c717(%rip), %rdx     # 0x44f88
movq %r14, %rdi
callq 0x76a0
jmp 0x8a97
pushq $0x10
popq %rdi
callq 0x71d0
movq %rax, %r14
leaq 0x18(%rsp), %rax
movq %rax, -0x10(%rax)
movsbl %r12b, %edx
leaq 0x8(%rsp), %rdi
pushq $0x1
popq %rsi
callq 0x7480
leaq 0x24873(%rip), %rsi     # 0x2d11d
leaq 0x28(%rsp), %rdi
leaq 0x8(%rsp), %rdx
callq 0x939b
movb $0x1, %bpl
leaq 0x28(%rsp), %rsi
movq %r14, %rdi
callq 0x7630
xorl %ebp, %ebp
movq 0x3c71e(%rip), %rsi     # 0x44ff0
movq 0x3c6af(%rip), %rdx     # 0x44f88
movq %r14, %rdi
callq 0x76a0
jmp 0x8a97
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x71a0
testb %bpl, %bpl
jne 0x88fd
jmp 0x8935
movq %rax, %rbx
movq %r14, %rdi
callq 0x7300
jmp 0x8935
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0x71a0
jmp 0x891c
movq %rax, %rbx
movb $0x1, %bpl
leaq 0x8(%rsp), %rdi
callq 0x71a0
testb %bpl, %bpl
jne 0x8947
jmp 0x8ac5
jmp 0x8944
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0x70e0
jmp 0x8ac5
movq %rax, %rbx
movq %r14, %rdi
callq 0x7300
jmp 0x8ac5
movq %rdx, 0x20(%rbx)
movq %rdx, %rax
movsbl (%rax), %ecx
cmpl $0x2e, %ecx
setne %dl
leal -0x30(%rcx), %esi
cmpl $0xa, %esi
setae %sil
testb %sil, %dl
jne 0x897b
incq %rax
movq %rax, %rdx
jmp 0x8954
movzbl %cl, %ecx
orl $0x20, %ecx
cmpl $0x65, %ecx
jne 0x89bd
leaq 0x1(%rax), %rcx
movq %rcx, 0x20(%rbx)
movzbl 0x1(%rax), %edx
cmpl $0x2d, %edx
je 0x899c
cmpl $0x2b, %edx
jne 0x89a7
addq $0x2, %rax
movq %rax, %rcx
movq %rax, 0x20(%rbx)
movsbl (%rcx), %eax
addl $-0x30, %eax
cmpl $0x9, %eax
ja 0x89ba
incq %rcx
movq %rcx, %rax
jmp 0x89a3
movq %rcx, %rax
subq %r13, %rax
leaq 0x38(%rsp), %rcx
movq %rcx, -0x10(%rcx)
addq %r15, %rax
leaq 0x28(%rsp), %r12
movq %r12, %rdi
movq %r15, %rsi
movq %rax, %rdx
callq 0xa2ca
movq %r14, %rdi
movq %r12, %rsi
callq 0x74c0
movq %r12, %rdi
callq 0x71a0
leaq 0x28(%rsp), %r15
pushq $0x8
popq %rdx
movq %r15, %rdi
movq %r14, %rsi
callq 0x7680
leaq 0x58(%rbx), %rsi
movq %r15, %rdi
callq 0x7280
movq 0x28(%rsp), %rax
movq -0x18(%rax), %rax
movl 0x48(%rsp,%rax), %eax
andl $0x7, %eax
cmpl $0x2, %eax
jne 0x8a50
movl $0x2, 0x30(%rbx)
leaq 0x28(%rsp), %rdi
callq 0x71b0
pushq $0x2
popq %r12
movl %r12d, %eax
addq $0x1a8, %rsp            # imm = 0x1A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
pushq $0x10
popq %rdi
callq 0x71d0
movq %rax, %r15
leaq 0x24686(%rip), %rsi     # 0x2d0e8
leaq 0x8(%rsp), %rdi
movq %r14, %rdx
callq 0x9325
movb $0x1, %bpl
leaq 0x8(%rsp), %rsi
movq %r15, %rdi
callq 0x7630
xorl %ebp, %ebp
movq 0x3c568(%rip), %rsi     # 0x44ff0
movq 0x3c4f9(%rip), %rdx     # 0x44f88
movq %r15, %rdi
callq 0x76a0
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x71a0
testb %bpl, %bpl
jne 0x8aae
jmp 0x8abb
movq %rax, %rbx
movq %r15, %rdi
callq 0x7300
jmp 0x8abb
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0x71b0
movq %rbx, %rdi
callq 0x76d0
nop