code: private function pop($expected = null) {
          if(count($this->tokens) == 0) {
              $message = is_null($expected)
                  ? "Ran out of tokens, expected $expected."
                  : 'Ran out of tokens.';
  
              throw new SyntaxErrorException($message);
          }
  
          $token = array_shift($this->tokens);
          $type = $token[0];
  
          if(!is_null($expected) && $type != $expected) {
              throw new SyntaxErrorException("Invalid token: Got $type, expected 
                  $expected.");
          }
  
          return $token;
      }
docs: Pops the first element from the array, if $expected is specified it
  also checks for a match, throwing an exception if the matching fails.
  
  @param array $array The token array
  @param string $expected The expected type of the token
  
  @return array The first token of the array/queue