Skip to content

Commit

Permalink
Add meta properties
Browse files Browse the repository at this point in the history
  • Loading branch information
lszeremeta committed Aug 1, 2020
1 parent 0a55b07 commit 74aea07
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 17 deletions.
21 changes: 12 additions & 9 deletions other-notations/YARSpg.ebnf
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ annotations_list
::= '+' annotation (',' annotation)*
props_list
::= '[' prop (',' prop)* ']'
meta_prop
::= '@' key ':' value
graphs_list
::= '/' graph_name (',' graph_name)* '/'
node
Expand All @@ -74,8 +76,7 @@ undirected
node_id ::= STRING
node_label
::= STRING
prop
::= key ':' value
prop ::= key ':' value meta_prop*
edge_id ::= STRING
edge_label
::= STRING
Expand All @@ -92,17 +93,19 @@ complex_value
::= set
| list
| struct
set ::= '{' (primitive_value | set) (',' (primitive_value | set))* '}'
list ::= '[' (primitive_value | list) (',' (primitive_value | list))* ']'
struct ::= '{' key ':' (primitive_value | struct) (',' key ':' (primitive_value | struct))* '}'
set ::= '{' ( primitive_value | set ) meta_prop* ( ',' ( primitive_value | set ) meta_prop* )* '}'
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)* ']'
prop_schema
::= key ':' value_schema
meta_prop_schema
::= '@' key ':' value_schema
value_schema
::= primitive_value_schema
::= primitive_value_schema meta_prop_schema*
| complex_value_schema
primitive_value_schema
::= 'Decimal'
Expand All @@ -123,11 +126,11 @@ complex_value_schema
| list_schema
| struct_schema
set_schema
::= 'Set' '(' (primitive_value_schema | set_schema) ')'
::= 'Set' '(' ( primitive_value_schema | set_schema ) ')' meta_prop_schema*
list_schema
::= 'List' '(' (primitive_value_schema | list_schema) ')'
::= 'List' '(' ( primitive_value_schema | list_schema ) ')' meta_prop_schema*
struct_schema
::= 'Struct' '(' (primitive_value_schema | struct_schema) ')'
::= 'Struct' '(' ( primitive_value_schema | struct_schema ) ')' meta_prop_schema*
edge_schema
::= directed_schema
| undirected_schema
Expand Down
24 changes: 16 additions & 8 deletions yarspg/YARSpg.g4
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ props_list
: '[' prop (',' prop)* ']'
;

meta_prop
: '@' key ':' value
;

graphs_list
: '/' graph_name (',' graph_name)* '/'
;
Expand Down Expand Up @@ -115,7 +119,7 @@ node_label
;

prop
: key ':' value
: key ':' value meta_prop*
;

edge_id
Expand Down Expand Up @@ -150,15 +154,15 @@ complex_value
;

set
: '{' (primitive_value | set) (',' (primitive_value | set))* '}'
: '{' (primitive_value | set) meta_prop* (',' (primitive_value | set) meta_prop*)* '}'
;

list
: '[' (primitive_value | list) (',' (primitive_value | list))* ']'
: '[' (primitive_value | list) meta_prop* (',' (primitive_value | list) meta_prop*)* ']'
;

struct
: '{' key ':' (primitive_value | struct) (',' key ':' (primitive_value | struct))* '}'
: '{' key ':' (primitive_value | struct) meta_prop* (',' key ':' (primitive_value | struct) meta_prop*)* '}'
;

node_schema
Expand All @@ -173,8 +177,12 @@ prop_schema
: key ':' value_schema
;

meta_prop_schema
: '@' key ':' value_schema
;

value_schema
: primitive_value_schema
: primitive_value_schema meta_prop_schema*
| complex_value_schema
;

Expand Down Expand Up @@ -205,15 +213,15 @@ complex_value_schema
;

set_schema
: 'Set' '(' (primitive_value_schema | set_schema) ')'
: 'Set' '(' (primitive_value_schema | set_schema) ')' meta_prop_schema*
;

list_schema
: 'List' '(' (primitive_value_schema | list_schema) ')'
: 'List' '(' (primitive_value_schema | list_schema) ')' meta_prop_schema*
;

struct_schema
: 'Struct' '(' (primitive_value_schema | struct_schema) ')'
: 'Struct' '(' (primitive_value_schema | struct_schema) ')' meta_prop_schema*
;

edge_schema
Expand Down
11 changes: 11 additions & 0 deletions yarspg/examples/test-example.yarspg
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,26 @@ S{"label333","c"}["value": String,"lang": String,"valid": Bool]/"graph2"/+<http:
<"c">{"label333","c"}["value":"male","lang":"en","valid":false]/"graph2", "graph3"/+<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{"label546"}["key": Float]
<"d">{"label546"}["key":442.1333]
S{"label546"}["key": Float@"source": String]
<"d">{"label546"}["key":442.1333@"source": "XZYNews"]
<"e">{"ef22","y","v"}["key44":[true,false,"some text", null, 11, 11.2231]]
<"f">["node":"node without label"]+foaf:maker: <http://example.com/me>
<"g">{"df2","z","q"}["key664":[false,["another list", 52, 44.1]]]+"abc": "value33"
<"h">{"label"}["key664":[false,["another list2", ["another list3", 54, false, true] , 52, 44.1]]]
<"h">{"label"}["key664":[false,["another list2"@"info": {"source": "ABC", "trust": "XYZ"}, ["another list3", 54, false, true] , 52, 44.1]]]
<"h">{"label"}["key664":[false,["another list2"@"info": {"source": "ABC", "trust": "XYZ"}, ["another list3", 54, false, true]@"access": [0, 1, 1, 0] @"ok": true, 52, 44.1]@"good": false]]
S{"label"}["keyword": Struct(String)]
<"i">{"label"}["keyword": {"name": "abc", "title": "xyz"}]
S{"label"}["keyword": Struct(String)@"ok": Integer]
<"i">{"label"}["keyword": {"name": "abc"@"info": "ok", "title": "xyz"}@"ok": 1]
S{"2label4"}["keyword2": Struct(Struct(String))]
<"2i44">{"2label4"}["keyword2": {"names": {"name": "abc", "title": "xyz"}, "names2": {"name2": "abc2", "title2": "xyz2"}, "names3": {"name3": "abc3", "title3": "xyz3"}}]
S{"2label4"}["keyword2": Struct(Struct(String)@"struct": String)@"struct": String @"ok": Bool]
<"2i44">{"2label4"}["keyword2": {"names": {"name": "abc", "title": "xyz"}@"rating": 5, "names2": {"name2": "abc2"@"more": "ok", "title2": "xyz2"}, "names3": {"name3": "abc3", "title3": "xyz3"}@"struct": "inside"}@"struct": "outside" @"ok": true]
<"i2">{"label"}["keyword": {"name": "abc", "title": {"name2": "abc2", "title2": "xyz2"}}]
S{"432f"}["set": Set(String)]/"graphname"/
<"z">{"432f"}["set": {"name", "title"}]/"graphname"/
<"z">{"432f"}["set": {"name", "title"}@"test":"test3"]/"graphname"/
S{"432f2"}["set": Set(Set(String))]
<"z2">{"432f2"}["set": {{"set2", "title"}}]
S{"3432f2"}["set": Set(Set(String))]
Expand Down Expand Up @@ -62,11 +71,13 @@ S{"ZYT5"}["datetime": DateTime]
% EDGE SCHEMAS
S("a1d")-{"aaa1a"}["key": String, "aab2bc": List(Integer)]->("label333")
("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")
S("label1")-{"bbb23b"}-("ef22")
("b43b")-{"bbb23b"}-("e")
S("label1")-{"bbb23b"}["bbbd32d": Bool, "value": Null]-("ef22")
("b43b")-{"bbbb53b"}["bbbd32d": false, "value": null]-("e")+foaf:maker: "Łukasz Szeremeta and Dominik Tomaszuk", <http://xmlns.com/dc/0.5/zyz>: "Test annotation"
("b43b")-{"bbbb53b"}["bbbd32d": false, "value": null@"psod": {"dff": 1, "ewf": 55}]-("e")+foaf:maker: "Łukasz Szeremeta and Dominik Tomaszuk", <http://xmlns.com/dc/0.5/zyz>: "Test annotation"

S("A")-{"label"}["date": Date]->("Z")
S("A2")-{"label2"}["time": Time]->("Z2")
Expand Down

0 comments on commit 74aea07

Please sign in to comment.