diff --git a/other-notations/YARSpg.ebnf b/other-notations/YARSpg.ebnf index fe8da8d..ce0a000 100644 --- a/other-notations/YARSpg.ebnf +++ b/other-notations/YARSpg.ebnf @@ -60,6 +60,8 @@ annotations_list ::= '+' annotation (',' annotation)* props_list ::= '[' prop (',' prop)* ']' +meta_prop + ::= '@' key ':' value graphs_list ::= '/' graph_name (',' graph_name)* '/' node @@ -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 @@ -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 id_key? +meta_prop_schema + ::= '@' key ':' value_schema value_schema - ::= primitive_value_schema ( 'ID' | 'NULL' )? + ::= primitive_value_schema ( 'ID' | 'NULL' )? meta_prop_schema* | complex_value_schema 'NULL'? primitive_value_schema ::= 'Decimal' @@ -122,11 +125,14 @@ complex_value_schema | list_schema | struct_schema set_schema - ::= 'Set' '(' ( primitive_value_schema 'NULL'? | set_schema ) ')' + ::= 'Set' '(' ( primitive_value_schema 'NULL'? | set_schema ) ')' meta_prop_schema* list_schema - ::= 'List' '(' ( primitive_value_schema 'NULL'? | list_schema ) ')' + ::= 'List' '(' ( primitive_value_schema 'NULL'? | list_schema ) ')' meta_prop_schema* struct_schema - ::= 'Struct' '(' ( primitive_value_schema 'NULL'? | struct_schema ) ')' + ::= 'Struct' '(' ( primitive_value_schema 'NULL'? | struct_schema ) ')' meta_prop_schema* +edge_schema + ::= directed_schema + | undirected_schema directed_schema ::= 'S' ('(' node_label ')')? '-' '{' edge_label '}' props_list_schema? '->' ('(' node_label ')')? undirected_schema diff --git a/yarspg/YARSpg.g4 b/yarspg/YARSpg.g4 index a55efd4..9bb98f5 100644 --- a/yarspg/YARSpg.g4 +++ b/yarspg/YARSpg.g4 @@ -81,6 +81,10 @@ props_list : '[' prop (',' prop)* ']' ; +meta_prop + : '@' key ':' value + ; + graphs_list : '/' graph_name (',' graph_name)* '/' ; @@ -115,7 +119,7 @@ node_label ; prop - : key ':' value + : key ':' value meta_prop* ; edge_id @@ -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 @@ -173,8 +177,12 @@ prop_schema : key ':' value_schema ; +meta_prop_schema + : '@' key ':' value_schema + ; + value_schema - : primitive_value_schema ('ID' | 'NULL')? + : primitive_value_schema ('ID' | 'NULL')? meta_prop_schema* | complex_value_schema 'NULL'? ; @@ -204,15 +212,15 @@ complex_value_schema ; set_schema - : 'Set' '(' (primitive_value_schema 'NULL'? | set_schema) ')' + : 'Set' '(' (primitive_value_schema 'NULL'? | set_schema) ')' meta_prop_schema* ; list_schema - : 'List' '(' (primitive_value_schema 'NULL'? | list_schema) ')' + : 'List' '(' (primitive_value_schema 'NULL'? | list_schema) ')' meta_prop_schema* ; struct_schema - : 'Struct' '(' (primitive_value_schema 'NULL'? | struct_schema) ')' + : 'Struct' '(' (primitive_value_schema 'NULL'? | struct_schema) ')' meta_prop_schema* ; edge_schema diff --git a/yarspg/examples/test-example.yarspg b/yarspg/examples/test-example.yarspg index 31da406..0cb60c1 100644 --- a/yarspg/examples/test-example.yarspg +++ b/yarspg/examples/test-example.yarspg @@ -26,17 +26,26 @@ S{"label333","c"}["value": String ID,"lang": String,"valid": Bool]/"graph2"/+{"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: <"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))] @@ -70,12 +79,14 @@ S{"ZYT5"}["datetime": DateTime] S("a1d")-{"aaa1a"}["key": String, "aab2bc": List(Integer)]->("label333") S("a1d")-{"aaa1a"}["key": String ID, "aab2bc": List(Integer)]->("label333") ("a")-<"ferf">{"aaa1a"}["key": "value", "aab2bc": [44, 22]]->("c")+: +("a")-<"ferf">{"aaa1a"}["key": "value"@"ok": "no", "aab2bc": [44, 22]@"list name": "alph"]->("c")+: ("a")-<"id341">{"aaa2a"}->("c") S("label1")-{"bbb23b"}-("ef22") ("b43b")-{"bbb23b"}-("e") S("label1")-{"bbb23b"}["bbbd32d": Bool, "value": String NULL]-("ef22") S("label1")-{"bbb23b"}["bbbd32d": Bool ID, "value": String NULL]-("ef22") ("b43b")-{"bbbb53b"}["bbbd32d": false, "value": null]-("e")+foaf:maker: "Łukasz Szeremeta and Dominik Tomaszuk", : "Test annotation" +("b43b")-{"bbbb53b"}["bbbd32d": false, "value": null@"psod": {"dff": 1, "ewf": 55}]-("e")+foaf:maker: "Łukasz Szeremeta and Dominik Tomaszuk", : "Test annotation" S("A")-{"label"}["date": Date]->("Z") S("A2")-{"label2"}["time": Time]->("Z2")