// File: /workspace/github_cpp_makefile_star2_O3/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 %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x80, %rsp
movq %rdi, %rbx
testl %esi, %esi
je 0x909e
movq %rbx, %rdi
xorl %esi, %esi
callq 0x88de
movl 0x30(%rbx), %eax
cmpl $0x20, %eax
jle 0x90d7
cmpl $0x21, %eax
je 0x9105
cmpl $0x28, %eax
je 0x912c
cmpl $0x2d, %eax
jne 0x941b
movq %rbx, %rdi
movl $0x1, %esi
callq 0x907e
movapd %xmm0, %xmm2
xorpd 0x2afbe(%rip), %xmm2    # 0x34090
jmp 0x9407
cmpl $0x1, %eax
je 0x9162
cmpl $0x2, %eax
jne 0x941b
movsd 0x58(%rbx), %xmm0
movapd %xmm0, (%rsp)
movq %rbx, %rdi
movl $0x1, %esi
callq 0x88de
jmp 0x9402
movq %rbx, %rdi
movl $0x1, %esi
callq 0x907e
xorpd %xmm1, %xmm1
cmpeqsd %xmm0, %xmm1
movsd 0x2aef5(%rip), %xmm2    # 0x34018
andpd %xmm1, %xmm2
jmp 0x9407
movq %rbx, %rdi
movl $0x1, %esi
callq 0x96a0
movsd %xmm0, (%rsp)
movq %rbx, %rdi
movl $0x29, %esi
callq 0x9b14
movq %rbx, %rdi
movl $0x1, %esi
callq 0x88de
movsd (%rsp), %xmm0
jmp 0x940b
leaq 0x28(%rsp), %r15
movq %r15, -0x10(%r15)
movq 0x38(%rbx), %rsi
movq 0x40(%rbx), %rdx
addq %rsi, %rdx
leaq 0x18(%rsp), %rdi
callq 0xa9b2
movq %rbx, %rdi
movl $0x1, %esi
callq 0x88de
cmpl $0x28, 0x30(%rbx)
jne 0x91f1
leaq 0x3f22e(%rip), %rdi     # 0x483c8
leaq 0x18(%rsp), %rsi
callq 0xadc8
movq %rax, %r14
leaq 0x3f222(%rip), %rax     # 0x483d0
cmpq %rax, %r14
je 0x9237
movq %rbx, %rdi
movl $0x1, %esi
callq 0x961e
movsd %xmm0, (%rsp)
movq %rbx, %rdi
movl $0x29, %esi
callq 0x9b14
movq %rbx, %rdi
movl $0x1, %esi
callq 0x88de
movsd (%rsp), %xmm0
callq *0x40(%r14)
jmp 0x93e2
leaq 0x68(%rbx), %rdi
leaq 0x18(%rsp), %rsi
callq 0x9c1c
movq %rax, %r14
movl 0x30(%rbx), %eax
addl $-0x3d, %eax
cmpl $0xb, %eax
ja 0x92bb
leaq 0x2ae28(%rip), %rcx     # 0x34040
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %rbx, %rdi
movl $0x1, %esi
callq 0x961e
movapd %xmm0, %xmm2
jmp 0x9333
leaq 0x3f1ba(%rip), %rdi     # 0x483f8
leaq 0x18(%rsp), %rsi
callq 0xae0e
movq %rax, %r14
leaq 0x3f1ae(%rip), %rax     # 0x48400
cmpq %rax, %r14
je 0x933d
movq %rbx, %rdi
movl $0x1, %esi
callq 0x961e
movsd %xmm0, (%rsp)
movq %rbx, %rdi
movl $0x2c, %esi
callq 0x9b14
movq %rbx, %rdi
movl $0x1, %esi
callq 0x961e
movsd %xmm0, 0x10(%rsp)
movq %rbx, %rdi
movl $0x29, %esi
callq 0x9b14
movq %rbx, %rdi
movl $0x1, %esi
callq 0x88de
movsd (%rsp), %xmm0
movsd 0x10(%rsp), %xmm1
callq *0x40(%r14)
jmp 0x93e2
movsd (%r14), %xmm2
jmp 0x93e6
movq %rbx, %rdi
movl $0x1, %esi
callq 0x961e
movsd (%r14), %xmm2
subsd %xmm0, %xmm2
jmp 0x9333
movq %rbx, %rdi
movl $0x1, %esi
callq 0x961e
movapd %xmm0, %xmm2
addsd (%r14), %xmm2
jmp 0x9333
movq %rbx, %rdi
movl $0x1, %esi
callq 0x961e
movapd %xmm0, %xmm2
mulsd (%r14), %xmm2
jmp 0x9333
movq %rbx, %rdi
movl $0x1, %esi
callq 0x961e
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x932a
jnp 0x946d
movsd (%r14), %xmm2
divsd %xmm0, %xmm2
movsd %xmm2, (%r14)
jmp 0x93e6
leaq 0x3f0e4(%rip), %rdi     # 0x48428
leaq 0x18(%rsp), %rsi
callq 0xae54
movq %rax, %r14
leaq 0x3f0d8(%rip), %rax     # 0x48430
cmpq %rax, %r14
je 0x94a4
movq %rbx, %rdi
movl $0x1, %esi
callq 0x961e
movsd %xmm0, (%rsp)
movq %rbx, %rdi
movl $0x2c, %esi
callq 0x9b14
movq %rbx, %rdi
movl $0x1, %esi
callq 0x961e
movsd %xmm0, 0x10(%rsp)
movq %rbx, %rdi
movl $0x2c, %esi
callq 0x9b14
movq %rbx, %rdi
movl $0x1, %esi
callq 0x961e
movsd %xmm0, 0x38(%rsp)
movq %rbx, %rdi
movl $0x29, %esi
callq 0x9b14
movq %rbx, %rdi
movl $0x1, %esi
callq 0x88de
movsd (%rsp), %xmm0
movsd 0x10(%rsp), %xmm1
movsd 0x38(%rsp), %xmm2
callq *0x40(%r14)
movapd %xmm0, %xmm2
movq 0x18(%rsp), %rdi
cmpq %r15, %rdi
je 0x9407
movq 0x28(%rsp), %rsi
incq %rsi
movapd %xmm2, (%rsp)
callq 0x7390
movapd (%rsp), %xmm2
movapd %xmm2, %xmm0
addq $0x80, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movl $0x10, %edi
callq 0x7180
movq %rax, %r14
addq $0x38, %rbx
leaq 0x2ad2e(%rip), %rsi     # 0x34161
leaq 0x18(%rsp), %rdi
movq %rbx, %rdx
callq 0x9a1b
movb $0x1, %bpl
leaq 0x18(%rsp), %rsi
movq %r14, %rdi
callq 0x75d0
xorl %ebp, %ebp
movq 0x3eb97(%rip), %rsi     # 0x47ff0
movq 0x3eb20(%rip), %rdx     # 0x47f80
movq %r14, %rdi
callq 0x7660
jmp 0x9549
movl $0x10, %edi
callq 0x7180
movq %rax, %r14
leaq 0x2acd1(%rip), %rsi     # 0x34152
movq %rax, %rdi
callq 0x7140
movq 0x3eb60(%rip), %rsi     # 0x47ff0
movq 0x3eae9(%rip), %rdx     # 0x47f80
movq %r14, %rdi
callq 0x7660
jmp 0x9549
movl $0x10, %edi
callq 0x7180
movq %rax, %r14
leaq 0x2ac7c(%rip), %rsi     # 0x34134
leaq 0x40(%rsp), %rdi
leaq 0x18(%rsp), %rdx
callq 0x9a1b
leaq 0x2ac71(%rip), %rsi     # 0x3413f
leaq 0x40(%rsp), %rdi
callq 0x76f0
leaq 0x70(%rsp), %r12
movq %r12, -0x10(%r12)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
jne 0x94fd
movupd (%rcx), %xmm0
movupd %xmm0, (%r12)
jmp 0x950a
movq %rdx, 0x60(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x70(%rsp)
movq 0x8(%rax), %rdx
leaq 0x60(%rsp), %rsi
movq %rdx, 0x8(%rsi)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movb $0x1, %bpl
movq %r14, %rdi
callq 0x75d0
xorl %ebp, %ebp
movq 0x3eab6(%rip), %rsi     # 0x47ff0
movq 0x3ea3f(%rip), %rdx     # 0x47f80
movq %r14, %rdi
callq 0x7660
movq %rax, %rbx
movq 0x60(%rsp), %rdi
cmpq %r12, %rdi
je 0x9563
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x7390
leaq 0x50(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x957e
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x7390
testb %bpl, %bpl
jne 0x95aa
jmp 0x95ff
movq %rax, %rbx
leaq 0x50(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x95aa
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x7390
jmp 0x95aa
jmp 0x95a7
movq %rax, %rbx
movq %r14, %rdi
callq 0x72a0
jmp 0x95ff
jmp 0x95fc
jmp 0x95fc
jmp 0x95fc
jmp 0x95fc
jmp 0x95fc
jmp 0x95fc
jmp 0x95fc
jmp 0x95fc
jmp 0x95fc
movq %rax, %rbx
leaq 0x28(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x95e4
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x7390
testb %bpl, %bpl
jne 0x95ee
jmp 0x9616
movq %rax, %rbx
movq %r14, %rdi
callq 0x72a0
jmp 0x9616
jmp 0x95fc
jmp 0x95fc
movq %rax, %rbx
movq 0x18(%rsp), %rdi
cmpq %r15, %rdi
je 0x9616
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x7390
movq %rbx, %rdi
callq 0x76a0