mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-22 01:58:47 +02:00
- bug: a JOIN b on b.extkey = a.id - bug: operators precedence (still a shift-reduce conflict with JOINS) - changed pkey into id (preserved the compatibility for DBObjectSearch::AddCondition() - allow implicit class name in WHERE condition - bug: wrong report on typo error - suggest an alternative in case of typo error SVN:code[12]
60 lines
1.2 KiB
PHP
60 lines
1.2 KiB
PHP
<?
|
|
|
|
class OqlNormalizeException extends OQLException
|
|
{
|
|
public function __construct($sIssue, $sInput, OqlName $oName, $aExpecting = null)
|
|
{
|
|
parent::__construct($sIssue, $sInput, 0, $oName->GetPos(), $oName->GetValue(), $aExpecting);
|
|
}
|
|
}
|
|
|
|
class OqlInterpreterException extends OQLException
|
|
{
|
|
}
|
|
|
|
|
|
class OqlInterpreter
|
|
{
|
|
public $m_sQuery;
|
|
|
|
public function __construct($sQuery)
|
|
{
|
|
$this->m_sQuery = $sQuery;
|
|
}
|
|
|
|
protected function Parse()
|
|
{
|
|
$oLexer = new OQLLexer($this->m_sQuery);
|
|
$oParser = new OQLParser($this->m_sQuery);
|
|
|
|
while($oLexer->yylex())
|
|
{
|
|
$oParser->doParse($oLexer->token, $oLexer->value, $oLexer->getTokenPos());
|
|
}
|
|
$res = $oParser->doFinish();
|
|
return $res;
|
|
}
|
|
|
|
public function ParseQuery()
|
|
{
|
|
$oRes = $this->Parse();
|
|
if (!$oRes instanceof OqlQuery)
|
|
{
|
|
throw new OqlException('Expecting an OQL query', $this->m_sQuery, 0, 0, get_class($oRes), array('OqlQuery'));
|
|
}
|
|
return $oRes;
|
|
}
|
|
|
|
public function ParseExpression()
|
|
{
|
|
$oRes = $this->Parse();
|
|
if (!$oRes instanceof Expression)
|
|
{
|
|
throw new OqlException('Expecting an OQL expression', $this->m_sQuery, 0, 0, get_class($oRes), array('Expression'));
|
|
}
|
|
return $oRes;
|
|
}
|
|
}
|
|
|
|
?>
|