Skip to content

Commit

Permalink
More RDF 1.2 N-Triples tests from star_spec to ntriples_spec.
Browse files Browse the repository at this point in the history
  • Loading branch information
gkellogg committed Oct 31, 2023
1 parent f3c0b6c commit 049e6a5
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 73 deletions.
145 changes: 74 additions & 71 deletions etc/turtle.bnf
Original file line number Diff line number Diff line change
@@ -1,74 +1,77 @@
turtleDoc ::= statement*
statement ::= directive | triples "."
directive ::= prefixID | base | sparqlPrefix | sparqlBase
prefixID ::= PREFIX PNAME_NS IRIREF "."?
base ::= BASE IRIREF "."?
sparqlPrefix ::= "PREFIX" PNAME_NS IRIREF
parqlBase ::= "BASE" IRIREF
triples ::= subject predicateObjectList | blankNodePropertyList predicateObjectList?
predicateObjectList ::= verb objectList ( ";" ( verb objectList)? )*
objectList ::= object annotation? ( "," object annotation? )*
verb ::= predicate | "a"
subject ::= iri | BlankNode | collection | quotedTriple
predicate ::= iri
object ::= iri | BlankNode | collection | blankNodePropertyList | literal | quotedTriple
literal ::= RDFLiteral | NumericLiteral | BooleanLiteral
blankNodePropertyList ::= "[" predicateObjectList "]"
collection ::= "(" object* ")"
NumericLiteral ::= INTEGER | DECIMAL | DOUBLE
RDFLiteral ::= String ( LANG_DIR | ( "^^" iri ) )?
BooleanLiteral ::= "true" | "false"
String ::= STRING_LITERAL_QUOTE | STRING_LITERAL_SINGLE_QUOTE | STRING_LITERAL_LONG_SINGLE_QUOTE |
STRING_LITERAL_LONG_QUOTE
iri ::= IRIREF | PrefixedName
PrefixedName ::= PNAME_LN | PNAME_NS
BlankNode ::= BLANK_NODE_LABEL | ANON
quotedTriple ::= "<<" qtSubject predicate qtObject ">>"
qtSubject ::= iri | BlankNode | quotedTriple
qtObject ::= iri | BlankNode | literal | quotedTriple
annotation ::= '{|' predicateObjectList '|}'
turtleDoc ::= statement*
statement ::= directive | triples '.'
directive ::= prefixID | base | sparqlPrefix | sparqlBase
prefixID ::= '@prefix' PNAME_NS IRIREF '.'
base ::= '@base' IRIREF '.'
sparqlPrefix ::= "PREFIX" PNAME_NS IRIREF
sparqlBase ::= "BASE" IRIREF
triples ::= subject predicateObjectList | blankNodePropertyList predicateObjectList?
predicateObjectList ::= verb objectList (';' (verb objectList)? )*
objectList ::= object annotation? ( ',' object annotation? )*
verb ::= predicate | 'a'
subject ::= iri | BlankNode | collection | quotedTriple
predicate ::= iri
object ::= iri | BlankNode | collection | blankNodePropertyList | literal | quotedTriple
literal ::= RDFLiteral | NumericLiteral | BooleanLiteral
blankNodePropertyList ::= '[' predicateObjectList ']'
collection ::= '(' object* ')'
NumericLiteral ::= INTEGER | DECIMAL | DOUBLE
RDFLiteral ::= String ( LANG_DIR | ( '^^' iri ) )?
BooleanLiteral ::= 'true' | 'false'
String ::= STRING_LITERAL_QUOTE | STRING_LITERAL_SINGLE_QUOTE
| STRING_LITERAL_LONG_SINGLE_QUOTE | STRING_LITERAL_LONG_QUOTE
iri ::= IRIREF | PrefixedName
PrefixedName ::= PNAME_LN | PNAME_NS
BlankNode ::= BLANK_NODE_LABEL | ANON
quotedTriple ::= '<<' qtSubject predicate qtObject '>>'
qtSubject ::= iri | BlankNode | quotedTriple
qtObject ::= iri | BlankNode | literal | quotedTriple
annotation ::= '{|' predicateObjectList '|}'

@terminals

IRIREF ::= '<' ([^#x00-#x20<>"{}|^`\] | UCHAR)* '>'
PNAME_NS ::= PN_PREFIX? ":"
PNAME_LN ::= PNAME_NS PN_LOCAL
BLANK_NODE_LABEL ::= '_:' ( PN_CHARS_U | [0-9] ) ((PN_CHARS|'.')* PN_CHARS)?
LANG_DIR ::= "@" [a-zA-Z]+ ( "-" [a-zA-Z0-9]+ )* ('--' [a-zA-Z]+)?`
INTEGER ::= [+-]? [0-9]+
DECIMAL ::= [+-]? ( ([0-9])* '.' ([0-9])+ )
DOUBLE ::= [+-]? ( [0-9]+ '.' [0-9]* EXPONENT | '.' ([0-9])+ EXPONENT | ([0-9])+ EXPONENT )
EXPONENT ::= [eE] [+-]? [0-9]+
STRING_LITERAL_QUOTE ::= '"' ( [^#x22#x5C#xA#xD] | ECHAR | UCHAR )* '"'
STRING_LITERAL_SINGLE_QUOTE ::= "'" ( [^#x27#x5C#xA#xD] | ECHAR | UCHAR )* "'"
STRING_LITERAL_LONG_SINGLE_QUOTE ::= "'''" ( ( "'" | "''" )? ( [^'\] | ECHAR | UCHAR ) )* "'''"
STRING_LITERAL_LONG_QUOTE ::= '"""' ( ( '"' | '""' )? ( [^"\] | ECHAR | UCHAR ) )* '"""'
UCHAR ::= ( "\u" HEX HEX HEX HEX ) | ( "\U" HEX HEX HEX HEX HEX HEX HEX HEX )
ECHAR ::= "\" [tbnrf\"']
PREFIX ::= "@"?[Pp][Rr][Ee][Ff][Ii][Xx]
BASE ::= "@"?[Bb][Aa][Ss][Ee]
WS ::= #x20 | #x9 | #xD | #xA
ANON ::= "[" WS* "]"
PN_CHARS_BASE ::= [A-Z]
| [a-z]
| [#x00C0-#x00D6]
| [#x00D8-#x00F6]
| [#x00F8-#x02FF]
| [#x0370-#x037D]
| [#x037F-#x1FFF]
| [#x200C-#x200D]
| [#x2070-#x218F]
| [#x2C00-#x2FEF]
| [#x3001-#xD7FF]
| [#xF900-#xFDCF]
| [#xFDF0-#xFFFD]
| [#x10000-#xEFFFF]
PN_CHARS_U ::= PN_CHARS_BASE | '_'
PN_CHARS ::= PN_CHARS_U | "-" | [0-9] | #x00B7 | [#x0300-#x036F] | [#x203F-#x2040]
PN_PREFIX ::= PN_CHARS_BASE ( ( PN_CHARS | "." )* PN_CHARS )?
PN_LOCAL ::= ( PN_CHARS_U | ':' | [0-9] | PLX ) ( ( PN_CHARS | '.' | ':' | PLX )* ( PN_CHARS | ':' | PLX ) ) ?
PLX ::= PERCENT | PN_LOCAL_ESC
PERCENT ::= '%' HEX HEX
HEX ::= [0-9] | [A-F] | [a-f]
PN_LOCAL_ESC ::= '\' ( '_' | '~' | '.' | '-' | '!' | '$' | '&' | "'" | '(' | ')' | '*' | '+' | ',' | ';' | '='
| '/' | '?' | '#' | '@' | '%' )
IRIREF ::= '<' ([^#x00-#x20<>"{}|^`\] | UCHAR)* '>' /* #x00=NULL #01-#x1F=control codes #x20=space */
PNAME_NS ::= PN_PREFIX? ':'
PNAME_LN ::= PNAME_NS PN_LOCAL
BLANK_NODE_LABEL ::= '_:' ( PN_CHARS_U | [0-9] ) ((PN_CHARS|'.')* PN_CHARS)?
LANG_DIR ::= '@' [a-zA-Z]+ ( '-' [a-zA-Z0-9]+ )* ( '--' [a-zA-Z]+ )?
INTEGER ::= [+-]? [0-9]+
DECIMAL ::= [+-]? ( ([0-9])* '.' ([0-9])+ )
DOUBLE ::= [+-]? ( [0-9]+ '.' [0-9]* EXPONENT | '.' ([0-9])+ EXPONENT | ([0-9])+ EXPONENT )
EXPONENT ::= [eE] [+-]? [0-9]+
STRING_LITERAL_QUOTE ::= '"' ( [^#x22#x5C#xA#xD] | ECHAR | UCHAR )* '"' /* #x22=" #x5C=\ #xA=new line #xD=carriage return */
STRING_LITERAL_SINGLE_QUOTE ::= "'" ( [^#x27#x5C#xA#xD] | ECHAR | UCHAR )* "'" /* #x27=' #x5C=\ #xA=new line #xD=carriage return */
STRING_LITERAL_LONG_SINGLE_QUOTE ::= "'''" ( ( "'" | "''" )? ( [^'\] | ECHAR | UCHAR ) )* "'''"
STRING_LITERAL_LONG_QUOTE ::= '"""' ( ( '"' | '""' )? ( [^"\] | ECHAR | UCHAR ) )* '"""'
UCHAR ::= ( '\u' HEX HEX HEX HEX ) | ( '\U' HEX HEX HEX HEX HEX HEX HEX HEX )
ECHAR ::= ('\' [tbnrf\"'])
NIL ::= '(' WS* ')'
WS ::= #x20 | #x9 | #xD | #xA /* #x20=space #x9=character tabulation #xD=carriage return #xA=new line */
ANON ::= '[' WS* ']'
PN_CHARS_BASE ::= ([A-Z]
| [a-z]
| [#x00C0-#x00D6]
| [#x00D8-#x00F6]
| [#x00F8-#x02FF]
| [#x0370-#x037D]
| [#x037F-#x1FFF]
| [#x200C-#x200D]
| [#x2070-#x218F]
| [#x2C00-#x2FEF]
| [#x3001-#xD7FF]
| [#xF900-#xFDCF]
| [#xFDF0-#xFFFD]
| [#x10000-#xEFFFF])
PN_CHARS_U ::= PN_CHARS_BASE | '_'
PN_CHARS ::= (PN_CHARS_U
| '-'
| [0-9]
| #x00B7
| [#x0300-#x036F]
| [#x203F-#x2040])
PN_PREFIX ::= PN_CHARS_BASE ( ( PN_CHARS | '.' )* PN_CHARS )?
PN_LOCAL ::= ( PN_CHARS_U | ':' | [0-9] | PLX ) ( ( PN_CHARS | '.' | ':' | PLX )* ( PN_CHARS | ':' | PLX ) ) ?
PLX ::= PERCENT | PN_LOCAL_ESC
PERCENT ::= '%' HEX HEX
HEX ::= ([0-9] | [A-F] | [a-f])
PN_LOCAL_ESC ::= '\' ( '_' | '~' | '.' | '-' | '!' | '$' | '&' | "'" | '(' | ')' | '*' | '+' | ',' | ';' | '=' | '/' | '?' | '#' | '@' | '%' )
3 changes: 2 additions & 1 deletion spec/ntriples_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
describe "w3c N-Triples tests" do
require 'suite_helper'

%w(rdf11/rdf-n-triples/manifest.ttl rdf12/rdf-n-triples/c14n/manifest.ttl).each do |man|
%w(rdf11/rdf-n-triples/manifest.ttl rdf12/rdf-n-triples/syntax/manifest.ttl rdf12/rdf-n-triples/c14n/manifest.ttl).each do |man|
Fixtures::SuiteTest::Manifest.open(Fixtures::SuiteTest::BASE + man) do |m|
describe m.comment do
m.entries.each do |t|
Expand All @@ -17,6 +17,7 @@

reader = RDF::NTriples::Reader.new(t.input,
logger: t.logger,
rdfstar: true,
validate: true)

graph = RDF::Graph.new
Expand Down
1 change: 0 additions & 1 deletion spec/star_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
require 'suite_helper'

%w(
rdf12/rdf-n-triples/syntax/manifest.ttl
rdf12/rdf-turtle/syntax/manifest.ttl
rdf12/rdf-turtle/eval/manifest.ttl).each do |man|
Fixtures::SuiteTest::Manifest.open(Fixtures::SuiteTest::BASE + man) do |m|
Expand Down

0 comments on commit 049e6a5

Please sign in to comment.