|
From: <cw...@us...> - 2007-08-12 17:42:08
|
Revision: 491
http://rdfapi-php.svn.sourceforge.net/rdfapi-php/?rev=491&view=rev
Author: cweiske
Date: 2007-08-12 10:42:05 -0700 (Sun, 12 Aug 2007)
Log Message:
-----------
Make it throw an exception instead of die()ing hard
Modified Paths:
--------------
trunk/rdfapi-php/api/syntax/N3Parser.php
Modified: trunk/rdfapi-php/api/syntax/N3Parser.php
===================================================================
--- trunk/rdfapi-php/api/syntax/N3Parser.php 2007-08-12 15:26:47 UTC (rev 490)
+++ trunk/rdfapi-php/api/syntax/N3Parser.php 2007-08-12 17:42:05 UTC (rev 491)
@@ -42,8 +42,11 @@
*
*
*
- * @author Sean B. Palmer <se...@my...>, Gunnar AA. Grimnes <ggr...@cs...>, Daniel Westphal <ma...@d-...>
+ * @author Sean B. Palmer <se...@my...>
+ * @author Gunnar AA. Grimnes <ggr...@cs...>
+ * @author Daniel Westphal <ma...@d-...>
* @version $Id$
+ * @license GPL http://www.gnu.org/licenses/gpl.txt
* @package syntax
* @access public
**/
@@ -68,37 +71,37 @@
**/
function N3Parser() {
//Regular expressions:
- $Name = '[A-Za-z0-9_@\.]+[^\.,;\[\]\s\) ]*';
- $URI = '<[^> ]*>';
- $bNode = '_:'.$Name;
- $Univar = '\?'.$Name;
- $QName = '(?:[A-Za-z][A-Za-z0-9_@\.]*)?:'.$Name;
- $Literal = '"(\\\"|[^"])*"'; # '"(?:\\"|[^"])*"'
-// $Literal = '"[^"\\\\]*(?:\\.\\[^"\\]*)*"'; # '"(?:\\"|[^"])*"'
- $LangTag = '@[A-Za-z\-]*[^ \^\.\;\,]';
+ $Name = '[A-Za-z0-9_@\.]+[^\.,;\[\]\s\) ]*';
+ $URI = '<[^> ]*>';
+ $bNode = '_:'.$Name;
+ $Univar = '\?'.$Name;
+ $QName = '(?:[A-Za-z][A-Za-z0-9_@\.]*)?:'.$Name;
+ $Literal = '"(\\\"|[^"])*"'; # '"(?:\\"|[^"])*"'
+// $Literal = '"[^"\\\\]*(?:\\.\\[^"\\]*)*"'; # '"(?:\\"|[^"])*"'
+ $LangTag = '@[A-Za-z\-]*[^ \^\.\;\,]';
$Datatype = '(\^\^)[^ ,\.;)]+';
$Datatype_URI = '(\^\^)'.$URI;
// $LLiteral = '"""[^"\\\\]*(?:(?:.|"(?!""))[^"\\\\]*)*"""';
$LLiteral = '"""[^"\\\\]*(?:(?:\\\\.|"(?!""))[^"\\\\]*)*"""';
// '"""[^"\\]*(?:(?:\\.|"(?!""))[^"\\]*)*"""'
- $Comment = '#.*$';
- $Prefix = '(?:[A-Za-z][A-Za-z0-9_]*)?:';
+ $Comment = '#.*$';
+ $Prefix = '(?:[A-Za-z][A-Za-z0-9_]*)?:';
$PrefixDecl = '@prefix';
- $WS = '[ \t]';
- $this->RDF_NS = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'; # for 'a' keyword
+ $WS = '[ \t]';
+ $this->RDF_NS = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'; # for 'a' keyword
$this->DAML_NS = 'http://www.daml.org/2001/03/daml+oil#'; # for '=' keyword
- $this->OWL_NS = 'http://www.w3.org/2002/07/owl#';
+ $this->OWL_NS = 'http://www.w3.org/2002/07/owl#';
// $t = array( $LLiteral, $URI); //, $Literal, $PrefixDecl, $QName, $bNode, $Prefix,
// $Univar, 'a', '{', '}', '\(', '\)', '\[', '\]', ',', ';', '\.', $WS, $Comment);
$t = array( $Datatype_URI,$Datatype,$LLiteral, $URI, $Literal, $PrefixDecl, $QName, $bNode, $Prefix, $Univar, 'a','=', '{', '}', '\(', '\)', '\[', '\]', ',', ';', '\.', $WS, $Comment,$LangTag);
- $this->Tokens="/(".join($t,"|").")/m";
+ $this->Tokens = "/(".join($t,"|").")/m";
- $this->bNode=0;
- $this->debug=0;
- $this->bNodeMap = array();
- $this->FixBnodes = FIX_BLANKNODES;
- $this->parseError=false;
+ $this->bNode = 0;
+ $this->debug = 0;
+ $this->bNodeMap = array();
+ $this->FixBnodes = FIX_BLANKNODES;
+ $this->parseError =false;
}
@@ -142,7 +145,7 @@
/**
- * This parses a N3 string and calls func($subject, $predicate, $object) with each trioke
+ * This parses a N3 string and calls func($subject, $predicate, $object) with each triple
* @param string $s
* @param string $func
* @access public
@@ -722,7 +725,9 @@
if (count($list) == 3) return array($list);
- if (count($list) < 3) die("Error: statement too short!");
+ if (count($list) < 3) {
+ throw new Exception('N3 statement too short.');
+ }
//Get all ;
$r=$this->getPovs($list);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|