mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-17 06:53:15 +00:00
Improve jison script, run the update parser
This commit is contained in:
4
.gitignore
vendored
4
.gitignore
vendored
@@ -59,3 +59,7 @@ behat.yml
|
||||
|
||||
# Exclude crossdomain.xml file it's generated
|
||||
/www/crossdomain.xml
|
||||
|
||||
# Exclude jison files
|
||||
grammar/query.js
|
||||
grammar/jison-*
|
||||
|
17
build_query_parser.sh
Normal file → Executable file
17
build_query_parser.sh
Normal file → Executable file
@@ -1,4 +1,19 @@
|
||||
#!/bin/sh
|
||||
|
||||
jison_version="master";
|
||||
jison_php="jison-$jison_version/ports/php/php.js"
|
||||
|
||||
cd grammar
|
||||
node jison/ports/php/php.js query.jison
|
||||
|
||||
if [ -f $jison_php ];
|
||||
then
|
||||
echo "Skip jison download"
|
||||
else
|
||||
echo "Download jison lib"
|
||||
wget https://github.com/zaach/jison/archive/$jison_version.zip
|
||||
unzip $jison_version.zip
|
||||
rm $jison_version.zip
|
||||
fi
|
||||
|
||||
node jison-$jison_version/ports/php/php.js query.jison
|
||||
mv QueryParser.php ../lib/Alchemy/Phrasea/SearchEngine/Elastic/QueryParser.php
|
@@ -18,7 +18,7 @@ class KeywordNode extends Node
|
||||
|
||||
public function getQuery()
|
||||
{
|
||||
throw new LogicException("A keyword can't be converted to a query.");
|
||||
throw new \LogicException("A keyword can't be converted to a query.");
|
||||
}
|
||||
|
||||
public function __toString()
|
||||
|
@@ -276,6 +276,8 @@ class ElasticSearchEngine implements SearchEngineInterface
|
||||
{
|
||||
$parser = new QueryParser();
|
||||
$ast = $parser->parse($string);
|
||||
|
||||
|
||||
$userQuery = $ast->getQuery();
|
||||
|
||||
$params = $this->createQueryParams($userQuery, $options ?: new SearchEngineOptions());
|
||||
|
@@ -447,11 +447,13 @@ class QueryParser
|
||||
switch ($yystate) {
|
||||
case 1:
|
||||
|
||||
|
||||
return $thisS;
|
||||
|
||||
|
||||
break;
|
||||
case 2:
|
||||
|
||||
// $thisS = sprintf('(%s DEF_OP %s)', $s[$o-1]->text, $s[$o]->text);
|
||||
|
||||
$thisS = new AST\AndExpression($s[$o-1]->text, $s[$o]->text);
|
||||
@@ -460,39 +462,47 @@ case 2:
|
||||
break;
|
||||
case 4:
|
||||
|
||||
|
||||
$thisS = new AST\AndExpression($s[$o-2]->text, $s[$o]->text);
|
||||
|
||||
|
||||
break;
|
||||
case 5:
|
||||
|
||||
|
||||
$thisS = new AST\OrExpression($s[$o-2]->text, $s[$o]->text);
|
||||
|
||||
|
||||
break;
|
||||
case 6:
|
||||
|
||||
|
||||
$thisS = new AST\InExpression($s[$o]->text, $s[$o-2]->text);
|
||||
|
||||
|
||||
break;
|
||||
case 7:
|
||||
|
||||
$thisS = $s[$o-1];
|
||||
|
||||
break;
|
||||
case 10:
|
||||
|
||||
$thisS = new AST\KeywordNode($s[$o]->text);
|
||||
|
||||
break;
|
||||
case 11:
|
||||
|
||||
$thisS = new AST\PrefixNode($s[$o-1]->text);
|
||||
|
||||
break;
|
||||
case 12:
|
||||
|
||||
$thisS = new AST\TextNode($s[$o]->text);
|
||||
|
||||
break;
|
||||
case 13:
|
||||
|
||||
$thisS = new AST\QuotedTextNode($s[$o]->text);
|
||||
|
||||
break;
|
||||
@@ -811,7 +821,7 @@ break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( isset($match) && $match ) {
|
||||
if ( $match ) {
|
||||
$matchCount = strlen($match[0]);
|
||||
$lineCount = preg_match("/(?:\r\n?|\n).*/", $match[0], $lines);
|
||||
$line = ($lines ? $lines[$lineCount - 1] : false);
|
||||
@@ -897,7 +907,6 @@ break;
|
||||
function LexerPerformAction($avoidingNameCollisions, $YY_START = null)
|
||||
{
|
||||
|
||||
|
||||
;
|
||||
switch($avoidingNameCollisions) {
|
||||
case 0:/* skip whitespace */
|
||||
|
Reference in New Issue
Block a user