W3C home > Mailing lists > Public > public-rdf-wg@w3.org > May 2012

grammar alignment with SPARQL

From: Eric Prud'hommeaux <eric@w3.org>
Date: Thu, 10 May 2012 23:16:57 -0400
To: public-rdf-wg@w3.org
Message-ID: <20120511031654.GB2828@w3.org>
I tweaked a few bits of the yacker grammar which I suspect we'd want
to adopt in the Turtle spec. I trimmed out a bunch of extra ()s, had
to \ some characters which I don't believe are permitted anyways by
<http://www.w3.org/TR/REC-xml/#sec-notation> (#xN notation only).
The structural changes were:
  Simplified IRIREF from
   [132s] IRIREF ::= ('<' ([^<>"{}|^`\]-[#x00-#x20])* | UCHAR '>')
  to
   [132s] IRIREF ::=  '<' ([^#x00-#x20<>\"{}|^`\\] | UCHAR)* '>'
  (#sec-notation doesn't tell me the precedence of A | B - c)

  Removed ([+-])? before numerics in favor of re-using SPARQL's
   [142s] INTEGER_POSITIVE ::= '+' INTEGER
   [143s] DECIMAL_POSITIVE ::= '+' DECIMAL
   [144s] DOUBLE_POSITIVE  ::= '+' DOUBLE
   [145s] INTEGER_NEGATIVE ::= '-' INTEGER
   [146s] DECIMAL_NEGATIVE ::= '-' DECIMAL
   [147s] DOUBLE_NEGATIVE  ::= '-' DOUBLE

  In STRING_LITERAL_LONG1, Changed ''''' to "'''" 'cause who could
  know what "'''''" meant?

  In PN_CHARS, changed #00B7 to [#00B7] to work around a yacker
  bug. (This is just to document -- of course this doesn't go into
  the Turtle spec.

  In PN_LOCAL_ESC, changed ''' to "'".

Full yacker grammar
<http://www.w3.org/2005/01/yacker/uploads/turtleAwesome/bnf> follows:

[1]		turtleDoc		::= 	statement*
[2]		statement		::= 	directive '.' | triples '.'
[3]		directive		::= 	prefixID | base
[4]		prefixID		::= 	PREFIX PNAME_NS IRIREF
[5]		base		::= 	BASE IRIREF
[6]		triples		::= 	subject predicateObjectList
[7]		predicateObjectList		::= 	verb objectList (';' verb objectList)* (';')?
[8]		objectList		::= 	object (',' object)*
[9]		verb		::= 	predicate | 'a'
[10]		subject		::= 	iri | blank
[11]		predicate		::= 	iri
[12]		object		::= 	iri | blank | literal
[13]		literal		::= 	RDFLiteral | NumericLiteral | BooleanLiteral
[14]		blank		::= 	BlankNode | blankNodePropertyList | collection
[15]		blankNodePropertyList		::= 	'[' predicateObjectList ']'
[16]		collection		::= 	'(' object* ')'
[60s]		RDFLiteral		::= 	String (LANGTAG | '^^' iri)?
[61s]		NumericLiteral		::= 	NumericLiteralUnsigned | NumericLiteralPositive | NumericLiteralNegative
[62s]		NumericLiteralUnsigned		::= 	INTEGER | DECIMAL | DOUBLE
[63s]		NumericLiteralPositive		::= 	INTEGER_POSITIVE | DECIMAL_POSITIVE | DOUBLE_POSITIVE
[64s]		NumericLiteralNegative		::= 	INTEGER_NEGATIVE | DECIMAL_NEGATIVE | DOUBLE_NEGATIVE
[65s]		BooleanLiteral		::= 	'true' | 'false'
[66s]		String		::= 	STRING_LITERAL1 | STRING_LITERAL2 | STRING_LITERAL_LONG1 | STRING_LITERAL_LONG2
[67s]		iri		::= 	IRIREF | PrefixedName
[68s]		PrefixedName		::= 	PNAME_LN | PNAME_NS
[69s]		BlankNode		::= 	BLANK_NODE_LABEL | ANON

@terminals

[17]		BASE		::= 	'@base'
[18]		PREFIX		::= 	'@prefix'
[132s]		IRIREF		::= 	'<' ([^#x00-#x20<>\"{}|^`\\] | UCHAR)* '>'
[133s]		PNAME_NS		::= 	PN_PREFIX? ':'
[134s]		PNAME_LN		::= 	PNAME_NS PN_LOCAL
[135s]		BLANK_NODE_LABEL		::= 	'_:' (PN_CHARS_U | [0-9]) ((PN_CHARS | '.')* PN_CHARS)?
[19]		LANGTAG		::= 	BASE | PREFIX | '@' [a-zA-Z]+ ('-' [a-zA-Z0-9]+)*
[139s]		INTEGER		::= 	[0-9]+
[140s]		DECIMAL		::= 	[0-9]* '.' [0-9]+
[141s]		DOUBLE		::= 	[0-9]+ '.' [0-9]* EXPONENT | '.' [0-9]+ EXPONENT | [0-9]+ EXPONENT
[142s] 		INTEGER_POSITIVE ::= 	'+' INTEGER
[143s] 		DECIMAL_POSITIVE ::= 	'+' DECIMAL
[144s] 		DOUBLE_POSITIVE  ::= 	'+' DOUBLE
[145s] 		INTEGER_NEGATIVE ::= 	'-' INTEGER
[146s] 		DECIMAL_NEGATIVE ::= 	'-' DECIMAL
[147s] 		DOUBLE_NEGATIVE  ::= 	'-' DOUBLE
[148s]		EXPONENT		::= 	[eE] [+-]? [0-9]+
[149s]		STRING_LITERAL1		::= 	"'" ([^#x27#x5C#xA#xD] | ECHAR | UCHAR)* "'"
[150s]		STRING_LITERAL2		::= 	'"' ([^#x22#x5C#xA#xD] | ECHAR | UCHAR)* '"'
[151s]		STRING_LITERAL_LONG1		::= 	"'''" (("'" | "''")? ([^'\\] | ECHAR | UCHAR))* "'''"
[152s]		STRING_LITERAL_LONG2		::= 	'"""' (('"' | '""')? ([^\"\\] | ECHAR | UCHAR))* '"""'
[19]		UCHAR		::= 	('\\u' HEX HEX HEX HEX | '\\U' HEX HEX HEX HEX HEX HEX HEX HEX)
[153s]		ECHAR		::= 	'\\' [tbnrf\\\"']
[154s]		NIL		::= 	'(' WS* ')'
[155s]		WS		::= 	#x20 | #x9 | #xD | #xA
[156s]		ANON		::= 	'[' WS* ']'
[157s]		PN_CHARS_BASE		::= 	[A-Z] | [a-z] | [#00C0-#00D6] | [#00D8-#00F6] | [#00F8-#02FF] | [#0370-#037D] | [#037F-#1FFF] | [#200C-#200D] | [#2070-#218F] | [#2C00-#2FEF] | [#3001-#D7FF] | [#F900-#FDCF] | [#FDF0-#FFFD] | [#10000-#EFFFF]
[158s]		PN_CHARS_U		::= 	PN_CHARS_BASE | '_' | ':'
[160s]		PN_CHARS		::= 	PN_CHARS_U | '-' | [0-9] | [#00B7] | [#0300-#036F] | [#203F-#2040]
[161s]		PN_PREFIX		::= 	PN_CHARS_BASE ((PN_CHARS | '.')* PN_CHARS)?
[162s]		PN_LOCAL		::= 	(PN_CHARS_U | [0-9] | PLX) ((PN_CHARS | '.' | PLX)* (PN_CHARS | PLX))?
[163s]		PLX		::= 	PERCENT | PN_LOCAL_ESC
[164s]		PERCENT		::= 	'%' HEX HEX
[165s]		HEX		::= 	[0-9] | [A-F] | [a-f]
[166s]		PN_LOCAL_ESC		::= 	'\\' ('_' | '~' | '.' | '-' | '!' | '$' | '&' | "'" | '(' | ')' | '*' | '+' | ',' | ';' | '=' | '/' | '?' | '#' | '@' | '%')

@pass ::= [ \t\r\n]+
 | "#" [^\r\n]* 

-- 
-ericP
Received on Friday, 11 May 2012 03:17:31 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 16:25:48 GMT