Skip to content

Commit

Permalink
Better syntax for metaproperties
Browse files Browse the repository at this point in the history
  • Loading branch information
lszeremeta committed Nov 29, 2021
1 parent dbf16eb commit fd2fa10
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 51 deletions.
22 changes: 11 additions & 11 deletions other-notations/YARSpg.ebnf
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ graph_id
prop_list
::= ( '[' ( ( prop | variable ) ( ',' ( prop | variable ) )* )? ']' )?
meta_prop
::= '@' key ':' value
::= '@' '<' ( key ':' value ( ',' key ':' value )* )? '>'
graphs_list
::= '/' graph_id (',' graph_id)* '/'
graph ::= '/' graph_id '/' ( '{' ( graph_label ( ',' graph_label )* )? '}' )? prop_list?
Expand All @@ -74,7 +74,7 @@ undirected
node_id ::= ID
node_label
::= STRING
prop ::= key ':' value meta_prop*
prop ::= key ':' value meta_prop?
edge_id ::= ID
edge_label
::= STRING
Expand All @@ -89,9 +89,9 @@ complex_value
::= set_value
| list_value
| struct_value
set_value ::= '{' ( primitive_value | set_value ) meta_prop* ( ',' ( primitive_value | set_value ) meta_prop* )* '}'
list_value ::= '[' ( primitive_value | list_value ) meta_prop* ( ',' ( primitive_value | list_value ) meta_prop* )* ']'
struct_value ::= '{' key ':' ( primitive_value | struct_value ) meta_prop* ( ',' key ':' ( primitive_value | struct_value ) meta_prop* )* '}'
set_value ::= '{' ( primitive_value | set_value ) meta_prop? ( ',' ( primitive_value | set_value ) meta_prop? )* '}'
list_value ::= '[' ( primitive_value | list_value ) meta_prop? ( ',' ( primitive_value | list_value ) meta_prop? )* ']'
struct_value ::= '{' key ':' ( primitive_value | struct_value ) meta_prop? ( ',' key ':' ( primitive_value | struct_value ) meta_prop? )* '}'
node_schema
::= 'S' '(' node_id_schema ( '{' ( node_label ( ',' node_label )* )? '}' )? prop_list_schema? ')' graphs_list? metadata?
node_id_schema
Expand All @@ -101,7 +101,7 @@ prop_list_schema
prop_schema
::= key ':' value_schema id_key?
meta_prop_schema
::= '@' key ':' value_schema
::= '@' '<' ( key ':' value_schema ( ',' key ':' value_schema )* )? '>'
cardinality
::= min_cardinality max_cardinality?
| max_cardinality
Expand All @@ -111,8 +111,8 @@ max_cardinality
::= 'MAX' card_num
card_num ::= UNSIGNED_INT
value_schema
::= primitive_value_schema ( 'UNIQUE' | 'NULL' )? 'OPTIONAL'? meta_prop_schema*
| complex_value_schema 'NULL'? 'OPTIONAL'? meta_prop_schema*
::= primitive_value_schema ( 'UNIQUE' | 'NULL' )? 'OPTIONAL'? meta_prop_schema?
| complex_value_schema 'NULL'? 'OPTIONAL'? meta_prop_schema?
primitive_value_schema
::= 'Decimal'
| 'SmallInt'
Expand All @@ -131,11 +131,11 @@ complex_value_schema
| list_schema
| struct_schema
set_schema
::= 'Set' '(' ( primitive_value_schema | set_schema ) 'NULL'? cardinality? ')' meta_prop_schema*
::= 'Set' '(' ( primitive_value_schema | set_schema ) 'NULL'? cardinality? ')' meta_prop_schema?
list_schema
::= 'List' '(' ( primitive_value_schema | list_schema ) 'NULL'? cardinality? ')' meta_prop_schema*
::= 'List' '(' ( primitive_value_schema | list_schema ) 'NULL'? cardinality? ')' meta_prop_schema?
struct_schema
::= 'Struct' '(' ( primitive_value_schema | struct_schema ) 'NULL'? cardinality? ')' meta_prop_schema*
::= 'Struct' '(' ( primitive_value_schema | struct_schema ) 'NULL'? cardinality? ')' meta_prop_schema?
edge_schema
::= directed_schema
| undirected_schema
Expand Down
22 changes: 11 additions & 11 deletions yarspg/YARSpg.g4
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ prop_list
;

meta_prop
: '@' key ':' value
: '@' '<' ( key ':' value ( ',' key ':' value )* )? '>'
;

graphs_list
Expand Down Expand Up @@ -109,7 +109,7 @@ node_label
;

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

edge_id
Expand Down Expand Up @@ -144,15 +144,15 @@ complex_value
;

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

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

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

node_schema
Expand All @@ -172,7 +172,7 @@ prop_schema
;

meta_prop_schema
: '@' key ':' value_schema
: '@' '<' ( key ':' value_schema ( ',' key ':' value_schema )* )? '>'
;

cardinality
Expand All @@ -193,8 +193,8 @@ card_num
;

value_schema
: primitive_value_schema ('UNIQUE' | 'NULL')? 'OPTIONAL'? meta_prop_schema*
| complex_value_schema 'NULL'? 'OPTIONAL'? meta_prop_schema*
: primitive_value_schema ('UNIQUE' | 'NULL')? 'OPTIONAL'? meta_prop_schema?
| complex_value_schema 'NULL'? 'OPTIONAL'? meta_prop_schema?
;

primitive_value_schema
Expand Down Expand Up @@ -223,15 +223,15 @@ complex_value_schema
;

set_schema
: 'Set' '(' (primitive_value_schema | set_schema) 'NULL'? cardinality? ')' meta_prop_schema*
: 'Set' '(' (primitive_value_schema | set_schema) 'NULL'? cardinality? ')' meta_prop_schema?
;

list_schema
: 'List' '(' (primitive_value_schema | list_schema) 'NULL'? cardinality? ')' meta_prop_schema*
: 'List' '(' (primitive_value_schema | list_schema) 'NULL'? cardinality? ')' meta_prop_schema?
;

struct_schema
: 'Struct' '(' (primitive_value_schema | struct_schema) 'NULL'? cardinality? ')' meta_prop_schema*
: 'Struct' '(' (primitive_value_schema | struct_schema) 'NULL'? cardinality? ')' meta_prop_schema?
;

edge_schema
Expand Down
6 changes: 3 additions & 3 deletions yarspg/examples/4-real-example-metaproperties.yarspg
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
S(NS1 {"Author"}["fname": String, "lname": String])+["created": "yesterday"]
S(NS2 {"Entry", "InProceedings"}["title": String, "numpages": Integer, "keyword": String OPTIONAL])
S(NS3 {"Entry", "Article"}["title": String, "numpages": Integer, "keyword": List(String MIN 1 MAX 5) OPTIONAL])
S(NS4 {"Proceedings"}["title": String, "year": Integer, "month": String OPTIONAL @"season": String])
S(NS4 {"Proceedings"}["title": String, "year": Integer, "month": String OPTIONAL @<"season": String>])
S(NS5 {"Journal"}["title": String, "year": Integer, "vol": Integer])

# Edge schema
Expand All @@ -20,8 +20,8 @@ S(NS3)-({"published_in"}["pages": String])->(NS5)
(Author02 {"Author"}["fname": "Alice", "lname": "Brown"])
(EI01 {"Entry", "InProceedings"}["title": "Serialization for...", "numpages": "10", "keyword": "Graph database"])
(EA01 {"Entry", "Article"}["title": "Property Graph...", "numpages": "10", "keyword": ["Query", "Graph"]])
(Proc01 {"Proceedings"}["title": "BDAS", "year": "2018", "month": "May" @"season": "spring"])
(Jour01 {"Journal"}["title": "J. DB", "year": "2020" @"date": "2020-06-16", "vol": "30"])
(Proc01 {"Proceedings"}["title": "BDAS", "year": "2018", "month": "May" @<"season": "spring">])
(Jour01 {"Journal"}["title": "J. DB", "year": "2020" @<"date": "2020-06-16">, "vol": "30"])

# Edges
(EI01)-({"has_author"}["order": "1"])->(Author01)
Expand Down
6 changes: 3 additions & 3 deletions yarspg/examples/5-real-example-variables.yarspg
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ $title_numpages = "title": String, "numpages": Integer
S(NS1 {"Author"}["fname": String, "lname": String])+["created": "yesterday"]
S(NS2 {"Entry", "InProceedings"}[$title_numpages, "keyword": String OPTIONAL])
S(NS3 {"Entry", "Article"}[$title_numpages, "keyword": List(String MIN 1 MAX 5) OPTIONAL])
S(NS4 {"Proceedings"}["title": String, "year": Integer, "month": String OPTIONAL @"season": String])
S(NS4 {"Proceedings"}["title": String, "year": Integer, "month": String OPTIONAL @<"season": String>])
S(NS5 {"Journal"}["title": String, "year": Integer, "vol": Integer])

# Edge schema
Expand All @@ -23,8 +23,8 @@ S(NS3)-({"published_in"}["pages": String])->(NS5)
(Author02 {"Author"}["fname": "Alice", "lname": "Brown"])
(EI01 {"Entry", "InProceedings"}["title": "Serialization for...", "numpages": "10", "keyword": "Graph database"])
(EA01 {"Entry", "Article"}["title": "Property Graph...", "numpages": "10", "keyword": ["Query", "Graph"]])
(Proc01 {"Proceedings"}["title": "BDAS", "year": "2018", "month": "May" @"season": "spring"])
(Jour01 {"Journal"}["title": "J. DB", "year": "2020" @"date": "2020-06-16", "vol": "30"])
(Proc01 {"Proceedings"}["title": "BDAS", "year": "2018", "month": "May" @<"season": "spring">])
(Jour01 {"Journal"}["title": "J. DB", "year": "2020" @<"date": "2020-06-16">, "vol": "30"])

# Edges
(EI01)-({"has_author"}["order": "1"])->(Author01)
Expand Down
4 changes: 2 additions & 2 deletions yarspg/examples/features-overview.yarspg
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ S/graph1/["prop": Bool, "prop2": String]
/graph1/{"graph_label", "graphlabel2"}["prop": "true", "prop2": "Abc"]

# Variables (can store properties; @ - meta properties)
$graph2_prop = "prop2": "Abc"@"ok": "false"
$graph2_prop_schema = "prop2": String @"ok": Bool
$graph2_prop = "prop2": "Abc"@<"ok": "false">
$graph2_prop_schema = "prop2": String @<"ok": Bool>

# Use of variables
S/graph2/["prop": Bool, $graph2_prop_schema]
Expand Down
42 changes: 21 additions & 21 deletions yarspg/examples/test-example.yarspg
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ S/default/["prop": Bool]
S/graph1/["prop": Bool, "prop2": String]
/graph1/{"graph_label", "graphlabel2"}["prop": "true", "prop2": "Abc"]

$graph2_prop = "prop2": "Abc"@"ok": "false"
$graph2_prop_schema = "prop2": String @"ok": Bool
$graph2_prop = "prop2": "Abc"@<"ok": "false">
$graph2_prop_schema = "prop2": String @<"ok": Bool>

# GRAPH
S/graph2/["prop": Bool, $graph2_prop_schema]
Expand Down Expand Up @@ -57,29 +57,29 @@ S(NS6 {"label546"}["key": Float UNIQUE])
(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"])
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": "<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"]])
(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(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))])
(a2i44 {"2label4"}["keyword2": {"names": {"name": "abc", "title": "xyz"}, "names2": {"name2": "abc2", "title2": "xyz2"}, "names3": {"name3": "abc3", "title3": "xyz3"}}])
S(NS11 {"2label4"}["keyword2": Struct(Struct(String)@"struct": String)@"struct": String @"ok": Bool])
(a2i44 {"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"])
S(NS11 {"2label4"}["keyword2": Struct(Struct(String)@<"struct": String>)@<"struct": String, "ok": Bool>])
(a2i44 {"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(NS12 {"432f"}["set": Set(String)])/graphname/
(z {"432f"}["set": {"name", "title"}])/graphname/
(z {"432f"}["set": {"name", "title"}@"test":"test3"])/graphname/
(z {"432f"}["set": {"name", "title"}@<"test":"test3">])/graphname/
S(NS13 {"432f2"}["set": Set(Set(String))])
(z2 {"432f2"}["set": {{"set2", "title"}}])
S(NS14 {"3432f2"}["set": Set(Set(String))])
Expand Down Expand Up @@ -132,9 +132,9 @@ S(A01)-({"aaa1a"}["key": String, "aab2bc": List(Integer)])->(A02)
S(A01)-({"aaa1a"}["key": String UNIQUE, "aab2bc": List(Integer)])->(A02)
(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>"]
$var_e344 = "aab2bc": ["44", "22"]@"list name": "alph"
(a)-(ferf {"aaa1a"}["key": "value"@"ok": "no", $var_e344])->(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>"]
$var_e344 = "aab2bc": ["44", "22"]@<"list name": "alph">
(a)-(ferf {"aaa1a"}["key": "value"@<"ok": "no">, $var_e344])->(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(HAd34)-({"bbb23b"})-(sje2)
(b43b)-({"bbb23b"})-(e)
Expand All @@ -144,21 +144,21 @@ S(ABC434)-({"bbb23b"}["bbbd32d": Bool, "value": String OPTIONAL])-(JSk342)
S(ad234)-({"bbb23b"}[$var_234e_schema, "value": String NULL])-(gr525)
S(asf32)-({"bbb23b"}["bbbd32d": Bool UNIQUE, "value": String NULL])-(wef32)
S(asf323)-({"bbb23b"}["bbbd32d": Bool UNIQUE, "value": List(String) NULL])-(wef323)
S(asf3233)-({"bbb23b"}["bbbd32d": Bool UNIQUE @"dfwe": Integer NULL, "value": List(String) NULL @"efe": List(List(String))])-(wef3234)
S(asf3233)-({"bbb23b"}["bbbd32d": Bool UNIQUE @<"dfwe": Integer NULL>, "value": List(String) NULL @<"efe": List(List(String))>])-(wef3234)
S(asf3245)-({"bbb23b"}["bbbd32d": Bool UNIQUE, "value": List(String) OPTIONAL])-(wef3245)
S(asf3245)-({"bbb23b"}["bbbd32d": Bool UNIQUE, "value": List(String MIN 4) OPTIONAL])-(wef3245)
S(asf3244)-({"bbb23b"}["bbbd32d": Bool UNIQUE, "value": List(String) OPTIONAL @"psod": Struct(Integer) OPTIONAL])-(wef3245)
S(asf3244)-({"bbb23b"}["bbbd32d": Bool UNIQUE, "value": List(String) OPTIONAL @"psod": Struct(Integer MAX 3) OPTIONAL])-(wef3245)
S(asf3244)-({"bbb23b"}["bbbd32d": Bool UNIQUE, "value": List(String) OPTIONAL @<"psod": Struct(Integer) OPTIONAL>])-(wef3245)
S(asf3244)-({"bbb23b"}["bbbd32d": Bool UNIQUE, "value": List(String) OPTIONAL @<"psod": Struct(Integer MAX 3) OPTIONAL>])-(wef3245)
(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"]
(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(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(wf2343)-({"label5"}["datetime": DateTime @<"info": String>])->(erg3264)
S(sdaf56)-({"label5"}["datetime": DateTime UNIQUE])->(dsf53)
S(sas34)-({"label6"}["datetimetzp": DateTime])->(sdag654)
S(asdg41)-({"label7"}["datetimetzm": DateTime])->(asv94)
Expand Down

0 comments on commit fd2fa10

Please sign in to comment.