Adding grammer and parsing sections
authorGavin Carothers <gavin@carothers.name>
Fri, 10 Jun 2011 15:31:29 -0700
changeset 38 c2e08dd38571
parent 37 80c3a1657266
child 39 e0b8c76957c7
Adding grammer and parsing sections
rdf-turtle/bnf
rdf-turtle/index.html
rdf-turtle/turtle.bnf
--- a/rdf-turtle/bnf	Fri Jun 10 15:04:03 2011 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,64 +0,0 @@
-[1]  Query			::= Prologue ConstructQuery
-[2]  Prologue			::= BaseDecl? PrefixDecl*
-[3]  BaseDecl			::= BASE IRI_REF '.'
-[4]  PrefixDecl			::= PREFIX PNAME_NS IRI_REF '.'
-[6]  ConstructQuery		::= ConstructTemplate
-[30] ConstructTemplate		::= ConstructTriples?
-[31] ConstructTriples		::= TriplesSameSubject ( '.' ConstructTriples? )?
-[32] TriplesSameSubject		::= GraphTerm PropertyListNotEmpty | TriplesNode PropertyList
-[33] PropertyListNotEmpty	::= Verb ObjectList ( ';' ( Verb ObjectList )? )*
-[34] PropertyList		::= PropertyListNotEmpty?
-[35] ObjectList			::= Object ( ',' Object )*
-[36] Object			::= GraphNode
-[37] Verb			::= IRIref | 'a'
-[38] TriplesNode		::= Collection | BlankNodePropertyList
-[39] BlankNodePropertyList	::= '[' PropertyListNotEmpty ']'
-[40] Collection			::= '(' GraphNode+ ')'
-[41] GraphNode			::= GraphTerm | TriplesNode
-[45] GraphTerm			::= IRIref | RDFLiteral | NumericLiteral | BooleanLiteral | BlankNode | NIL
-[60] RDFLiteral			::= String ( LANGTAG | ( '^^' IRIref ) )?
-[61] NumericLiteral		::= NumericLiteralUnsigned | NumericLiteralPositive | NumericLiteralNegative
-[62] NumericLiteralUnsigned	::= INTEGER | DECIMAL | DOUBLE
-[63] NumericLiteralPositive	::= INTEGER_POSITIVE | DECIMAL_POSITIVE | DOUBLE_POSITIVE
-[64] NumericLiteralNegative	::= INTEGER_NEGATIVE | DECIMAL_NEGATIVE | DOUBLE_NEGATIVE
-[65] BooleanLiteral		::= 'true' | 'false'
-[66] String			::= STRING_LITERAL1 | STRING_LITERAL2 | STRING_LITERAL_LONG1 | STRING_LITERAL_LONG2
-[67] IRIref			::= IRI_REF | PrefixedName
-[68] PrefixedName		::= PNAME_LN | PNAME_NS
-[69] BlankNode			::= BLANK_NODE_LABEL | ANON
-
-@terminals
-
-[70] IRI_REF			::= '<' ([^<>\"{}|^`\\]-[#x00-#x20])* '>'
-[71] PNAME_NS			::= PN_PREFIX? ':'
-[72] PNAME_LN			::= PNAME_NS PN_LOCAL
-[73] BLANK_NODE_LABEL		::= '_:' PN_LOCAL
-[74] BASE                       ::= '@base'
-[75] PREFIX                     ::= '@prefix'
-[76] LANGTAG			::= BASE | PREFIX | '@999' [a-zA-Z]+ ('-' [a-zA-Z0-9]+)*
-[77] INTEGER			::= [0-9]+
-[78] DECIMAL			::= [0-9]* '.' [0-9]+
-[79] DOUBLE			::= [0-9]+ '.' [0-9]* EXPONENT | '.' ([0-9])+ EXPONENT | ([0-9])+ EXPONENT
-[80] INTEGER_POSITIVE		::= '+' INTEGER
-[81] DECIMAL_POSITIVE		::= '+' DECIMAL
-[82] DOUBLE_POSITIVE		::= '+' DOUBLE
-[83] INTEGER_NEGATIVE		::= '-' INTEGER
-[84] DECIMAL_NEGATIVE		::= '-' DECIMAL
-[85] DOUBLE_NEGATIVE		::= '-' DOUBLE
-[86] EXPONENT			::= [eE] [+-]? [0-9]+
-[87] STRING_LITERAL1		::= "'" ( ([^#x27#x5C#xA#xD]) | ECHAR )* "'"
-[88] STRING_LITERAL2		::= '"' ( ([^#x22#x5C#xA#xD]) | ECHAR )* '"'
-[89] STRING_LITERAL_LONG1	::= "'''" ( ( "'" | "''" )? ( [^'\\] | ECHAR ) )* "'''"
-[90] STRING_LITERAL_LONG2	::= '"""' ( ( '"' | '""' )? ( [^"\\] | ECHAR ) )* '"""'
-[91] ECHAR			::= '\\' [tbnrf\\"']
-[92] NIL			::= '(' WS* ')'
-[93] WS				::= #x20 | #x9 | #xD | #xA
-[94] ANON			::= '[' WS* ']'
-[95] 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]
-[96] PN_CHARS_U			::= PN_CHARS_BASE | '_'
-[98] PN_CHARS			::= PN_CHARS_U | '-' | [0-9] | #x00B7 | [#x0300-#x036F] | [#x203F-#x2040]
-[99] PN_PREFIX			::= PN_CHARS_BASE ((PN_CHARS|'.')* PN_CHARS)?
-[100] PN_LOCAL			::= ( PN_CHARS_U | [0-9] ) ((PN_CHARS|'.')* PN_CHARS)?
-
-@pass: [ \t\r\n]+ | '#' [^\r\n]*
-
--- a/rdf-turtle/index.html	Fri Jun 10 15:04:03 2011 -0700
+++ b/rdf-turtle/index.html	Fri Jun 10 15:31:29 2011 -0700
@@ -80,8 +80,12 @@
     <script>
     function updateExample(doc, content) {
     // perform transformations to make it render and prettier
-    return '<pre class="example">' + doc._esc(content) + '</pre>';
+      return '<pre class="example">' + doc._esc(content) + '</pre>';
     }
+    function esc(doc, content) {
+      return doc._esc(content);
+    }
+
     </script>
 	
     </head>
@@ -455,6 +459,255 @@
 
 			<p>The Turtle syntax for literals and blank nodes are defined by <a href="http://www.w3.org/TR/rdf-sparql-query/#QSynLiterals">SPARQL Query section 4.1.2</a> and <a href="http://www.w3.org/TR/rdf-sparql-query/#QSynBlankNodes">SPARQL Query section 4.1.4</a> respectively.</p>
 		</section>
+        <section id="sec-grammar">
+          <h2>Turtle Grammar</h2>
+
+          <p>A Turtle document is a
+          Unicode[[!Unicode]]
+          character string encoded in UTF-8.
+          Unicode codepoints only in the range U+0 to U+10FFFF inclusive are
+          allowed.
+          </p>
+          <section id="sec-grammar-ws">
+            <h3>White Space</h3>
+
+            <p>White space (production <a href="#prod-turtle2-WS">ws</a>) is used to separate
+            two tokens which would otherwise be (mis-)recognized as one token.
+
+            </p>
+
+            <p>White space is significant in tokens
+            <a href="#prod-turtle2-IRI_REF">IRI_REF</a> and <a href="#prod-turtle2-String">string</a>.
+            </p>
+          </section>
+          <section id="sec-grammar-comments">
+            <h3>Comments</h3>
+
+            <p>Comments in Turtle take the form of '#', outside an
+            <a href="#prod-turtle2-IRI_REF">IRI_REF</a> or strings,
+            and continue to the end of line (marked by characters U+000D or U+000A)
+            or end of file if there is no end of line after the comment
+            marker.  Comments are treated as white space.
+
+            </p>
+          </section>
+          <section  id="sec-strings">
+            <h3>String Escapes</h3>
+
+            <p>Turtle strings and URIs can use <code>\</code>-escape sequences to
+            represent Unicode code points.</p>
+
+
+            <p>The following table describes all the escapes
+            allowed inside a <a href="#prod-turtle2-String">string</a>
+            or <a href="#prod-turtle2-IRI_REF">IRI_REF</a>:</p>
+
+            <table border="1" summary="Turtle string escapes">
+              <tbody>
+                <tr>
+                  <th>Escape</th>
+
+                  <th>Unicode code point</th>
+
+                </tr>
+
+                <tr>
+                  <td>'\u' <a href="#rHEX">hex</a> <a href="#rHEX">hex</a> <a href="#rHEX">hex</a> <a href="#rHEX">hex</a></td>
+                  <td>A Unicode codepoint in the range U+0 to U+FFFF inclusive
+              corresponding to the encoded hexadecimal value.</td>
+                </tr>
+
+                                                              
+                <tr>
+                  <td>'\U' <a href="#rHEX">hex</a> <a href="#rHEX">hex</a> <a href="#rHEX">hex</a> <a href="#rHEX">hex</a> <a href="#rHEX">hex</a> <a href="#rHEX">hex</a> <a href="#rHEX">hex</a> <a href="#rHEX">hex</a></td>
+
+                  <td>A Unicode codepoint in the range U+10000 to U+10FFFF inclusive
+              corresponding to the encoded hexadecimal value.</td>
+                </tr>
+
+                <tr>
+                  <td>'\t'</td>
+                  <td>U+0009</td>
+                </tr>
+                                                              
+                <tr>
+
+                  <td>'\n'</td>
+                  <td>U+000A</td>
+                </tr>
+                                                              
+                <tr>
+                  <td>'\r'</td>
+                  <td>U+000D</td>
+                </tr>
+
+                                                              
+                <tr>
+                  <td>'\"'<br />
+            (inside <a href="#prod-turtle2-String">string</a>)</td>
+                <td>U+0022</td>
+                </tr>
+                                                              
+                <tr>
+
+                  <td>'\>'<br />
+            (inside <a href="#prod-turtle2-IRI_REF">IRI_REF</a> only)</td>
+                  <td>U+003E</td>
+                </tr>
+                                                              
+                <tr>
+                  <td>'\\'</td>
+
+                  <td>U+005C</td>
+                </tr>
+                                                              
+              </tbody>
+            </table>
+
+            <p>where <a href="#rHEX">HEX</a> is a hexadecimal character</p>
+            <blockquote>
+              <p><span style="font-family: monospace; font-size: 85%;"><a id="rHEX">HEX</a> 
+            ::= [0-9] | [A-F] | [a-f]</span></p>
+
+            </blockquote>
+          </section>
+          <section id="sec-grammar-grammar">
+          <h3>Grammar</h3>
+            <p>The EBNF used here is defined in XML 1.0 (Third Edition)
+            <a href="#ref-notation">[NOTATION]</a>. Production labels consisting of a number and a final 's', e.g. [<a href="http://www.w3.org/TR/2008/REC-rdf-sparql-query-20080115/#rRDFLiteral"><span class="prodNo">60s</span></a>], reference to the production with that number in the <a href="http://www.w3.org/TR/2008/REC-rdf-sparql-query-20080115/#sparqlGrammar">SPARQL Query Language for RDF grammar</a> <a href="#ref-sparqlq">[SPARQLQ]</a>.
+            </p>
+            <p class="note">At this point there should be the table output from yacker, but I has having trouble getting it to behave as expected.</p>
+            <pre data-include="turtle.bnf">
+            </pre>
+          </section>
+        </section>
+        <section id="sec-parsing"> 
+          <h2>Parsing</h2>
+
+          <p>The <a href="http://www.w3.org/TR/rdf-concepts/">RDF Concepts and Abstract Syntax</a> ([[!RDF-CONCEPTS]]) specification defines three types of <em>RDF Term</em>:
+
+          <a href="http://www.w3.org/TR/2004/REC-rdf-concepts-20040210/#dfn-URI-reference">RDF URI References</a> (here called IRIs),
+          <a href="http://www.w3.org/TR/2004/REC-rdf-concepts-20040210/#dfn-literal">literals</a> and
+          <a href="http://www.w3.org/TR/2004/REC-rdf-concepts-20040210/#dfn-blank-node">blank nodes</a>.
+          Literals are composed of a <a href="http://www.w3.org/TR/rdf-concepts/#dfn-lexical-form">lexical form</a> and an optional <a href="http://www.w3.org/TR/2004/REC-rdf-concepts-20040210/#dfn-language-identifier">language tag</a> or datatype IRI.
+          An extra type, <code id="prefix" class="dfn">prefix</code>, is used during parsing to map string identifiers to namespace IRIs.
+
+          <!-- The Turtle grammar uses the same productions and terminals to create these terms as does <a href="http://www.w3.org/TR/rdf-sparql-query/#grammar">SPARQL</a>. --><!-- This set is listed in <a href="http://www.w3.org/TR/rdf-sparql-query/#docTerminology">SPARQL §1.2.4</a>. -->
+
+          This section maps a string conforming to the grammar in <a href="#sec-grammar-grammar">section 4.4</a> to a set of triples by mapping this strings matching productions and lexical tokens to these RDF terms or their components (e.g. language tags, lexical forms of literals). Some productions change the parser state (base or prefix declarations).</p>
+          <section id="sec-parsing-state">
+          <h3>Parser State</h3>
+
+              <p>Parsing Turtle requires a state of four items:</p>
+
+              <ul>
+                <li id="baseURI">IRI <code class="dfn">baseURI</code> — When the <a href="#prod-turtle2-base">base production</a> is reached, the second rule argument, <code>IRI_REF</code>, is the base URI used for relative IRI resolution <span class="testrefs">(test: <a href="tests/#base1">base1</a> <a href="tests/#base2">base2</a>)</span>.</li>
+
+                <li id="namespaces">Map[<a class="type prefix" href="#prefix">prefix</a> -&gt; IRI] <code class="dfn">namespaces</code> — The second and third rule arguments (<code>PNAME_NS</code> and <code>IRI_REF</code>) in the <a href="#prod-turtle2-prefixID">prefixID production</a> assign a namespace name (<code>IRI_REF</code>) for the prefix (<code>PNAME_NS</code>). Outside of a <code>prefixID</code> production, any <code>PNAME_NS</code> is substituted with the namespace <span class="testrefs">(test: <a href="tests/#prefix1">prefix1</a> <!-- a href="tests/#escapedPrefix1">escapedPrefix1</a --> <a href="tests/#escapedNamespace1">escapedNamespace1</a>)</span>. Note that the prefix may be an empty string, per the <code>PNAME_NS,</code> production: <code>(PN_PREFIX)? ":"</code> <span class="testrefs">(test: <a href="tests/#default1">default1</a>)</span>.</li>
+
+                <li id="bnodeLabels">Map[<a class="type string">string</a> -&gt; <a href="http://www.w3.org/TR/2004/REC-rdf-concepts-20040210/#dfn-blank-node">blank node</a>] <code class="dfn">bnodeLabels</code> — A mapping from string to blank node label.</li>
+                <li id="curSubject">RDF_Term <code class="dfn">curSubject</code> — The <code class="curSubject">curSubject</code> is bound to the <code><a href="#prod-turtle2-subject">subject</a></code> production.</li>
+
+                <li id="curPredicate">RDF_Term <code class="dfn">curPredicate</code> — The <code class="curPredicate">curPredicate</code> is bound to the <code><a href="#prod-turtle2-verb">verb</a></code> production. If token matched was "<code>a</code>", <code class="curPredicate">curPredicate</code> is bound to the IRI <code>http://www.w3.org/1999/02/22-rdf-syntax-ns#type</code> <span class="testrefs">(test: <a href="tests/#type">type</a>)</span>.</li>
+
+              </ul>
+          </section>
+          <section  id="sec-parsing-terms">
+          <h3>RDF Term Constructors</h3>
+
+              <p>This table maps productions and lexical tokens to <code>RDF terms</code> or components of <code>RDF terms</code> listed in <a href="#sec-parsing">section 5</a>:</p>
+
+              <table>
+                <thead>
+              <tr>                                  <th>                                                                       production               </th><th>                                                                                       type            </th><th>procedure</th></tr>
+                </thead>
+                <tbody>
+              <tr id="handle-IRI_REF"              ><td><a class="type IRI"         href="#prod-turtle2-IRI_REF"              >IRI_REF              </a></td><td><a href="http://www.w3.org/TR/2004/REC-rdf-concepts-20040210/#dfn-URI-reference">      IRI         </a></td><td>The characters between "&lt;" and "&gt;" are <a href="#unescape">unescaped¹</a> to form the unicode string of the IRI. Relative IRI resolution is performed per <a href="http://www.w3.org/TR/rdf-sparql-query/#QSynIRI">SPARQL Query section 4.1.1</a>.</td></tr>
+
+              <tr id="handle-PNAME_NS"             ><td><a class="type string"      href="#prod-turtle2-PNAME_NS"             >PNAME_NS             </a></td><td><a href="#prefix">                                                                     prefix      </a></td><td>The potentially empty unicode string matching the first argument of the rule is a key into the <a href="#namespaces">namespaces map</a>.</td></tr>
+              <tr id="handle-PNAME_LN"             ><td><a class="type IRI"         href="#prod-turtle2-PNAME_LN"             >PNAME_LN             </a></td><td><a href="http://www.w3.org/TR/2004/REC-rdf-concepts-20040210/#dfn-URI-reference">      IRI         </a></td><td>A <a href="#prefix">prefix</a> is identified by the first argument, <code>PNAME_NS</code>. The <a href="#namespaces">namespaces map</a> has a corresponding <code>namespace</code>. The unicode string of the IRI is formed by concatenating this <code>namespace</code> and the second argument, <code>PN_LOCAL</code>. Relative IRI resolution is performed per <a href="http://www.w3.org/TR/rdf-sparql-query/#QSynIRI">SPARQL Query section 4.1.1</a>.</td></tr>
+
+              <tr id="handle-STRING_LITERAL1"      ><td><a class="type lexicalForm" href="#prod-turtle2-STRING_LITERAL1"      >STRING_LITERAL1      </a></td><td><a href="http://www.w3.org/TR/rdf-concepts/#dfn-lexical-form">                         lexical form</a></td><td>The characters between the outermost "'"s are <a href="#unescape">unescaped¹</a> to form the unicode string of a lexical form.</td></tr>
+              <tr id="handle-STRING_LITERAL2"      ><td><a class="type lexicalForm" href="#prod-turtle2-STRING_LITERAL2"      >STRING_LITERAL2      </a></td><td><a href="http://www.w3.org/TR/rdf-concepts/#dfn-lexical-form">                         lexical form</a></td><td>The characters between the outermost '"'s are <a href="#unescape">unescaped¹</a> to form the unicode string of a lexical form.</td></tr>
+
+              <tr id="handle-STRING_LITERAL_LONG1" ><td><a class="type lexicalForm" href="#prod-turtle2-STRING_LITERAL_LONG1" >STRING_LITERAL_LONG1 </a></td><td><a href="http://www.w3.org/TR/rdf-concepts/#dfn-lexical-form">                         lexical form</a></td><td>The characters between the outermost "'''"s are <a href="#unescape">unescaped¹</a> to form the unicode string of a lexical form.</td></tr>
+              <tr id="handle-STRING_LITERAL_LONG2" ><td><a class="type lexicalForm" href="#prod-turtle2-STRING_LITERAL_LONG2" >STRING_LITERAL_LONG2 </a></td><td><a href="http://www.w3.org/TR/rdf-concepts/#dfn-lexical-form">                         lexical form</a></td><td>The characters between the outermost '"""'s are <a href="#unescape">unescaped¹</a> to form the unicode string of a lexical form.</td></tr>
+
+                  <tr id="handle-LANGTAG"              ><td><a class="type langTag"     href="#prod-turtle2-LANGTAG"              >LANGTAG              </a></td><td><a href="http://www.w3.org/TR/2004/REC-rdf-concepts-20040210/#dfn-language-identifier">language tag</a></td><td>The characters following the "@" form the unicode string of the language tag.</td></tr>
+              <tr id="handle-RDFLiteral"           ><td><a class="type literal"     href="#prod-turtle2-RDFLiteral"           >RDFLiteral           </a></td><td><a href="http://www.w3.org/TR/2004/REC-rdf-concepts-20040210/#dfn-literal">            literal     </a></td><td>The literal has a lexical form of the first rule argument (<code>String</code>) and either a language tag of <code>LANGTAG</code> or a datatype URI of <code>URIref</code>, depending on which rule matched the input.</td></tr>
+
+              <tr id="handle-INTEGER"              ><td><a class="type integer"     href="#prod-turtle2-INTEGER"              >INTEGER              </a></td><td><a href="http://www.w3.org/TR/2004/REC-rdf-concepts-20040210/#dfn-literal">            literal     </a></td><td>The literal has a lexical form of the input string, and a datatype of xsd:integer.</td></tr>
+              <tr id="handle-DECIMAL"              ><td><a class="type decimal"     href="#prod-turtle2-DECIMAL"              >DECIMAL              </a></td><td><a href="http://www.w3.org/TR/2004/REC-rdf-concepts-20040210/#dfn-literal">            literal     </a></td><td>The literal has a lexical form of the input string, and a datatype of xsd:decimal.</td></tr>
+              <tr id="handle-DOUBLE"               ><td><a class="type double"      href="#prod-turtle2-DOUBLE"               >DOUBLE               </a></td><td><a href="http://www.w3.org/TR/2004/REC-rdf-concepts-20040210/#dfn-literal">            literal     </a></td><td>The literal has a lexical form of the input string, and a datatype of xsd:double.</td></tr>
+
+              <tr id="handle-BooleanLiteral"       ><td><a class="type boolean"     href="#prod-turtle2-BooleanLiteral"       >BooleanLiteral       </a></td><td><a href="http://www.w3.org/TR/2004/REC-rdf-concepts-20040210/#dfn-literal">            literal     </a></td><td>The literal has a lexical form of the "true" or "false", depending on which matched the input, and a datatype of xsd:boolean.</td></tr>
+              <tr id="handle-BLANK_NODE_LABEL"     ><td><a class="type bNode"       href="#prod-turtle2-BLANK_NODE_LABEL"     >BLANK_NODE_LABEL     </a></td><td><a href="http://www.w3.org/TR/2004/REC-rdf-concepts-20040210/#dfn-blank-node">         blank node  </a></td><td>The string matching the second argument, <code>PN_LOCAL</code>, is a key in <a href="#bnodeLabels">bnodeLabels</a>. If there is no corresponding blank node in the map, one is allocated.</td></tr>
+              <tr id="handle-ANON"                 ><td><a class="type bNode"       href="#prod-turtle2-ANON"                 >ANON                 </a></td><td><a href="http://www.w3.org/TR/2004/REC-rdf-concepts-20040210/#dfn-blank-node">         blank node  </a></td><td>A blank node is generated.</td></tr>
+
+              <tr id="handle-blankNodePropertyList"><td><a class="type bNode"       href="#prod-turtle2-blankNodePropertyList">blankNodePropertyList</a></td><td><a href="http://www.w3.org/TR/2004/REC-rdf-concepts-20040210/#dfn-blank-node">         blank node  </a></td><td>A blank node is generated. Note the rules for <code>blankNodePropertyList</code> in the next section.</td></tr>
+              <tr id="handle-collection"           ><td><a class="type bNode"       href="#prod-turtle2-collection"           >collection           </a></td><td><a href="http://www.w3.org/TR/2004/REC-rdf-concepts-20040210/#dfn-blank-node">         blank node  </a></td><td>A blank node is generated. Note the rules for <code>collection</code> in the next section.</td></tr>
+
+                </tbody>
+              </table>
+
+              <p><a id="unescape">¹</a> <a href="http://www.w3.org/TeamSubmission/turtle/#sec-strings">Section 3.3</a> defines an mapping from <code>escaped unicode strings</code> to <code>unicode strings</code>. The following lexical tokens are unescaped to produce <code>unicode strings</code>: <a class="type IRI" href="#prod-turtle2-IRI_REF">IRI_REF</a>, <!-- <a class="type PNAME_NS" href="#prod-turtle2-PNAME_NS">PNAME_NS</a>, --><!-- <a class="type IRI"          href="#prod-turtle2-PNAME_LN">PNAME_LN</a>, --><a class="type lexicalForm"  href="#prod-turtle2-STRING_LITERAL1">STRING_LITERAL1</a>, <a class="type lexicalForm"  href="#prod-turtle2-STRING_LITERAL2">STRING_LITERAL2</a>, <a class="type lexicalForm"  href="#prod-turtle2-STRING_LITERAL_LONG1">STRING_LITERAL_LONG1</a> and <a class="type lexicalForm"  href="#prod-turtle2-STRING_LITERAL_LONG2">STRING_LITERAL_LONG2</a><!-- and <a class="type langTag"      href="#prod-turtle2-LANGTAG">LANGTAG</a> --><!-- and <a class="type bNode"        href="#prod-turtle2-BLANK_NODE_LABEL">BLANK_NODE_LABEL</a> -->.</p>
+          </section>
+          <section id="sec-parsing-triples">
+          <h3>RDF Triples Constructors</h3>
+              <p>A Turtle document defines an <a href="http://www.w3.org/TR/2004/REC-rdf-concepts-20040210/#dfn-rdf-graph">RDF graph</a> composed of set of <a href="http://www.w3.org/TR/2004/REC-rdf-concepts-20040210/#dfn-rdf-triple">RDF triple</a>s.
+          Each <a tabindex="30" class="grammarRef" href="#prod-turtle2-object">object</a> <code>N</code> in the document produces an RDF triple: <span class="ntriple"><code class="curSubject">curSubject</code> <code class="curPredicate">curPredicate</code> <code>N</code> .</span>
+
+          </p>
+
+          <p>
+          Beginning the <code><a href="#prod-turtle2-blankNodePropertyList">blankNodePropertyList</a></code> production records the <code class="curSubject">curSubject</code> and <code class="curPredicate">curPredicate</code>, and sets <code class="curSubject">curSubject</code> to a novel <code>blank node</code> <code>B</code>.
+          Finishing the <code><a href="#prod-turtle2-blankNodePropertyList">blankNodePropertyList</a></code> production restores <code class="curSubject">curSubject</code> and <code class="curPredicate">curPredicate</code>.
+          The node produced by matching <code><a href="#prod-turtle2-blankNodePropertyList">blankNodePropertyList</a></code> is the blank node <code>B</code>.
+
+          </p>
+
+          <p>
+          Beginning the <code><a href="#prod-turtle2-collection">collection</a></code> production records the <code class="curSubject">curSubject</code> and <code class="curPredicate">curPredicate</code>, sets <code class="curSubject">curSubject</code> to a novel <code>blank node</code> <code>B<sub>head</sub></code> and sets <code class="curSubject">curSubject</code> and <code class="curPredicate">curPredicate</code> to <code>B<sub>head</sub></code> and <code>rdf:first</code> respectively.
+          Each object <code>O</code> in <code><a href="#prod-turtle2-collection">collection</a></code> allocates a novel <code>blank node</code> <code>B<sub>n</sub></code>, creates an additional triple <span class="ntriple"><code>curSubject rdf:rest B<sub>n</sub></code> .</span> and sets <code>curSubject</code> to <code>B<sub>n</sub></code>.
+          Finishing the <code><a href="#prod-turtle2-collection">collection</a></code> production creates an additional triple <span class="ntriple"><code>curSubject rdf:rest rdf:nil</code> .</span> and restores <code class="curSubject">curSubject</code> and <code class="curPredicate">curPredicate</code>
+
+          The node produced by matching <code><a href="#prod-turtle2-collection">collection</a></code> is the blank node <code>B<sub>head</sub></code>.
+          </p>
+          <section id="sec-parsing-example">
+          <h3>Parsing Example (Informative)</h3>
+
+          <p>The following informative example shows the semantic actions performed when  parsing this Turtle document with an LALR(1) parser:</p>
+          <pre class="example">
+@prefix ericFoaf: &lt;http://www.w3.org/People/Eric/ericP-foaf.rdf#&gt; .
+@prefix : &lt;http://xmlns.com/foaf/0.1/&gt; .
+ericFoaf:ericP :givenName "Eric" ;
+              :knows &lt;http://norman.walsh.name/knows/who/dan-brickley&gt; ,
+                      [ :mbox &lt;mailto:timbl@w3.org&gt; ] ,
+                      &lt;http://getopenid.com/amyvdh&gt; .</pre>
+
+              <ul>
+                <li>Map the prefix <code>ericFoaf</code> to the IRI <code>http://www.w3.org/People/Eric/ericP-foaf.rdf#</code>.</li>
+                <li>Map the empty prefix to the IRI <code>http://xmlns.com/foaf/0.1/</code>.</li>
+                <li>Assign <code class="curSubject">curSubject</code> the IRI <code>http://www.w3.org/People/Eric/ericP-foaf.rdf#ericP</code>.</li>
+
+                <li>Assign <code class="curPredicate">curPredicate</code> the IRI <code>http://xmlns.com/foaf/0.1/givenName</code>.</li>
+                <li>Emit an RDF triple: <span class="ntriple"><code>&lt;...rdf#ericP&gt;</code> <code>&lt;.../givenName&gt;</code> <code>"Eric"</code> .</span></li>
+
+                <li>Assign <code class="curPredicate">curPredicate</code> the IRI <code>http://xmlns.com/foaf/0.1/knows</code>.</li>
+                <li>Emit an RDF triple: <span class="ntriple"><code>&lt;...rdf#ericP&gt;</code> <code>&lt;.../knows&gt;</code> <code>&lt;...who/dan-brickley&gt;</code> .</span></li>
+
+                <li>Emit an RDF triple: <span class="ntriple"><code>&lt;...rdf#ericP&gt;</code> <code>&lt;.../knows&gt;</code> <code>&lt;_:1&gt;</code> .</span></li>
+                <li>Save <code class="curSubject">curSubject</code> and reassign to the blank node <code>&lt;_:1&gt;</code>.</li>
+
+                <li>Save <code class="curPredicate">curPredicate</code>.</li>
+                <li>Assign <code class="curPredicate">curPredicate</code> the IRI <code>http://xmlns.com/foaf/0.1/mbox</code>.</li>
+                <li>Emit an RDF triple: <span class="ntriple"><code>_:1</code> <code>&lt;.../mbox&gt;</code> <code>&lt;mailto:timbl@w3.org&gt;</code> .</span></li>
+
+                <li>Restore <code class="curSubject">curSubject</code> and <code class="curPredicate">curPredicate</code> to their saved values (<code>&lt;...rdf#ericP&gt;</code>, <code>&lt;.../knows&gt;</code>).</li>
+                <li>Emit an RDF triple: <span class="ntriple"><code>&lt;...rdf#ericP&gt;</code> <code>&lt;.../knows&gt;</code> <code>&lt;http://getopenid.com/amyvdh&gt;</code> .</span></li>
+
+              </ul>
+          </section>
     </body>
 
 </html>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/rdf-turtle/turtle.bnf	Fri Jun 10 15:31:29 2011 -0700
@@ -0,0 +1,64 @@
+[1]  Query			::= Prologue ConstructQuery
+[2]  Prologue			::= BaseDecl? PrefixDecl*
+[3]  BaseDecl			::= BASE IRI_REF '.'
+[4]  PrefixDecl			::= PREFIX PNAME_NS IRI_REF '.'
+[6]  ConstructQuery		::= ConstructTemplate
+[30] ConstructTemplate		::= ConstructTriples?
+[31] ConstructTriples		::= TriplesSameSubject ( '.' ConstructTriples? )?
+[32] TriplesSameSubject		::= GraphTerm PropertyListNotEmpty | TriplesNode PropertyList
+[33] PropertyListNotEmpty	::= Verb ObjectList ( ';' ( Verb ObjectList )? )*
+[34] PropertyList		::= PropertyListNotEmpty?
+[35] ObjectList			::= Object ( ',' Object )*
+[36] Object			::= GraphNode
+[37] Verb			::= IRIref | 'a'
+[38] TriplesNode		::= Collection | BlankNodePropertyList
+[39] BlankNodePropertyList	::= '[' PropertyListNotEmpty ']'
+[40] Collection			::= '(' GraphNode+ ')'
+[41] GraphNode			::= GraphTerm | TriplesNode
+[45] GraphTerm			::= IRIref | RDFLiteral | NumericLiteral | BooleanLiteral | BlankNode | NIL
+[60] RDFLiteral			::= String ( LANGTAG | ( '^^' IRIref ) )?
+[61] NumericLiteral		::= NumericLiteralUnsigned | NumericLiteralPositive | NumericLiteralNegative
+[62] NumericLiteralUnsigned	::= INTEGER | DECIMAL | DOUBLE
+[63] NumericLiteralPositive	::= INTEGER_POSITIVE | DECIMAL_POSITIVE | DOUBLE_POSITIVE
+[64] NumericLiteralNegative	::= INTEGER_NEGATIVE | DECIMAL_NEGATIVE | DOUBLE_NEGATIVE
+[65] BooleanLiteral		::= 'true' | 'false'
+[66] String			::= STRING_LITERAL1 | STRING_LITERAL2 | STRING_LITERAL_LONG1 | STRING_LITERAL_LONG2
+[67] IRIref			::= IRI_REF | PrefixedName
+[68] PrefixedName		::= PNAME_LN | PNAME_NS
+[69] BlankNode			::= BLANK_NODE_LABEL | ANON
+
+@terminals
+
+[70] IRI_REF			::= '<' ([^<>\"{}|^`\\]-[#x00-#x20])* '>'
+[71] PNAME_NS			::= PN_PREFIX? ':'
+[72] PNAME_LN			::= PNAME_NS PN_LOCAL
+[73] BLANK_NODE_LABEL		::= '_:' PN_LOCAL
+[74] BASE                       ::= '@base'
+[75] PREFIX                     ::= '@prefix'
+[76] LANGTAG			::= BASE | PREFIX | '@999' [a-zA-Z]+ ('-' [a-zA-Z0-9]+)*
+[77] INTEGER			::= [0-9]+
+[78] DECIMAL			::= [0-9]* '.' [0-9]+
+[79] DOUBLE			::= [0-9]+ '.' [0-9]* EXPONENT | '.' ([0-9])+ EXPONENT | ([0-9])+ EXPONENT
+[80] INTEGER_POSITIVE		::= '+' INTEGER
+[81] DECIMAL_POSITIVE		::= '+' DECIMAL
+[82] DOUBLE_POSITIVE		::= '+' DOUBLE
+[83] INTEGER_NEGATIVE		::= '-' INTEGER
+[84] DECIMAL_NEGATIVE		::= '-' DECIMAL
+[85] DOUBLE_NEGATIVE		::= '-' DOUBLE
+[86] EXPONENT			::= [eE] [+-]? [0-9]+
+[87] STRING_LITERAL1		::= "'" ( ([^#x27#x5C#xA#xD]) | ECHAR )* "'"
+[88] STRING_LITERAL2		::= '"' ( ([^#x22#x5C#xA#xD]) | ECHAR )* '"'
+[89] STRING_LITERAL_LONG1	::= "'''" ( ( "'" | "''" )? ( [^'\\] | ECHAR ) )* "'''"
+[90] STRING_LITERAL_LONG2	::= '"""' ( ( '"' | '""' )? ( [^"\\] | ECHAR ) )* '"""'
+[91] ECHAR			::= '\\' [tbnrf\\"']
+[92] NIL			::= '(' WS* ')'
+[93] WS				::= #x20 | #x9 | #xD | #xA
+[94] ANON			::= '[' WS* ']'
+[95] 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]
+[96] PN_CHARS_U			::= PN_CHARS_BASE | '_'
+[98] PN_CHARS			::= PN_CHARS_U | '-' | [0-9] | #x00B7 | [#x0300-#x036F] | [#x203F-#x2040]
+[99] PN_PREFIX			::= PN_CHARS_BASE ((PN_CHARS|'.')* PN_CHARS)?
+[100] PN_LOCAL			::= ( PN_CHARS_U | [0-9] ) ((PN_CHARS|'.')* PN_CHARS)?
+
+@pass: [ \t\r\n]+ | '#' [^\r\n]*
+