Full Grammar
There are two kind of files in a dolfin package. The package.dlf
placed at the root of a package folder, it serves as a manifest of the whole package. We give an exemple of such a file here and let the grammar being deduced.
package <http://my.special.iri/of-ontology>:
dolfin_version: 1
version: 1.2.3
author: not only me
author: but also you
description: This package is an example
There are regular dolfin files. The folder in which they are, are used to compose the iri of each ontology and then the iri of each element.
ontology ::=
iri_name_annotation?
prefix_statement*
declaration*
EOF
iri_name_annotation ::=
"@iri_name" String NEWLINE
prefix_statement ::=
"prefix" prefix_target
prefix_target ::=
qualified_name_or_iri ":" NEWLINE
INDENT
prefix_target+
DEDENT
| qualified_name_or_iri "as" Name NEWLINE
| qualified_name_or_iri NEWLINE
declaration ::=
concept
| property
| rule
concept ::=
"concept" Name ":" NEWLINE
INDENT
concept_member+
DEDENT
concept_member ::=
sub_concept
| has_property
| "one" "of" ":" NEWLINE
INDENT
enum_value+
DEDENT
sub_concept ::= "sub" type_ref ("," typeref)*
has_property ::= "has" Name ":" cardinality? type_ref NEWLINE
property ::=
"property" Name ":" cardinality? type_ref "->" cardinality? type_ref NEWLINE
rule ::=
"rule" Name ":" NEWLINE
INDENT
match_block
then_block
DEDENT
match_block ::=
"match" ":" NEWLINE
INDENT
match_pattern+
DEDENT
then_block ::=
"then" ":" NEWLINE
INDENT
then_item+
DEDENT
match_pattern ::=
subject qualified_name object NEWLINE
| subject qualified_name contraint_block NEWLINE
| subject "a" tyep_ref NEWLINE
| "among" ":" NEWLINE
INDENT
match_pattern+
DEDENT quantifier ":" NEWLINE
INDENT
match_pattern+
DEDENT
| quantifier ":" NEWLINE
INDENT
match_pattern+
DEDENT
quantifier ::=
"all"
| "none"
| "at least" Integer
| "at most" Integer
| "exactly" Integer
| "between" Integer "," Integer
then_item ::=
assertion NEWLINE
| nested_rule
assertion ::=
subject qualified_name object
| subject qualified_name no_comp_contraint_block
| subject "a" type_ref
nested_rule ::= match_block then_block
subject ::=
variable
| qualified_name
| contraint_block
object ::=
variable
| literal
| qualified_name
constraint_block ::= "[" constraint ("," contraint)+ ]
contraint ::=
"a" type_ref
| comparison_op literal
| qualified_name object
| qualified_name contraint_block
comparion_op ::=
"="
| "!="
| "<"
| "<="
| ">"
| ">="
type_ref ::=
"string"
| "int"
| "float"
| "boolean"
qualified_name ::=
cardinality ::=
"one"
| "any"
| "some"
| "optional"
| Integer
| Integer ".." Integer
| Integer ".." "*"