// File: /workspace/github_cpp_makefile_star2_O2/melop[P]admixem/./parser/parser.cpp
// Function: Parser::Primary(bool)
const double Parser::Primary (const bool get)   // primary (base) tokens
  {
  
  if (get)
    GetToken ();    // one-token lookahead  
  
  switch (type_)
    {
    case NUMBER:  
      {
      double v = value_; 
      GetToken (true);  // get next one (one-token lookahead)
      return v;
      }
    
    case NAME:
      {
      std::string word = word_;
      GetToken (true); 
      if (type_ == LHPAREN)
        {
        // might be single-argument function (eg. abs (x) )
        std::map<std::string, OneArgFunction>::const_iterator si;
        si = OneArgumentFunctions.find (word);
        if (si != OneArgumentFunctions.end ())
          {
          double v = Expression (true);   // get argument
          CheckToken (RHPAREN);
          GetToken (true);        // get next one (one-token lookahead)
          return si->second (v);  // evaluate function
          }
        
        // might be double-argument function (eg. roll (6, 2) )
        std::map<std::string, TwoArgFunction>::const_iterator di;
        di = TwoArgumentFunctions.find (word);
        if (di != TwoArgumentFunctions.end ())
          {
          double v1 = Expression (true);   // get argument 1 (not commalist)
          CheckToken (COMMA);
          double v2 = Expression (true);   // get argument 2 (not commalist)
          CheckToken (RHPAREN);
          GetToken (true);            // get next one (one-token lookahead)
          return di->second (v1, v2); // evaluate function
          }
  
       // might be double-argument function (eg. roll (6, 2) )
        std::map<std::string, ThreeArgFunction>::const_iterator ti;
        ti = ThreeArgumentFunctions.find (word);
        if (ti != ThreeArgumentFunctions.end ())
          {
          double v1 = Expression (true);   // get argument 1 (not commalist)
          CheckToken (COMMA);
          double v2 = Expression (true);   // get argument 2 (not commalist)
          CheckToken (COMMA);
          double v3 = Expression (true);   // get argument 3 (not commalist)
          CheckToken (RHPAREN);
          GetToken (true);  // get next one (one-token lookahead)
          return ti->second (v1, v2, v3); // evaluate function
          }
        
        throw std::runtime_error ("Function '" + word + "' not implemented.");
        }
		
		

      
      // not a function? must be a symbol in the symbol table
      double & v = symbols_ [word];  // get REFERENCE to symbol table entry
      // change table entry with expression? (eg. a = 22, or a = 22)
	  
	  
      switch (type_)
        {
        // maybe check for NaN or Inf here (see: isinf, isnan functions)
        case ASSIGN:     v  = Expression (true); break;   
        case ASSIGN_ADD: v += Expression (true); break;   
        case ASSIGN_SUB: v -= Expression (true); break;   
        case ASSIGN_MUL: v *= Expression (true); break;   
        case ASSIGN_DIV: 
            {
            double d = Expression (true); 
            if (d == 0.0)
              throw std::runtime_error ("Divide by zero");
            v /= d;
            break;   // change table entry with expression
            } // end of ASSIGN_DIV
        default: break;   // do nothing for others
        } // end of switch on type_              
      return v;               // and return new value
      }
    
    case MINUS:               // unary minus
      return - Primary (true);
    
    case NOT:   // unary not
      return (Primary (true) == 0.0) ? 1.0 : 0.0;;
    
    case LHPAREN:
      {
      double v = CommaList (true);    // inside parens, you could have commas
      CheckToken (RHPAREN);
      GetToken (true);                // eat the )
      return v;
      }
    
    default:   
      throw std::runtime_error ("Unexpected token: " + word_);
    
    } // end of switch on type
  
  }

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0x80, %rsp
movq %rdi, %rbx
testl %esi, %esi
je 0x8aea
movq %rbx, %rdi
xorl %esi, %esi
callq 0x84ca
movl 0x30(%rbx), %eax
cmpl $0x1, %eax
je 0x8b44
cmpl $0x2d, %eax
je 0x8b2c
cmpl $0x21, %eax
je 0x8bbf
cmpl $0x28, %eax
je 0x8be4
cmpl $0x2, %eax
jne 0x8e0a
movsd 0x58(%rbx), %xmm0
movapd %xmm0, (%rsp)
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0x84ca
jmp 0x8df9
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0x8ace
xorpd 0x24551(%rip), %xmm0    # 0x2d090
jmp 0x8dfe
leaq 0x38(%rbx), %rsi
leaq 0x18(%rsp), %rdi
callq 0x7550
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0x84ca
cmpl $0x28, 0x30(%rbx)
jne 0x8c15
leaq 0x3c88a(%rip), %rdi     # 0x453f8
leaq 0x18(%rsp), %rsi
callq 0xa720
movq %rax, %r14
leaq 0x3c87e(%rip), %rax     # 0x45400
cmpq %rax, %r14
je 0x8c55
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0x8f6c
movsd %xmm0, (%rsp)
pushq $0x29
popq %rsi
movq %rbx, %rdi
callq 0x93c0
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0x84ca
movsd (%rsp), %xmm0
callq *0x40(%r14)
jmp 0x8dea
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0x8ace
xorpd %xmm1, %xmm1
cmpeqsd %xmm0, %xmm1
movsd 0x24435(%rip), %xmm0    # 0x2d010
andpd %xmm1, %xmm0
jmp 0x8dfe
pushq $0x1
popq %rbp
movq %rbx, %rdi
movl %ebp, %esi
callq 0x8fea
movsd %xmm0, (%rsp)
pushq $0x29
popq %rsi
movq %rbx, %rdi
callq 0x93c0
movq %rbx, %rdi
movl %ebp, %esi
callq 0x84ca
movsd (%rsp), %xmm0
jmp 0x8dfe
leaq 0x68(%rbx), %rdi
leaq 0x18(%rsp), %rsi
callq 0x94ac
movq %rax, %r14
movl 0x30(%rbx), %eax
addl $-0x3d, %eax
cmpl $0xb, %eax
ja 0x8ccf
leaq 0x243fc(%rip), %rcx     # 0x2d038
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0x8f6c
jmp 0x8d11
leaq 0x3c7cc(%rip), %rdi     # 0x45428
leaq 0x18(%rsp), %rsi
callq 0xa75e
movq %rax, %r14
leaq 0x3c7c0(%rip), %rax     # 0x45430
cmpq %rax, %r14
je 0x8d53
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0x8f6c
movsd %xmm0, (%rsp)
pushq $0x2c
popq %rsi
movq %rbx, %rdi
callq 0x93c0
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0x8f6c
movsd %xmm0, 0x10(%rsp)
pushq $0x29
popq %rsi
movq %rbx, %rdi
callq 0x93c0
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0x84ca
movsd (%rsp), %xmm0
movsd 0x10(%rsp), %xmm1
callq *0x40(%r14)
jmp 0x8dea
movsd (%r14), %xmm0
jmp 0x8dea
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0x8f6c
movsd (%r14), %xmm1
subsd %xmm0, %xmm1
jmp 0x8d44
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0x8f6c
addsd (%r14), %xmm0
jmp 0x8d11
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0x8f6c
mulsd (%r14), %xmm0
movapd %xmm0, (%rsp)
movsd %xmm0, (%r14)
jmp 0x8def
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0x8f6c
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x8d3b
jnp 0x8e5a
movsd (%r14), %xmm1
divsd %xmm0, %xmm1
movapd %xmm1, (%rsp)
movsd %xmm1, (%r14)
jmp 0x8def
leaq 0x3c6fe(%rip), %rdi     # 0x45458
leaq 0x18(%rsp), %rsi
callq 0xa79c
movq %rax, %r14
leaq 0x3c6f2(%rip), %rax     # 0x45460
cmpq %rax, %r14
je 0x8e8c
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0x8f6c
movsd %xmm0, (%rsp)
pushq $0x2c
popq %rsi
movq %rbx, %rdi
callq 0x93c0
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0x8f6c
movsd %xmm0, 0x10(%rsp)
pushq $0x2c
popq %rsi
movq %rbx, %rdi
callq 0x93c0
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0x8f6c
movsd %xmm0, 0x38(%rsp)
pushq $0x29
popq %rsi
movq %rbx, %rdi
callq 0x93c0
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0x84ca
movsd (%rsp), %xmm0
movsd 0x10(%rsp), %xmm1
movsd 0x38(%rsp), %xmm2
callq *0x40(%r14)
movapd %xmm0, (%rsp)
leaq 0x18(%rsp), %rdi
callq 0x71a0
movapd (%rsp), %xmm0
addq $0x80, %rsp
popq %rbx
popq %r14
popq %rbp
retq
pushq $0x10
popq %rdi
callq 0x71d0
movq %rax, %r14
addq $0x38, %rbx
leaq 0x24341(%rip), %rsi     # 0x2d161
leaq 0x18(%rsp), %rdi
movq %rbx, %rdx
callq 0x9325
movb $0x1, %bpl
leaq 0x18(%rsp), %rsi
movq %r14, %rdi
callq 0x7630
xorl %ebp, %ebp
movq 0x3c1aa(%rip), %rsi     # 0x44ff0
movq 0x3c13b(%rip), %rdx     # 0x44f88
movq %r14, %rdi
callq 0x76a0
jmp 0x8eeb
pushq $0x10
popq %rdi
callq 0x71d0
movq %rax, %r14
leaq 0x242e6(%rip), %rsi     # 0x2d152
movq %rax, %rdi
callq 0x7150
movq 0x3c175(%rip), %rsi     # 0x44ff0
movq 0x3c106(%rip), %rdx     # 0x44f88
movq %r14, %rdi
callq 0x76a0
jmp 0x8eeb
pushq $0x10
popq %rdi
callq 0x71d0
movq %rax, %r14
leaq 0x24296(%rip), %rsi     # 0x2d134
leaq 0x40(%rsp), %rdi
leaq 0x18(%rsp), %rdx
callq 0x9325
leaq 0x2428b(%rip), %rdx     # 0x2d13f
leaq 0x60(%rsp), %rdi
leaq 0x40(%rsp), %rsi
callq 0x948c
movb $0x1, %bpl
leaq 0x60(%rsp), %rsi
movq %r14, %rdi
callq 0x7630
xorl %ebp, %ebp
movq 0x3c114(%rip), %rsi     # 0x44ff0
movq 0x3c0a5(%rip), %rdx     # 0x44f88
movq %r14, %rdi
callq 0x76a0
movq %rax, %rbx
leaq 0x60(%rsp), %rdi
callq 0x71a0
jmp 0x8f00
movq %rax, %rbx
movb $0x1, %bpl
leaq 0x40(%rsp), %rdi
callq 0x71a0
testb %bpl, %bpl
jne 0x8f16
jmp 0x8f5a
jmp 0x8f13
movq %rax, %rbx
movq %r14, %rdi
callq 0x7300
jmp 0x8f5a
jmp 0x8f57
jmp 0x8f57
jmp 0x8f57
jmp 0x8f57
jmp 0x8f57
jmp 0x8f57
jmp 0x8f57
jmp 0x8f57
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0x71a0
testb %bpl, %bpl
jne 0x8f47
jmp 0x8f64
movq %rax, %rbx
movq %r14, %rdi
callq 0x7300
jmp 0x8f64
jmp 0x8f57
jmp 0x8f57
jmp 0x8f57
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0x71a0
movq %rbx, %rdi
callq 0x76d0