/** * Parses function * * @return XmlImportSpintaxFunction */ private function parseSpintax() { $spintax = new XmlImportAstSpintax($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 $spintax; } else { while ($this->index < count($this->tokens) - 2) { $spintax->addArgument($this->parseExpression()); if ($this->tokens[$this->index + 1]->getKind() == XmlImportToken::KIND_CLOSE) { $this->index++; return $spintax; 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 {$function->getName()} function argument list"); } }