/**
  * Parses function
  *
  * @return XmlImportAstFunction
  */
 private function parseMath()
 {
     $math = new XmlImportAstMath($this->tokens[++$this->index]->getValue());
     if ($this->tokens[$this->index + 1]->getKind() != XmlImportToken::KIND_OPEN) {
         throw new XmlImportException("Open brace expected instead of " . $this->tokens[$this->index + 1]->getKind());
     }
     $this->index++;
     if ($this->tokens[$this->index + 1]->getKind() == XmlImportToken::KIND_CLOSE) {
         $this->index++;
         return $math;
     } else {
         while ($this->index < count($this->tokens) - 2) {
             $math->addArgument($this->parseExpression());
             if ($this->tokens[$this->index + 1]->getKind() == XmlImportToken::KIND_CLOSE) {
                 $this->index++;
                 return $math;
                 break;
             } elseif ($this->tokens[$this->index + 1]->getKind() == XmlImportToken::KIND_COMMA) {
                 $this->index++;
             } else {
                 throw new XmlImportException("Comma or closing brace expected instead of " . $this->tokens[$this->index + 1]->getKind());
             }
         }
         throw new XmlImportException("Unexpected end of MATH argument list");
     }
 }
 /**
  * Generates code for a function
  *
  * @param XmlImportAstFunction $function
  * @return string
  */
 private function generateForMath(XmlImportAstMath $math)
 {
     $result = '';
     $arguments = $math->getArguments();
     for ($i = 0; $i < count($arguments); $i++) {
         $result .= $this->generateForExpression($arguments[$i], true);
     }
     return 'number_format(' . str_replace("\"", "", $result) . ',2)';
 }