Scanning
An Notation3 document is encoded as a series of tokens, encoded as UTF-8 bytes. Whitespace outside tokens is not significant. If a "#" is found outside a token, from the "#" to the end of the line is ignored. The valid tokens are:
- uriref
- <.*?>
- declaration
- @[A-Za-z]+
- prefix
- [A-Za-z0-9]*:
- name
- [A-Za-z0-9_-]+
- qname
- prefixname
- that is, a prefix followed immediately by a name
- literal1
- '.*?'
- literal2
- ".*?"
- literal3
- """.*?"""
- exivar
- _:name
- univar
- \?name
- list1
- \(
- list0
- \)
- block1
- \[
- block0
- \]
- formula1
- {
- formula0
- }
- comma
- ,
- semi
- ;
- equals
- =
- period
- \.
Parsing
The Notation3 grammar is made up of sentences, each of which is a directive or statement.
Directives
Directives are provide information supplementary to the data communicated by the document. The valid directives are:
- prefix
- "@prefix" prefix uriref period
- The parser should store the prefix to uriref mapping for later use. A l
Statements
Statements express the actual data communicated by the document. The valid types of statements are:
- standalone
- ( block | formula ) period
- The block or formula is asserted.
- extended
- term predicateObject ( semi predicateObject )* period
- The first term is added to the beginning of each pair returned by predicateObject to create a triple. This asserts all of these triples.
Partial statements are:
- predicateObject
- term object ( semi term object )*
- Each value in the list returned by object is placed after the immediately preceding term to create a pair. This returns a list of these pairs.
- object
- term ( comma term )*
- This returns a list of the terms.
- a
- "a"
- This refers to the URI-reference "http://www.w3.org/1999/02/22-rdf-syntax-ns#type".
- this
- "this"
- This refers to a reference to the enclosing formula.
- equals
- equals
- This refers to the URI-reference "http://www.daml.org/2001/03/daml+oil#equivalentTo".
- exivar
- exivar
- This resolves to the existentially quantified variable with the document-scope name following the "_:".
- univar
- univar
- This resolves to the universally quantified variable with the document-scope name following the "?".
- literal1
- literal1
- This refers to the string with the contents inside the quotes.
- literal2
- literal2
- This refers to the string with the contents inside the quotes.
- literal3
- literal3
- This refers to the string with the contents inside the quotes.
- uriref
- uriref
- This refers to the thing identified by the URI-reference inside the angle brackets.
- qname
- qname
- This refers to the URI-reference derived by taking the URI-reference stored with the prefix portion of the qname and concatenating it with the name portion of the qname.
- list
- list1 term* list0
- This refers to the DAML list with its contents as the terms, in order.
- block
- block1 predicateObject* block0
- This creates a new existentially quantified variable. This asserts the triples created by adding the existentially quantified variable to the front of each pair returned by predicateObject. This refers to the existentially quantified variable.
- formula
- formula1 statement* formula0
- This creates a new formula. The statements are asserted from within the context of the formula. This refers to the new formula.
Terms
A term is a part of a sentence. Valid terms are: