Skip to content

Commit

Permalink
More flexibility in empty labels or properties
Browse files Browse the repository at this point in the history
> Examples <

Node without labels:
Option 1: <id>{}[...]
Option 2: <id>[...]

Node without properties:
Option 1: <id>{...}[]
Option 2: <id>{}

Similar in edges and node/edge schamas
  • Loading branch information
lszeremeta committed Aug 17, 2020
1 parent eb2bdbc commit 9b36a83
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 18 deletions.
19 changes: 9 additions & 10 deletions other-notations/YARSpg.ebnf
Original file line number Diff line number Diff line change
Expand Up @@ -59,20 +59,20 @@ rdf_annotation
annotations_list
::= '+' '[' annotation (',' annotation)* ']'
props_list
::= '[' prop (',' prop)* ']'
::= ( '[' ( prop (',' prop)* )? ']' )?
meta_prop
::= '@' key ':' value
graphs_list
::= '/' graph_name (',' graph_name)* '/'
node
::= '<' node_id '>' ('{' node_label (',' node_label)* '}')? props_list? graphs_list? annotations_list?
::= '<' node_id '>' ( '{' ( node_label ( ',' node_label )* )? '}' )? props_list graphs_list? annotations_list?
edge
::= directed
| undirected
section ::= '%' SECTION_NAME
directed ::= '(' node_id ')' '-' ('<' edge_id '>')? '{' edge_label '}' props_list? '->' '(' node_id ')' graphs_list? annotations_list?
directed ::= '(' node_id ')' '-' ( '<' edge_id '>' )? ( '{' ( edge_label ( ',' edge_label )* )? '}' )? props_list '->' '(' node_id ')' graphs_list? annotations_list?
undirected
::= '(' node_id ')' '-' ('<' edge_id '>')? '{' edge_label '}' props_list? '-' '(' node_id ')' graphs_list? annotations_list?
::= '(' node_id ')' '-' ( '<' edge_id '>' )? ( '{' ( edge_label ( ',' edge_label )* )? '}' )? props_list '-' '(' node_id ')' graphs_list? annotations_list?
node_id ::= STRING
node_label
::= STRING
Expand All @@ -97,9 +97,9 @@ set ::= '{' ( primitive_value | set ) meta_prop* ( ',' ( primitive_value |
list ::= '[' ( primitive_value | list ) meta_prop* ( ',' ( primitive_value | list ) meta_prop* )* ']'
struct ::= '{' key ':' ( primitive_value | struct ) meta_prop* ( ',' key ':' ( primitive_value | struct ) meta_prop* )* '}'
node_schema
::= 'S' ('{' node_label (',' node_label)* '}')? props_list_schema? graphs_list? annotations_list?
props_list_schema
::= '[' prop_schema (',' prop_schema)* ']'
::= 'S' ( '{' ( node_label ( ',' node_label )* )? '}' )? prop_list_schema graphs_list? annotations_list?
prop_list_schema
::= ( '[' ( prop_schema ( ',' prop_schema )* )? ']' )?
prop_schema
::= key ':' value_schema id_key?
meta_prop_schema
Expand Down Expand Up @@ -134,10 +134,9 @@ edge_schema
::= directed_schema
| undirected_schema
directed_schema
::= 'S' ('(' node_label ')')? '-' '{' edge_label '}' props_list_schema? '->' ('(' node_label ')')?
::= 'S' '(' node_label ')' '-' ( '{' ( edge_label ( ',' edge_label )* )? '}' )? prop_list_schema '->' '(' node_label ')'
undirected_schema
::= 'S' ('(' node_label ')')? '-' '{' edge_label '}' props_list_schema? '-' ('(' node_label ')')?

::= 'S' '(' node_label ')' '-' ( '{' ( edge_label ( ',' edge_label )* )? '}' )? prop_list_schema '-' '(' node_label ')'
SECTION_NAME
::= 'METADATA'
| 'NODE SCHEMAS'
Expand Down
16 changes: 8 additions & 8 deletions yarspg/YARSpg.g4
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ annotations_list
;

props_list
: '[' prop (',' prop)* ']'
: ( '[' ( prop (',' prop)* )? ']' )?
;

meta_prop
Expand All @@ -90,7 +90,7 @@ graphs_list
;

node
: '<' node_id '>' ('{' node_label (',' node_label)* '}')? props_list? graphs_list? annotations_list?
: '<' node_id '>' ( '{' ( node_label ( ',' node_label )* )? '}' )? props_list graphs_list? annotations_list?
;

edge
Expand All @@ -103,11 +103,11 @@ section
;

directed
: '(' node_id ')' '-' ('<' edge_id '>')? '{' edge_label '}' props_list? '->' '(' node_id ')' graphs_list? annotations_list?
: '(' node_id ')' '-' ('<' edge_id '>')? ( '{' ( edge_label ( ',' edge_label )* )? '}' )? props_list '->' '(' node_id ')' graphs_list? annotations_list?
;

undirected
: '(' node_id ')' '-' ('<' edge_id '>')? '{' edge_label '}' props_list? '-' '(' node_id ')' graphs_list? annotations_list?
: '(' node_id ')' '-' ('<' edge_id '>')? ( '{' ( edge_label ( ',' edge_label )* )? '}' )? props_list '-' '(' node_id ')' graphs_list? annotations_list?
;

node_id
Expand Down Expand Up @@ -166,11 +166,11 @@ struct
;

node_schema
: 'S' '{' node_label (',' node_label)* '}' prop_list_schema? graphs_list? annotations_list?
: 'S' ( '{' ( node_label ( ',' node_label )* )? '}' )? prop_list_schema graphs_list? annotations_list?
;

prop_list_schema
: '[' prop_schema (',' prop_schema)* ']'
: ( '[' ( prop_schema (',' prop_schema)* )? ']' )?
;

prop_schema
Expand Down Expand Up @@ -229,11 +229,11 @@ edge_schema
;

directed_schema
: 'S' '(' node_label ')' '-' '{' edge_label '}' prop_list_schema? '->' '(' node_label ')'
: 'S' '(' node_label ')' '-' ( '{' ( edge_label ( ',' edge_label )* )? '}' )? prop_list_schema '->' '(' node_label ')'
;

undirected_schema
: 'S' '(' node_label ')' '-' '{' edge_label '}' prop_list_schema? '-' '(' node_label ')'
: 'S' '(' node_label ')' '-' ( '{' ( edge_label ( ',' edge_label )* )? '}' )? prop_list_schema '-' '(' node_label ')'
;

SECTION_NAME
Expand Down
4 changes: 4 additions & 0 deletions yarspg/examples/test-example.yarspg
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
% NODES
% NODE SCHEMAS
<"a">{"a1d","x"}["aa1a":true,"a2aa":"text","aa3aa":null]+[foaf:maker: "Łukasz Szeremeta and Dominik Tomaszuk", <http://xmlns.com/dc/0.5/zyz>: "Test annotation"]
<"b43b">{}[]+[foaf:maker: "Łukasz Szeremeta and Dominik Tomaszuk"] #b43b
<"b43b">{"label1"}["value":5]+[foaf:maker: "Łukasz Szeremeta and Dominik Tomaszuk"] #b43b
S{}[]/"graph2"/
S{"label333","c"}["value": String,"lang": String,"valid": Bool]/"graph2"/+[<http://xmlns.com/dc/0.5/zyz>: <http://xmlns.com/dc/0.5/qtv>, foaf:maker: "Łukasz Szeremeta and Dominik Tomaszuk", <http://xmlns.com/dc/0.5/zyz>: "Test annotation", "cdf": "fgh", foaf:maker: <http://example.com/me>]
S{"label333","c"}["value": String,"lang": String,"valid": Bool ID]/"graph2"/+[<http://xmlns.com/dc/0.5/zyz>: <http://xmlns.com/dc/0.5/qtv>, foaf:maker: "Łukasz Szeremeta and Dominik Tomaszuk", <http://xmlns.com/dc/0.5/zyz>: "Test annotation", "cdf": "fgh", foaf:maker: <http://example.com/me>]
S{"label333","c"}["value": String ID,"lang": String,"valid": Bool]/"graph2"/+[<http://xmlns.com/dc/0.5/zyz>: <http://xmlns.com/dc/0.5/qtv>, foaf:maker: "Łukasz Szeremeta and Dominik Tomaszuk", <http://xmlns.com/dc/0.5/zyz>: "Test annotation", "cdf": "fgh", foaf:maker: <http://example.com/me>]
Expand Down Expand Up @@ -76,8 +78,10 @@ S{"ZYT5"}["datetime": DateTime]

% EDGES
% EDGE SCHEMAS
S("a1d")-{}[]->("label333")
S("a1d")-{"aaa1a"}["key": String, "aab2bc": List(Integer)]->("label333")
S("a1d")-{"aaa1a"}["key": String ID, "aab2bc": List(Integer)]->("label333")
("a")-<"ferf">{}[]->("c")
("a")-<"ferf">{"aaa1a"}["key": "value", "aab2bc": [44, 22]]->("c")+[<http://xmlns.com/dc/0.5/zyz>: <http://xmlns.com/dc/0.5/qtv>]
("a")-<"ferf">{"aaa1a"}["key": "value"@"ok": "no", "aab2bc": [44, 22]@"list name": "alph"]->("c")+[<http://xmlns.com/dc/0.5/zyz>: <http://xmlns.com/dc/0.5/qtv>]
("a")-<"id341">{"aaa2a"}->("c")
Expand Down

0 comments on commit 9b36a83

Please sign in to comment.