Turtle
class Turtle extends Ntriples
Class to parse Turtle with no external dependencies.
It is a translation from Java to PHP of the Sesame Turtle Parser: http://bit.ly/TurtleParser
Lasted updated against version: ecda6a15a200a2fc6a062e2e43081257c3ccd4e6 (Mon Jul 29 12:05:58 2013)
Properties
| protected Graph | $graph | from Parser | |
| protected | $format | The format of the document currently being parsed | from Parser |
| protected | $baseUri | The base URI for the document currently being parsed | from Parser |
| protected | $tripleCount | from Parser | |
| protected | $data | ||
| protected | $namespaces | ||
| protected | $subject | ||
| protected | $predicate | ||
| protected | $object | ||
| protected | $line | ||
| protected | $column | ||
| protected | $bytePos | ||
| protected | $dataLength |
Methods
Check, cleanup parameters and prepare for parsing
Parse Turtle into an Graph
Add a triple to the current graph, and keep count of the number of triples
Decodes an encoded N-Triples string. Any -escape sequences are substituted with their decoded value.
Constructor
Parse a statement [2]
Parse a directive [3]
Parse a prefixID [4]
Parse base [5]
Parse triples [6] modified to use a pointer instead of manipulating the input buffer directly.
Parse a predicateObjectList [7]
Parse a objectList [8]
Parse a subject [10]
Parse a predicate [11]
Parse a object [12]
Parses a blankNodePropertyList [15]
Parses a collection [16], e.g: ( item1 item2 item3 )
Parses an RDF value. This method parses uriref, qname, node ID, quoted literal, integer, double and boolean.
Parses a quoted string, optionally followed by a language tag or datatype.
Parses a quoted string, which is either a "normal string" or a """long string""".
Parses a "normal string". This method requires that the opening character has already been parsed.
Parses a """long string""". This method requires that the first three characters have already been parsed.
Parses a numeric value, either of type integer, decimal or double
Parses a URI / IRI
Parses qnames and boolean values, which have equivalent starting characters.
No description
Parses a blank node ID, e.g: _:node1
No description
Verifies that the supplied character $c is one of the expected characters specified in $expected. This method will throw a exception if this is not the case.
Skip through whitespace and comments
Consumes characters from reader until the first EOL has been read.
Read a single character from the input buffer.
Gets the next character to be returned by read() without moving the pointer position. Speeds up the mb_substr() call by only giving it the next 4 bytes to parse.
Steps back, restoring the previous character read() to the input buffer
Reverse skips through whitespace in 4 byte increments.
No description
Returns true if $c is a whitespace character
No description
No description
No description
No description
No description
No description
No description
Details
in
Parser at line 70
protected
remapBnode($name)
Create a new, unique bnode identifier from a source identifier.
If the source identifier has previously been seen, the same new bnode identifier is returned.
in
Parser at line 82
protected
resetBnodeMap()
Delete the bnode mapping - to be called at the start of a new parse
in
Parser at line 91
protected
checkParseParams($graph, $data, $format, $baseUri)
Check, cleanup parameters and prepare for parsing
at line 91
parse($graph, $data, $format, $baseUri)
Parse Turtle into an Graph
in
Parser at line 148
protected
addTriple($resource, $property, $value)
Add a triple to the current graph, and keep count of the number of triples
in
Ntriples at line 58
protected string
unescapeString(string $str)
Decodes an encoded N-Triples string. Any -escape sequences are substituted with their decoded value.
in
Ntriples at line 110
protected
parseNtriplesSubject($sub, $lineNum)
in
Ntriples at line 132
protected
parseNtriplesObject($obj, $lineNum)
at line 76
__construct()
Constructor
at line 129
protected
parseStatement()
Parse a statement [2]
at line 161
protected
parseDirective($directive)
Parse a directive [3]
at line 187
protected
parsePrefixID()
Parse a prefixID [4]
at line 227
protected
parseBase()
Parse base [5]
at line 240
protected
parseTriples()
Parse triples [6] modified to use a pointer instead of manipulating the input buffer directly.
at line 284
protected
parsePredicateObjectList()
Parse a predicateObjectList [7]
at line 315
protected
parseObjectList()
Parse a objectList [8]
at line 330
protected
parseSubject()
Parse a subject [10]
at line 356
protected
parsePredicate()
Parse a predicate [11]
at line 394
protected
parseObject()
Parse a object [12]
at line 421
protected
parseImplicitBlank()
Parses a blankNodePropertyList [15]
This method parses the token [] and predicateObjectLists that are surrounded by square brackets.
at line 460
protected
parseCollection()
Parses a collection [16], e.g: ( item1 item2 item3 )
at line 531
protected
parseValue()
Parses an RDF value. This method parses uriref, qname, node ID, quoted literal, integer, double and boolean.
at line 569
protected
parseQuotedLiteral()
Parses a quoted string, optionally followed by a language tag or datatype.
at line 655
protected
parseQuotedString()
Parses a quoted string, which is either a "normal string" or a """long string""".
at line 693
protected string
parseString(string $closingCharacter)
Parses a "normal string". This method requires that the opening character has already been parsed.
at line 739
protected string
parseLongString(string $closingCharacter)
Parses a """long string""". This method requires that the first three characters have already been parsed.
at line 782
protected
parseNumber()
Parses a numeric value, either of type integer, decimal or double
at line 881
protected
parseURI()
Parses a URI / IRI
at line 932
protected
parseQNameOrBoolean()
Parses qnames and boolean values, which have equivalent starting characters.
at line 1031
protected
readLocalEscapedChar()
at line 1050
protected
parseNodeID()
Parses a blank node ID, e.g: _:node1
at line 1088
protected
resolve($uri)
at line 1103
protected
verifyCharacterOrFail($c, $expected)
Verifies that the supplied character $c is one of the expected characters specified in $expected. This method will throw a exception if this is not the case.
at line 1133
protected
skipWSC()
Skip through whitespace and comments
at line 1152
protected
processComment()
Consumes characters from reader until the first EOL has been read.
at line 1178
protected
read()
Read a single character from the input buffer.
Returns -1 when the end of the file is reached. Does not manipulate the data variable. Keeps track of the byte position instead.
at line 1201
protected
peek()
Gets the next character to be returned by read() without moving the pointer position. Speeds up the mb_substr() call by only giving it the next 4 bytes to parse.
at line 1218
protected
unread($chars)
Steps back, restoring the previous character read() to the input buffer
at line 1235
protected
unskipWS()
Reverse skips through whitespace in 4 byte increments.
(Keeps the byte pointer accurate when unreading.)
at line 1253
protected
createBNode()
at line 1265
static
isWhitespace($c)
Returns true if $c is a whitespace character