-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
re-add antlr and sparql parser (see OntoWiki issue #123)
- Loading branch information
Showing
49 changed files
with
43,355 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of the {@link http://aksw.org/Projects/Erfurt Erfurt} project. | ||
* | ||
* @copyright Copyright (c) 2009, {@link http://aksw.org AKSW} | ||
* @license http://opensource.org/licenses/gpl-license.php GNU General Public License (GPL) | ||
*/ | ||
|
||
/** | ||
* @category Erfurt | ||
* @package Sparql_Parser_Sparql | ||
* @author Rolland Brunec <rollxx@gmail.com> | ||
* @copyright Copyright (c) 2010 {@link http://aksw.org aksw} | ||
* @license http://opensource.org/licenses/gpl-license.php GNU General Public License (GPL) | ||
*/ | ||
|
||
require_once 'Erfurt/Sparql/Parser.php'; | ||
|
||
class Erfurt_Sparql_Parser_ErfurtParser implements Erfurt_Sparql_Parser_Interface | ||
{ | ||
|
||
function __construct($parserOptions=array()) | ||
{ | ||
// TODO pass options? | ||
} | ||
|
||
public static function initFromString($queryString, $parserOptions = array()){ | ||
require_once 'Erfurt/Sparql/ParserException.php'; | ||
$retval=null; | ||
$errors=null; | ||
$parser = new Erfurt_Sparql_Parser($queryString); | ||
try { | ||
$retval = $parser->parse(); | ||
} catch (Erfurt_Sparql_ParserException $e) { | ||
$errors = $e->__toString(); | ||
} | ||
return array('retval' =>$retval, 'errors'=>$errors); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of the {@link http://aksw.org/Projects/Erfurt Erfurt} project. | ||
* | ||
* @copyright Copyright (c) 2010, {@link http://aksw.org AKSW} | ||
* @license http://opensource.org/licenses/gpl-license.php GNU General Public License (GPL) | ||
*/ | ||
|
||
/** | ||
* @category Erfurt | ||
* @package Sparql_Parser | ||
* @author Rolland Brunec <rollxx@gmail.com> | ||
* @copyright Copyright (c) 2010 {@link http://aksw.org aksw} | ||
* @license http://opensource.org/licenses/gpl-license.php GNU General Public License (GPL) | ||
*/ | ||
interface Erfurt_Sparql_Parser_Interface | ||
{ | ||
|
||
/** | ||
* @param string $queryString | ||
* @param array $parserOptions | ||
* @throws Parser Exception, if there was a poblem parsing the query | ||
* @return Returns Erfurt_Sparql_Query2 object | ||
*/ | ||
public static function initFromString($queryString, $parserOptions = array()); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of the {@link http://aksw.org/Projects/Erfurt Erfurt} project. | ||
* | ||
* @copyright Copyright (c) 2010, {@link http://aksw.org AKSW} | ||
* @license http://opensource.org/licenses/gpl-license.php GNU General Public License (GPL) | ||
*/ | ||
|
||
/** | ||
* @category Erfurt | ||
* @package Sparql_Parser_Sparql | ||
* @author Rolland Brunec <rollxx@gmail.com> | ||
* @copyright Copyright (c) 2010 {@link http://aksw.org aksw} | ||
* @license http://opensource.org/licenses/gpl-license.php GNU General Public License (GPL) | ||
*/ | ||
|
||
class Erfurt_Sparql_Parser_Rasqal_Rasqal implements Erfurt_Sparql_Parser_Interface | ||
{ | ||
/** | ||
* | ||
*/ | ||
protected $_fallback = 'sparql10'; | ||
|
||
protected $_toString = 'toString'; | ||
|
||
private $_parserName = null; | ||
|
||
private $_lexerName = null; | ||
|
||
function __construct($parserOptions=array()) | ||
{ | ||
} | ||
|
||
public function initFromString($queryString, $parserOptions = array()){ | ||
} | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of the {@link http://aksw.org/Projects/Erfurt Erfurt} project. | ||
* | ||
* @copyright Copyright (c) 2009, {@link http://aksw.org AKSW} | ||
* @license http://opensource.org/licenses/gpl-license.php GNU General Public License (GPL) | ||
*/ | ||
|
||
/** | ||
* @category Erfurt | ||
* @package Sparql_Parser_Sparql | ||
* @author Rolland Brunec <rollxx@gmail.com> | ||
* @copyright Copyright (c) 2010 {@link http://aksw.org aksw} | ||
* @license http://opensource.org/licenses/gpl-license.php GNU General Public License (GPL) | ||
*/ | ||
|
||
require_once 'antlr/Php/antlr.php'; | ||
|
||
class Erfurt_Sparql_Parser_Sparql10 implements Erfurt_Sparql_Parser_Interface | ||
{ | ||
public static function initFromString($queryString, $parsePartial = null){ | ||
$retval=null; | ||
$input = new Erfurt_Sparql_Parser_Util_CaseInsensitiveStream($queryString); | ||
$lexer = new Erfurt_Sparql_Parser_Sparql10_Sparql10Lexer($input); | ||
// if (!count($lexer->getErrors())) { | ||
$tokens = new CommonTokenStream($lexer); | ||
$parser = new Erfurt_Sparql_Parser_Sparql10_Sparql10Parser($tokens); | ||
if($parsePartial != null && is_string($parsePartial) && method_exists($parser, $parsePartial)){ | ||
$retval = call_user_func( array( $parser, $parsePartial ) ); | ||
} else { | ||
$retval = $parser->parse(); | ||
} | ||
// } | ||
return array('retval' =>$retval, 'errors'=> | ||
//array_merge($lexer->getErrors(), | ||
//$parser? | ||
$parser->getErrors() | ||
//:array()) | ||
); | ||
} | ||
|
||
} |
Oops, something went wrong.