rdql
[ class tree: rdql ] [ index: rdql ] [ all elements ]

Class: RDF_RDQL_Parser

Source Location: /RDF_RDQL-0.2.0/RDF/RDQL/Parser.php

Class Overview

RDF_Object
   |
   --RDF_RDQL_Parser

This class contains methods for parsing an RDQL query string into PHP variables.


Author(s):

Version:

  • V0.7

Variables

Methods


Inherited Variables

Inherited Methods


Class Details

[line 19]
This class contains methods for parsing an RDQL query string into PHP variables.

The output of the RDQLParser is an array with variables and constraints of each query clause (Select, From, Where, And, Using). To perform an RDQL query this array has to be passed to the RDQLEngine.

  • Author: Radoslaw Oldakowski <radol@gmx.de>
  • Version: V0.7
  • Access: public


[ Top ]


Class Variables

$parsedQuery =

[line 55]

Parsed query variables and constraints.

{ } are only used within the parser class and are not returned as parsed query. ( [] stands for an integer index - 0..N )

  • Var: ['selectVars'][] = ?VARNAME ['sources'][]{['value']} = URI | QName {['is_qname'] = boolean} ['patterns'][]['subject']['value'] = VARorURI {['is_qname'] = boolean} ['predicate']['value'] = VARorURI {['is_qname'] = boolean} ['object']['value'] = VARorURIorLiterl {['is_qname'] = boolean} ['is_literal'] = boolean ['l_lang'] = string ['l_dtype'] = string {['l_dtype_is_qname'] = boolean} ['filters'][]['string'] = string ['evalFilterStr'] = string ['reqexEqExprs'][]['var'] = ?VARNAME ['operator'] = (eq | ne) ['regex'] = string ['strEqExprs'][]['var'] = ?VARNAME ['operator'] = (eq | ne) ['value'] = string ['value_type'] = ('variable' | 'URI' | 'QName' | 'Literal') ['value_lang'] = string ['value_dtype'] = string {['value_dtype_is_qname'] = boolean} ['numExpr']['vars'][] = ?VARNAME {['ns'][PREFIX] = NAMESPACE}
  • Access: protected

Type:   array


[ Top ]

$tokens =

[line 65]

Query string divided into a sequence of tokens.

A token is either: ' ' or "\n" or "\r" or "\t" or ',' or '(' or ')' or a string containing any characters except from the above.

  • Access: protected

Type:   array


[ Top ]



Method Detail

findAllQueryVariables   [line 699]

array findAllQueryVariables( )

Find all query variables used in the WHERE clause.
  • Return: [] = ?VARNAME
  • Access: protected

[ Top ]

parseAnd   [line 443]

void parseAnd( )

Parse the AND clause of an RDQL query
  • Throws: PhpError
  • Access: protected

[ Top ]

parseExpressions   [line 582]

array parseExpressions( $filterStr, string $filteStr)

Parse expressions inside the passed filter: 1) regex equality expressions: ?var [~~ | =~ | !~ ] REG_EX 2a) string equality expressions: ?var [eq | ne] "literal"@lang^^dtype.

2b) string equality expressions: ?var [eq | ne] <URI> or ?var [eq | ne] prefix:local_name 3) numerical expressions: e.q. (?var1 - ?var2)*4 >= 20

In cases 1-2 parse each expression of the given filter into an array of variables. For each parsed expression put a place holder (e.g. ##RegEx_1##) into the filterStr. The RDQLengine will then replace each place holder with the outcomming boolean value of the corresponding expression. The remaining filterStr contains only numerical expressions and place holders.

  • Return: ['string'] = string ['evalFilterStr'] = string ['reqexEqExprs'][]['var'] = ?VARNAME ['operator'] = (eq | ne) ['regex'] = string ['strEqExprs'][]['var'] = ?VARNAME ['operator'] = (eq | ne) ['value'] = string ['value_type'] = ('variable' | 'URI' 'QName' | | 'Literal') ['value_lang'] = string ['value_dtype'] = string ['value_dtype_is_qname'] = boolean ['numExpr']['vars'][] = ?VARNAME
  • Access: protected

Parameters:

string   $filteStr   — 
   $filterStr   — 

[ Top ]

parseFilter   [line 534]

void parseFilter( integer $n, string $filter)

Check if a filter from the AND clause contains an equal number of '(' and ')' and parse filter expressions.
  • Throws: PHPError
  • Access: protected

Parameters:

integer   $n   — 
string   $filter   — 

[ Top ]

parseFrom   [line 305]

void parseFrom( )

Parse the FROM/SOURCES clause of an RDQL query When the parsing of this clause is finished, parseWhere() will be called.
  • Throws: PhpError
  • Access: protected

[ Top ]

parseQuery   [line 74]

array &parseQuery( string $queryString)

Parse the given RDQL query string and return an array with query variables and constraints.
  • Access: public

Parameters:

string   $queryString   — 

[ Top ]

parseSelect   [line 217]

void parseSelect( )

Parse the SELECT clause of an RDQL query.

When the parsing of the SELECT clause is finished, this method will call a suitable method to parse the subsequent clause.

  • Throws: PhpError
  • Access: protected

[ Top ]

parseUsing   [line 481]

void parseUsing( )

Parse the USING clause of an RDQL query
  • Throws: PhpError
  • Access: protected

[ Top ]

parseWhere   [line 358]

void parseWhere( )

*' Parse the WHERE clause of an RDQL query.

When the parsing of the WHERE clause is finished, this method will call a suitable method to parse the subsequent clause if provided.

  • Throws: PhpError
  • Access: protected

[ Top ]

removeComments   [line 106]

string removeComments( string $query)

Remove comments from the passed query string.
  • Throws: PHPError
  • Access: protected

Parameters:

string   $query   — 

[ Top ]

replaceNamespacePrefixes   [line 727]

void replaceNamespacePrefixes( )

Replace all namespace prefixes in the pattern and constraint clause of an RDQL query with the namespaces declared in the USING clause and default namespaces.
  • Access: protected

[ Top ]

startParsing   [line 204]

void startParsing( )

Start parsing of the tokenized query string.
  • Access: protected

[ Top ]

tokenize   [line 178]

void tokenize( string $queryString)

Divide the query string into tokens.

A token is either: ' ' or "\n" or "\r" or '\t' or ',' or '(' or ')' or a string containing any character except from the above.

  • Access: protected

Parameters:

string   $queryString   — 

[ Top ]

_checkComma   [line 859]

void _checkComma( string $commaExpected, string $clause_error)

Check if the query string of the given clause contains an undesired ','.

If a comma was correctly placed then remove it and clear all whitespaces.

  • Throws: PHPError
  • Access: protected

Parameters:

string   $commaExpected   — 
string   $clause_error   — 

[ Top ]

_checkRegExQuotation   [line 1239]

void _checkRegExQuotation( string $filterString, string $lQuotMark, string $rQuotMark)

Throw an error if the regular expression from the AND clause is not quoted.
  • Throws: PHPError
  • Access: protected

Parameters:

string   $filterString   — 
string   $lQuotMark   — 
string   $rQuotMark   — 

[ Top ]

_checkSelectVars   [line 1198]

void _checkSelectVars( )

Check if all variables from the SELECT clause are defined in the WHERE clause
  • Access: protected

[ Top ]

_clearWhiteSpaces   [line 839]

void _clearWhiteSpaces( )

Remove whitespace-tokens from the array $this->tokens
  • Access: protected

[ Top ]

_isDefined   [line 1216]

string _isDefined( $var $var)

Check if the given variable is defined in the WHERE clause.
  • Throws: PHPError
  • Access: protected

Parameters:

$var   $var   —  string

[ Top ]

_replaceNamespacePrefix   [line 1183]

string _replaceNamespacePrefix( string $qName, $clause_error, string $clasue_error)

Replace a prefix in a given QName and return a full URI.
  • Throws: PHPError
  • Access: protected

Parameters:

string   $qName   — 
string   $clasue_error   — 
   $clause_error   — 

[ Top ]

_validateLiteral   [line 1035]

array _validateLiteral( string $token)

Check if $token is the first token of a valid literal ("LITERAL") and return an array with literal properties (value, language, datatype).
  • Return: ['value'] = string ['is_literal'] = boolean ['l_lang'] = string ['l_dtype'] = string ['l_dtype_is_qname'] = boolean
  • Throws: PHPError
  • Access: protected

Parameters:

string   $token   — 

[ Top ]

_validateNCName   [line 1146]

boolean _validateNCName( string $token)

Check if the given token is a valid NCName.
  • Access: protected

Parameters:

string   $token   — 

[ Top ]

_validatePrefix   [line 1163]

string _validatePrefix( string $token)

Check if the given token is a valid namespace prefix.
  • Throws: PHPError
  • Access: protected

Parameters:

string   $token   — 

[ Top ]

_validateQName   [line 1120]

boolean _validateQName( string $token, string $clause_error)

Check if the given token is a valid QName.
  • Throws: PHPError
  • Access: protected

Parameters:

string   $token   — 
string   $clause_error   — 

[ Top ]

_validateURI   [line 977]

string _validateURI( string $token, string $clause_error)

Check if $token is the first token of a valid URI (<URI>) and return the whole URI string
  • Throws: PHPError
  • Access: protected

Parameters:

string   $token   — 
string   $clause_error   — 

[ Top ]

_validateVar   [line 956]

string _validateVar( string $token, $clause_error, string $clause)

Check if the given token is a valid variable name (?var).
  • Throws: PHPError
  • Access: protected

Parameters:

string   $token   — 
string   $clause   — 
   $clause_error   — 

[ Top ]

_validateVarUri   [line 885]

array _validateVarUri( string $token)

Check if the given token is either a variable (?var) or the first token of an URI (<URI>).

In case of an URI this function returns the whole URI string.

  • Return: ['value'] = string
  • Throws: PHPError
  • Access: protected

Parameters:

string   $token   — 

[ Top ]

_validateVarUriLiteral   [line 916]

array _validateVarUriLiteral( string $token)

Check if the given token is either a variable (?var) or the first token of either an URI (<URI>) or a literal ("Literal").

In case of a literal return an array with literal properties (value, language, datatype). In case of a variable or an URI return only ['value'] = string.

  • Return: ['value'] = string ['is_qname'] = boolean ['is_literal'] = boolean ['l_lang'] = string ['l_dtype'] = string
  • Throws: PHPError
  • Access: protected

Parameters:

string   $token   — 

[ Top ]


Documentation generated on Mon, 11 Mar 2019 15:39:50 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.