From f68da611e6801a41d3df7dba371b0fd522846de2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Szeremeta?= Date: Thu, 3 Sep 2020 01:25:34 +0200 Subject: [PATCH] OPTIONAL keyword and fix for NULL --- other-notations/YARSpg.ebnf | 10 +++++----- yarspg/YARSpg.g4 | 10 +++++----- yarspg/examples/test-example.yarspg | 14 ++++++++++++++ 3 files changed, 24 insertions(+), 10 deletions(-) diff --git a/other-notations/YARSpg.ebnf b/other-notations/YARSpg.ebnf index f674fb2..b5b9aca 100644 --- a/other-notations/YARSpg.ebnf +++ b/other-notations/YARSpg.ebnf @@ -119,8 +119,8 @@ prop_schema meta_prop_schema ::= '@' key ':' value_schema value_schema - ::= primitive_value_schema ( 'ID' | 'NULL' )? meta_prop_schema* - | complex_value_schema 'NULL'? + ::= primitive_value_schema ( 'ID' | 'NULL' )? 'OPTIONAL'? meta_prop_schema* + | complex_value_schema 'NULL'? 'OPTIONAL'? meta_prop_schema* primitive_value_schema ::= 'Decimal' | 'SmallInt' @@ -139,11 +139,11 @@ complex_value_schema | list_schema | struct_schema set_schema - ::= 'Set' '(' ( primitive_value_schema 'NULL'? | set_schema ) ')' meta_prop_schema* + ::= 'Set' '(' ( primitive_value_schema 'NULL'? 'OPTIONAL'? | set_schema ) ')' meta_prop_schema* list_schema - ::= 'List' '(' ( primitive_value_schema 'NULL'? | list_schema ) ')' meta_prop_schema* + ::= 'List' '(' ( primitive_value_schema 'NULL'? 'OPTIONAL'? | list_schema ) ')' meta_prop_schema* struct_schema - ::= 'Struct' '(' ( primitive_value_schema 'NULL'? | struct_schema ) ')' meta_prop_schema* + ::= 'Struct' '(' ( primitive_value_schema 'NULL'? 'OPTIONAL'? | struct_schema ) ')' meta_prop_schema* edge_schema ::= directed_schema | undirected_schema diff --git a/yarspg/YARSpg.g4 b/yarspg/YARSpg.g4 index 660da43..99adc5f 100644 --- a/yarspg/YARSpg.g4 +++ b/yarspg/YARSpg.g4 @@ -213,8 +213,8 @@ meta_prop_schema ; value_schema - : primitive_value_schema ('ID' | 'NULL')? meta_prop_schema* - | complex_value_schema 'NULL'? + : primitive_value_schema ('ID' | 'NULL')? 'OPTIONAL'? meta_prop_schema* + | complex_value_schema 'NULL'? 'OPTIONAL'? meta_prop_schema* ; primitive_value_schema @@ -243,15 +243,15 @@ complex_value_schema ; set_schema - : 'Set' '(' (primitive_value_schema 'NULL'? | set_schema) ')' meta_prop_schema* + : 'Set' '(' (primitive_value_schema 'NULL'? 'OPTIONAL'? | set_schema) ')' meta_prop_schema* ; list_schema - : 'List' '(' (primitive_value_schema 'NULL'? | list_schema) ')' meta_prop_schema* + : 'List' '(' (primitive_value_schema 'NULL'? 'OPTIONAL'? | list_schema) ')' meta_prop_schema* ; struct_schema - : 'Struct' '(' (primitive_value_schema 'NULL'? | struct_schema) ')' meta_prop_schema* + : 'Struct' '(' (primitive_value_schema 'NULL'? 'OPTIONAL'? | struct_schema) ')' meta_prop_schema* ; edge_schema diff --git a/yarspg/examples/test-example.yarspg b/yarspg/examples/test-example.yarspg index b8abd06..630150a 100644 --- a/yarspg/examples/test-example.yarspg +++ b/yarspg/examples/test-example.yarspg @@ -43,12 +43,14 @@ S(NS3 {"label333","c"}["value": String,"lang": String,"valid": Bool ID])/graph2/ 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(NS5 {"label546"}["key": Float]) +S(NS52 {"label546"}["key": Float OPTIONAL]) 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(NS7 {"label546"}["key": Float@"source": String]) +S(NS72 {"label546"}["key": Float@"source": String OPTIONAL]) (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: ] @@ -57,8 +59,10 @@ S(NS7 {"label546"}["key": Float@"source": String]) (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(NS8 {"label"}["keyword": Struct(String)]) +S(NS82 {"label"}["keyword": Struct(String) OPTIONAL]) (i {"label"}["keyword": {"name": "abc", "title": "xyz"}]) S(NS9 {"label"}["keyword": Struct(String)@"ok": Integer]) +S(NS92 {"label"}["keyword": Struct(String)@"ok": Integer OPTIONAL]) (i {"label"}["keyword": {"name": "abc"@"info": "ok", "title": "xyz"}@"ok": 1]) 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"}}]) @@ -75,18 +79,21 @@ S(NS14 {"3432f2"}["set": Set(Set(String))]) S(NS15 {"1ad32"}["list": List(String)]) (1dsc {"1ad32"}["list": ["name55", "name3"]]) S(NS16 {"1ad32"}["list": List(String NULL)]) +S(NS162 {"1ad32"}["list": List(String OPTIONAL)]) (1dsc {"1ad32"}["list": ["name55", null]]) S(NS17 {"1ad32"}["list": List(String) NULL]) (1dsc {"1ad32"}["list": null]) S(NS18 {"ad3"}["list": List(List(String))]) (ds {"ad3"}["list": [["name55", "name3"]]]) S(NS19 {"ad32"}["list": List(List(String))]) +S(NS192 {"ad32"}["list": List(List(String OPTIONAL)) OPTIONAL]) (dsc {"ad32"}["list": [["name55", "name3"], ["name11", "name2"]]]) S(NS20 {"ZYT"}["date": Date]) S(NS21 {"ZYT2"}["time": Time]) S(NS22 {"ZYT3"}["timezp": Time]) S(NS23 {"ZYT4"}["timezm": Time]) +S(NS232 {"ZYT4"}["timezm": Time OPTIONAL]) S(NS24 {"ZYT5"}["datetime": DateTime]) (ABC {"ZYT"}["date": 1999-01-01]) (ABC2 {"ZYT2"}["time": 11:15:32]) @@ -111,8 +118,13 @@ S(HAd34)-({"bbb23b"})-(sje2) (b43b)-({"bbb23b"})-(e) $var_234e_schema = "bbbd32d": Bool ID S(ABC43)-({"bbb23b"}["bbbd32d": Bool, "value": String NULL])-(JSk34) +S(ABC434)-({"bbb23b"}["bbbd32d": Bool, "value": String OPTIONAL])-(JSk342) S(ad234)-({"bbb23b"}[$var_234e_schema, "value": String NULL])-(gr525) S(asf32)-({"bbb23b"}["bbbd32d": Bool ID, "value": String NULL])-(wef32) +S(asf323)-({"bbb23b"}["bbbd32d": Bool ID, "value": List(String) NULL])-(wef323) +S(asf3233)-({"bbb23b"}["bbbd32d": Bool ID @"dfwe": Integer NULL, "value": List(String) NULL @"efe": List(List(String))])-(wef3234) +S(asf3245)-({"bbb23b"}["bbbd32d": Bool ID, "value": List(String) OPTIONAL])-(wef3245) +S(asf3244)-({"bbb23b"}["bbbd32d": Bool ID, "value": List(String) OPTIONAL @"psod": Struct(Integer) OPTIONAL])-(wef3245) (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"] @@ -120,7 +132,9 @@ 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(Adg35)-({"label4"}["timezm": Time OPTIONAL])->(saf244) S(wf23)-({"label5"}["datetime": DateTime])->(erg32) +S(wf2343)-({"label5"}["datetime": DateTime @"info": String])->(erg3264) S(sdaf56)-({"label5"}["datetime": DateTime ID])->(dsf53) S(sas34)-({"label6"}["datetimetzp": DateTime])->(sdag654) S(asdg41)-({"label7"}["datetimetzm": DateTime])->(asv94)