From 4e5a03438e1ebb48f9ab63b8ec02ef333aa57ef3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Szeremeta?= Date: Tue, 1 Sep 2020 17:56:21 +0200 Subject: [PATCH] Add node_id_schema --- other-notations/YARSpg.ebnf | 6 +- yarspg/YARSpg.g4 | 10 ++- yarspg/examples/canonical-real-example.yarspg | 18 ++--- yarspg/examples/real-example.yarspg | 18 ++--- yarspg/examples/test-example.yarspg | 78 +++++++++---------- 5 files changed, 67 insertions(+), 63 deletions(-) diff --git a/other-notations/YARSpg.ebnf b/other-notations/YARSpg.ebnf index 8d3e2e0..f674fb2 100644 --- a/other-notations/YARSpg.ebnf +++ b/other-notations/YARSpg.ebnf @@ -109,7 +109,7 @@ 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 )* )? '}' )? prop_list_schema? ')' graphs_list? local_metadata_list? + ::= 'S' '(' node_id_schema ( '{' ( node_label ( ',' node_label )* )? '}' )? prop_list_schema? ')' graphs_list? local_metadata_list? node_id_schema ::= ALNUM_PLUS prop_list_schema @@ -148,9 +148,9 @@ edge_schema ::= directed_schema | undirected_schema directed_schema - ::= 'S' '(' node_label ')' '-' '(' ( '{' ( edge_label ( ',' edge_label )* )? '}' )? prop_list_schema? ')' '->' '(' node_label ')' + ::= 'S' '(' node_id_schema ')' '-' '(' ( '{' ( edge_label ( ',' edge_label )* )? '}' )? prop_list_schema? ')' '->' '(' node_id_schema ')' undirected_schema - ::= 'S' '(' node_label ')' '-' '(' ( '{' ( edge_label ( ',' edge_label )* )? '}' )? prop_list_schema? ')' '-' '(' node_label ')' + ::= 'S' '(' node_id_schema ')' '-' '(' ( '{' ( edge_label ( ',' edge_label )* )? '}' )? prop_list_schema? ')' '-' '(' node_id_schema1 ')' SECTION_NAME ::= 'GRAPH' | 'METADATA' diff --git a/yarspg/YARSpg.g4 b/yarspg/YARSpg.g4 index ddfc125..660da43 100644 --- a/yarspg/YARSpg.g4 +++ b/yarspg/YARSpg.g4 @@ -193,7 +193,11 @@ struct ; node_schema - : 'S' '(' ( '{' ( node_label ( ',' node_label )* )? '}' )? prop_list_schema? ')' graphs_list? local_metadata_list? + : 'S' '(' node_id_schema ( '{' ( node_label ( ',' node_label )* )? '}' )? prop_list_schema? ')' graphs_list? local_metadata_list? + ; + +node_id_schema + : ALNUM_PLUS ; prop_list_schema @@ -256,11 +260,11 @@ edge_schema ; directed_schema - : 'S' '(' node_label ')' '-' '(' ( '{' ( edge_label ( ',' edge_label )* )? '}' )? prop_list_schema? ')' '->' '(' node_label ')' + : 'S' '(' node_id_schema ')' '-' '(' ( '{' ( edge_label ( ',' edge_label )* )? '}' )? prop_list_schema? ')' '->' '(' node_id_schema ')' ; undirected_schema - : 'S' '(' node_label ')' '-' '(' ( '{' ( edge_label ( ',' edge_label )* )? '}' )? prop_list_schema? ')' '-' '(' node_label ')' + : 'S' '(' node_id_schema ')' '-' '(' ( '{' ( edge_label ( ',' edge_label )* )? '}' )? prop_list_schema? ')' '-' '(' node_id_schema ')' ; SECTION_NAME diff --git a/yarspg/examples/canonical-real-example.yarspg b/yarspg/examples/canonical-real-example.yarspg index 1082825..fe547bd 100644 --- a/yarspg/examples/canonical-real-example.yarspg +++ b/yarspg/examples/canonical-real-example.yarspg @@ -1,16 +1,16 @@ %METADATA -:"Łukasz Szeremeta and Dominik Tomaszuk" %NODE SCHEMAS -S({"Author"}["fname":String,"lname":String]) -S({"Entry","InProceedings"}["title":String,"numpages":Integer,"keyword":String]) -S({"Entry","Article"}["title":String,"numpages":Integer,"keyword":List(String)]) -S({"Proceedings"}["title":String,"year":Integer,"month":String]) -S({"Journal"}["title":String,"year":Integer,"vol":Integer]) +S(NS1{"Author"}["fname":String,"lname":String]) +S(NS2{"Entry","InProceedings"}["title":String,"numpages":Integer,"keyword":String]) +S(NS3{"Entry","Article"}["title":String,"numpages":Integer,"keyword":List(String)]) +S(NS4{"Proceedings"}["title":String,"year":Integer,"month":String]) +S(NS5{"Journal"}["title":String,"year":Integer,"vol":Integer]) %EDGE SCHEMAS -S("Entry")-({"has_author"}["order":Integer])->("Author") -S("Entry")-({"cities"})->("Entry") -S("InProceedings")-({"booktitle"}["pages":String])->("Proceedings") -S("Article")-({"published_in"}["pages":String])->("Journal") +S(NS2)-({"has_author"}["order":Integer])->(NS1) +S(NS3)-({"cities"})->(NS2) +S(NS2)-({"booktitle"}["pages":String])->(NS4) +S(NS3)-({"published_in"}["pages":String])->(NS5) %NODES (Author01{"Author"}["fname":"John","lname":"Smith"])#Author01 (Author02{"Author"}["fname":"Alice","lname":"Brown"]) diff --git a/yarspg/examples/real-example.yarspg b/yarspg/examples/real-example.yarspg index ef7bab3..d14e0e2 100644 --- a/yarspg/examples/real-example.yarspg +++ b/yarspg/examples/real-example.yarspg @@ -5,17 +5,17 @@ -foaf:maker: "Łukasz Szeremeta and Dominik Tomaszuk" # Node schema -S({"Author"}["fname": String, "lname": String]) -S({"Entry", "InProceedings"}["title": String, "numpages": Integer, "keyword": String]) -S({"Entry", "Article"}["title": String, "numpages": Integer, "keyword": List(String)]) -S({"Proceedings"}["title": String, "year": Integer, "month": String]) -S({"Journal"}["title": String, "year": Integer, "vol": Integer]) +S(NS1 {"Author"}["fname": String, "lname": String]) +S(NS2 {"Entry", "InProceedings"}["title": String, "numpages": Integer, "keyword": String]) +S(NS3 {"Entry", "Article"}["title": String, "numpages": Integer, "keyword": List(String)]) +S(NS4 {"Proceedings"}["title": String, "year": Integer, "month": String]) +S(NS5 {"Journal"}["title": String, "year": Integer, "vol": Integer]) # Edge schema -S("Entry")-({"has_author"}["order": Integer])->("Author") -S("Entry")-({"cities"})->("Entry") -S("InProceedings")-({"booktitle"}["pages": String])->("Proceedings") -S("Article")-({"published_in"}["pages": String])->("Journal") +S(NS2)-({"has_author"}["order": Integer])->(NS1) +S(NS3)-({"cities"})->(NS2) +S(NS2)-({"booktitle"}["pages": String])->(NS4) +S(NS3)-({"published_in"}["pages": String])->(NS5) # Nodes (Author01 {"Author"}["fname": "John", "lname": "Smith"]) #Author01 diff --git a/yarspg/examples/test-example.yarspg b/yarspg/examples/test-example.yarspg index e2debdb..b8abd06 100644 --- a/yarspg/examples/test-example.yarspg +++ b/yarspg/examples/test-example.yarspg @@ -36,19 +36,19 @@ $var44 = "aa1a":true,"a2aa":"text" (a {"a1d","x"}["aa1a":true,"a2aa":"text","aa3aa":null])+[foaf:maker: "Łukasz Szeremeta and Dominik Tomaszuk", : "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(NS1 {}[])/graph2/ $var44_schema = "value": String,"lang": String -S({"label333","c"}[$var44_schema,"valid": Bool])/graph2/+[: , foaf:maker: "Łukasz Szeremeta and Dominik Tomaszuk", : "Test annotation", "cdf": "fgh", foaf:maker: ] -S({"label333","c"}["value": String,"lang": String,"valid": Bool ID])/graph2/+[: , foaf:maker: "Łukasz Szeremeta and Dominik Tomaszuk", : "Test annotation", "cdf": "fgh", foaf:maker: ] -S({"label333","c"}["value": String ID,"lang": String,"valid": Bool])/graph2/+[: , foaf:maker: "Łukasz Szeremeta and Dominik Tomaszuk", : "Test annotation", "cdf": "fgh", foaf:maker: ] +S(NS2 {"label333","c"}[$var44_schema,"valid": Bool])/graph2/+[: , foaf:maker: "Łukasz Szeremeta and Dominik Tomaszuk", : "Test annotation", "cdf": "fgh", foaf:maker: ] +S(NS3 {"label333","c"}["value": String,"lang": String,"valid": Bool ID])/graph2/+[: , foaf:maker: "Łukasz Szeremeta and Dominik Tomaszuk", : "Test annotation", "cdf": "fgh", foaf:maker: ] +S(NS4 {"label333","c"}["value": String ID,"lang": String,"valid": Bool])/graph2/+[: , foaf:maker: "Łukasz Szeremeta and Dominik Tomaszuk", : "Test annotation", "cdf": "fgh", foaf:maker: ] (c {"label333","c"}["value":"male","lang":"en","valid":false])/graph2, graph3/+[: , foaf:maker: "Łukasz Szeremeta and Dominik Tomaszuk", : "Test annotation", "cdf": "fgh", foaf:maker: ] -S({"label546"}["key": Float]) -S({"label546"}["key": Float ID]) +S(NS5 {"label546"}["key": Float]) +S(NS6 {"label546"}["key": Float ID]) (d {"label546"}["key":.1333]) (d {"label546"}["key":.1333e+5]) (d {"label546"}["key":1333E-2]) (d {"label546"}["key":442.1333]) -S({"label546"}["key": Float@"source": String]) +S(NS7 {"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: ] @@ -56,38 +56,38 @@ S({"label546"}["key": Float@"source": String]) (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)]) +S(NS8 {"label"}["keyword": Struct(String)]) (i {"label"}["keyword": {"name": "abc", "title": "xyz"}]) -S({"label"}["keyword": Struct(String)@"ok": Integer]) +S(NS9 {"label"}["keyword": Struct(String)@"ok": Integer]) (i {"label"}["keyword": {"name": "abc"@"info": "ok", "title": "xyz"}@"ok": 1]) -S({"2label4"}["keyword2": Struct(Struct(String))]) +S(NS10 {"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]) +S(NS11 {"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/ +S(NS12 {"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))]) +S(NS13 {"432f2"}["set": Set(Set(String))]) (z2 {"432f2"}["set": {{"set2", "title"}}]) -S({"3432f2"}["set": Set(Set(String))]) +S(NS14 {"3432f2"}["set": Set(Set(String))]) (3z2 {"3432f2"}["set": {{"set2", "title"}, {"set3", "title3"}}]) -S({"1ad32"}["list": List(String)]) +S(NS15 {"1ad32"}["list": List(String)]) (1dsc {"1ad32"}["list": ["name55", "name3"]]) -S({"1ad32"}["list": List(String NULL)]) +S(NS16 {"1ad32"}["list": List(String NULL)]) (1dsc {"1ad32"}["list": ["name55", null]]) -S({"1ad32"}["list": List(String) NULL]) +S(NS17 {"1ad32"}["list": List(String) NULL]) (1dsc {"1ad32"}["list": null]) -S({"ad3"}["list": List(List(String))]) +S(NS18 {"ad3"}["list": List(List(String))]) (ds {"ad3"}["list": [["name55", "name3"]]]) -S({"ad32"}["list": List(List(String))]) +S(NS19 {"ad32"}["list": List(List(String))]) (dsc {"ad32"}["list": [["name55", "name3"], ["name11", "name2"]]]) -S({"ZYT"}["date": Date]) -S({"ZYT2"}["time": Time]) -S({"ZYT3"}["timezp": Time]) -S({"ZYT4"}["timezm": Time]) -S({"ZYT5"}["datetime": DateTime]) +S(NS20 {"ZYT"}["date": Date]) +S(NS21 {"ZYT2"}["time": Time]) +S(NS22 {"ZYT3"}["timezp": Time]) +S(NS23 {"ZYT4"}["timezm": Time]) +S(NS24 {"ZYT5"}["datetime": DateTime]) (ABC {"ZYT"}["date": 1999-01-01]) (ABC2 {"ZYT2"}["time": 11:15:32]) (ABC3 {"ZYT3"}["timezp": 11:15:32+01:30]) @@ -98,32 +98,32 @@ 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") +S(A01)-({}[])->(A02) +S(A01)-({"aaa1a"}["key": String, "aab2bc": List(Integer)])->(A02) +S(A01)-({"aaa1a"}["key": String ID, "aab2bc": List(Integer)])->(A02) (a)-(ferf {}[])->(c) (a)-(ferf {"aaa1a"}["key": "value", "aab2bc": [44, 22]])->(c)+[: ] $var_e344 = "aab2bc": [44, 22]@"list name": "alph" (a)-(ferf {"aaa1a"}["key": "value"@"ok": "no", $var_e344])->(c)+[: ] (a)-(ferf {"aaa1a"}["key": "value"@"ok": "no", "aab2bc": [44, 22]@"list name": "alph"])->(c)+[: ] (a)-(id341 {"aaa2a"})->(c) -S("label1")-({"bbb23b"})-("ef22") +S(HAd34)-({"bbb23b"})-(sje2) (b43b)-({"bbb23b"})-(e) $var_234e_schema = "bbbd32d": Bool ID -S("label1")-({"bbb23b"}["bbbd32d": Bool, "value": String NULL])-("ef22") -S("label1")-({"bbb23b"}[$var_234e_schema, "value": String NULL])-("ef22") -S("label1")-({"bbb23b"}["bbbd32d": Bool ID, "value": String NULL])-("ef22") +S(ABC43)-({"bbb23b"}["bbbd32d": Bool, "value": String NULL])-(JSk34) +S(ad234)-({"bbb23b"}[$var_234e_schema, "value": String NULL])-(gr525) +S(asf32)-({"bbb23b"}["bbbd32d": Bool ID, "value": String NULL])-(wef32) (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") -S("A3")-({"label3"}["timezp": Time])->("Z3") -S("A4")-({"label4"}["timezm": Time])->("Z4") -S("A5")-({"label5"}["datetime": DateTime])->("Z5") -S("A5")-({"label5"}["datetime": DateTime ID])->("Z5") -S("A6")-({"label6"}["datetimetzp": DateTime])->("Z6") -S("A7")-({"label7"}["datetimetzm": DateTime])->("Z7") +S(f23)-({"label"}["date": Date])->(f321) +S(g34g2)-({"label2"}["time": Time])->(fwef334) +S(weg12)-({"label3"}["timezp": Time])->(gerg534) +S(Adg3)-({"label4"}["timezm": Time])->(saf24) +S(wf23)-({"label5"}["datetime": DateTime])->(erg32) +S(sdaf56)-({"label5"}["datetime": DateTime ID])->(dsf53) +S(sas34)-({"label6"}["datetimetzp": DateTime])->(sdag654) +S(asdg41)-({"label7"}["datetimetzm": DateTime])->(asv94) (ABC)-({"label"}["date": 1999-01-01])->(XYZ) (ABC2)-({"label2"}["time": 11:15:32])->(XYZ2) (ABC3)-({"label3"}["timezp": 11:15:32+01:30])->(XYZ3)