// File: zeeev[P]DASVC/bamtools/src/utils/bamtools_filter_ruleparser.h
// Function: BamTools::RuleParser::readToken(BamTools::RuleToken&)
inline
bool RuleParser::readToken(RuleToken& token) {
  
    // skip any preceding whitespace
    skipSpaces();
    if ( m_current == m_end ) return false;

    // clear out prior token value
    token.Value.clear();
    
    // read chars while still in token
    char c = 1;
    bool keepReading = true;
    bool inOperandString = false;
    while ( keepReading && (c != 0) ) {
      
      // get next char
      c = getNextChar();
      switch (c) {
        
          // current char is '('
          case ( LEFT_PARENTHESIS_CHAR ) :
              token.Type = RuleToken::LEFT_PARENTHESIS;
              token.Value.append(1, LEFT_PARENTHESIS_CHAR);
              keepReading = false;
              break;
              
          // current char is ')'
          case ( RIGHT_PARENTHESIS_CHAR ) :
              if ( inOperandString )
                  --m_current;
              else {
                  token.Type = RuleToken::RIGHT_PARENTHESIS;
                  token.Value.append(1, RIGHT_PARENTHESIS_CHAR);
              }
              keepReading = false;
              break;
        
          // current char is '&'
          case ( AND_OPERATOR_CHAR ) :
              if ( inOperandString ) 
                  --m_current;
              else {
                  token.Type = RuleToken::AND_OPERATOR;
                  token.Value.append(1, AND_OPERATOR_CHAR);
              }
              keepReading = false;
              break;
              
          // current char is '|' 
          case ( OR_OPERATOR_CHAR ) :
              if ( inOperandString )
                  --m_current;
              else {  
                  token.Type = RuleToken::OR_OPERATOR;
                  token.Value.append(1, OR_OPERATOR_CHAR);
              }
              keepReading = false;
              break;
              
          // current char is '!'
          case ( NOT_OPERATOR_CHAR ) :
              token.Type = RuleToken::NOT_OPERATOR;
              token.Value.append(1, NOT_OPERATOR_CHAR);
              keepReading = false;
              break;
              
          // current char is ' '
          case ( SPACE_CHAR ) : 
              keepReading = false;
              break;
            
          // current char is a true value token
          default:
              if ( c != 0 ) {
                  token.Type = RuleToken::OPERAND;
                  token.Value.append(1, c);
                  inOperandString = true;
                  keepReading = true;
              }
        }         
    }
      
    return true;
}

// Assembly:
subq $0x38, %rsp
movq %rdi, 0x28(%rsp)
movq %rsi, 0x20(%rsp)
movq 0x28(%rsp), %rdi
movq %rdi, 0x10(%rsp)
callq 0xb3100
movq 0x10(%rsp), %rcx
movq 0x28(%rcx), %rax
cmpq 0x30(%rcx), %rax
jne 0xb2cb6
movb $0x0, 0x37(%rsp)
jmp 0xb2ed7
movq 0x20(%rsp), %rdi
addq $0x8, %rdi
callq 0x86970
movb $0x1, 0x1f(%rsp)
movb $0x1, 0x1e(%rsp)
movb $0x0, 0x1d(%rsp)
xorl %eax, %eax
testb $0x1, 0x1e(%rsp)
movb %al, 0xf(%rsp)
je 0xb2cef
movsbl 0x1f(%rsp), %eax
cmpl $0x0, %eax
setne %al
movb %al, 0xf(%rsp)
movb 0xf(%rsp), %al
testb $0x1, %al
jne 0xb2cfc
jmp 0xb2ed2
movq 0x10(%rsp), %rdi
callq 0xb3170
movb %al, 0x1f(%rsp)
movsbl 0x1f(%rsp), %eax
movl %eax, 0x8(%rsp)
subl $0x20, %eax
je 0xb2e8d
jmp 0xb2d1e
movl 0x8(%rsp), %eax
subl $0x21, %eax
je 0xb2e63
jmp 0xb2d2d
movl 0x8(%rsp), %eax
subl $0x26, %eax
je 0xb2dd8
jmp 0xb2d3c
movl 0x8(%rsp), %eax
subl $0x28, %eax
je 0xb2d64
jmp 0xb2d47
movl 0x8(%rsp), %eax
subl $0x29, %eax
je 0xb2d91
jmp 0xb2d52
movl 0x8(%rsp), %eax
subl $0x7c, %eax
je 0xb2e1f
jmp 0xb2e94
movq 0x20(%rsp), %rax
movl $0x4, (%rax)
movq 0x20(%rsp), %rdi
addq $0x8, %rdi
movl $0x1, %esi
movl $0x28, %edx
callq 0x867a0
movb $0x0, 0x1e(%rsp)
jmp 0xb2ecd
testb $0x1, 0x1d(%rsp)
je 0xb2dab
movq 0x10(%rsp), %rax
movq 0x28(%rax), %rcx
addq $-0x1, %rcx
movq %rcx, 0x28(%rax)
jmp 0xb2dce
movq 0x20(%rsp), %rax
movl $0x5, (%rax)
movq 0x20(%rsp), %rdi
addq $0x8, %rdi
movl $0x1, %esi
movl $0x29, %edx
callq 0x867a0
movb $0x0, 0x1e(%rsp)
jmp 0xb2ecd
testb $0x1, 0x1d(%rsp)
je 0xb2df2
movq 0x10(%rsp), %rax
movq 0x28(%rax), %rcx
addq $-0x1, %rcx
movq %rcx, 0x28(%rax)
jmp 0xb2e15
movq 0x20(%rsp), %rax
movl $0x1, (%rax)
movq 0x20(%rsp), %rdi
addq $0x8, %rdi
movl $0x1, %esi
movl $0x26, %edx
callq 0x867a0
movb $0x0, 0x1e(%rsp)
jmp 0xb2ecd
testb $0x1, 0x1d(%rsp)
je 0xb2e39
movq 0x10(%rsp), %rax
movq 0x28(%rax), %rcx
addq $-0x1, %rcx
movq %rcx, 0x28(%rax)
jmp 0xb2e5c
movq 0x20(%rsp), %rax
movl $0x2, (%rax)
movq 0x20(%rsp), %rdi
addq $0x8, %rdi
movl $0x1, %esi
movl $0x7c, %edx
callq 0x867a0
movb $0x0, 0x1e(%rsp)
jmp 0xb2ecd
movq 0x20(%rsp), %rax
movl $0x3, (%rax)
movq 0x20(%rsp), %rdi
addq $0x8, %rdi
movl $0x1, %esi
movl $0x21, %edx
callq 0x867a0
movb $0x0, 0x1e(%rsp)
jmp 0xb2ecd
movb $0x0, 0x1e(%rsp)
jmp 0xb2ecd
movsbl 0x1f(%rsp), %eax
cmpl $0x0, %eax
je 0xb2ecb
movq 0x20(%rsp), %rax
movl $0x0, (%rax)
movq 0x20(%rsp), %rdi
addq $0x8, %rdi
movl $0x1, %esi
movsbl 0x1f(%rsp), %edx
callq 0x867a0
movb $0x1, 0x1d(%rsp)
movb $0x1, 0x1e(%rsp)
jmp 0xb2ecd
jmp 0xb2cd3
movb $0x1, 0x37(%rsp)
movb 0x37(%rsp), %al
andb $0x1, %al
addq $0x38, %rsp
retq
nopw %cs:(%rax,%rax)
nopl (%rax)