Skip to content

Commit

Permalink
New awesome syntax for node schemas
Browse files Browse the repository at this point in the history
  • Loading branch information
lszeremeta committed Aug 21, 2020
1 parent 7782b71 commit 36d3916
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 36 deletions.
2 changes: 1 addition & 1 deletion other-notations/YARSpg.ebnf
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,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? annotations_list?
::= 'S' '(' ( '{' ( node_label ( ',' node_label )* )? '}' )? prop_list_schema ')' graphs_list? annotations_list?
prop_list_schema
::= ( '[' ( ( prop_schema | var ) ( ',' ( prop_schema | var ) )* )? ']' )?
prop_schema
Expand Down
2 changes: 1 addition & 1 deletion yarspg/YARSpg.g4
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ struct
;

node_schema
: 'S' ( '{' ( node_label ( ',' node_label )* )? '}' )? prop_list_schema graphs_list? annotations_list?
: 'S' '(' ( '{' ( node_label ( ',' node_label )* )? '}' )? prop_list_schema ')' graphs_list? annotations_list?
;

prop_list_schema
Expand Down
10 changes: 5 additions & 5 deletions yarspg/examples/canonical-real-example.yarspg
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
%METADATA
-<http://xmlns.com/foaf/0.1/maker>:"Ł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({"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])
%EDGE SCHEMAS
S("Entry")-({"has_author"}["order":Integer])->("Author")
S("Entry")-({"cities"})->("Entry")
Expand Down
10 changes: 5 additions & 5 deletions yarspg/examples/real-example.yarspg
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
-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({"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])

# Edge schema
S("Entry")-({"has_author"}["order": Integer])->("Author")
Expand Down
48 changes: 24 additions & 24 deletions yarspg/examples/test-example.yarspg
Original file line number Diff line number Diff line change
Expand Up @@ -36,58 +36,58 @@ $var44 = "aa1a":true,"a2aa":"text"
("a" {"a1d","x"}["aa1a":true,"a2aa":"text","aa3aa":null])+[foaf:maker: "Łukasz Szeremeta and Dominik Tomaszuk", <http://xmlns.com/dc/0.5/zyz>: "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({}[])/"graph2"/
$var44_schema = "value": String,"lang": String
S{"label333","c"}[$var44_schema,"valid": Bool]/"graph2"/+[<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{"label333","c"}["value": String,"lang": String,"valid": Bool ID]/"graph2"/+[<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{"label333","c"}["value": String ID,"lang": String,"valid": Bool]/"graph2"/+[<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({"label333","c"}[$var44_schema,"valid": Bool])/"graph2"/+[<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({"label333","c"}["value": String,"lang": String,"valid": Bool ID])/"graph2"/+[<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({"label333","c"}["value": String ID,"lang": String,"valid": Bool])/"graph2"/+[<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>]
("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]
S{"label546"}["key": Float ID]
S({"label546"}["key": Float])
S({"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({"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)]
S({"label"}["keyword": Struct(String)])
("i" {"label"}["keyword": {"name": "abc", "title": "xyz"}])
S{"label"}["keyword": Struct(String)@"ok": Integer]
S({"label"}["keyword": Struct(String)@"ok": Integer])
("i" {"label"}["keyword": {"name": "abc"@"info": "ok", "title": "xyz"}@"ok": 1])
S{"2label4"}["keyword2": Struct(Struct(String))]
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]
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"/
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))]
S({"432f2"}["set": Set(Set(String))])
("z2" {"432f2"}["set": {{"set2", "title"}}])
S{"3432f2"}["set": Set(Set(String))]
S({"3432f2"}["set": Set(Set(String))])
("3z2" {"3432f2"}["set": {{"set2", "title"}, {"set3", "title3"}}])
S{"1ad32"}["list": List(String)]
S({"1ad32"}["list": List(String)])
("1dsc" {"1ad32"}["list": ["name55", "name3"]])
S{"1ad32"}["list": List(String NULL)]
S({"1ad32"}["list": List(String NULL)])
("1dsc" {"1ad32"}["list": ["name55", null]])
S{"1ad32"}["list": List(String) NULL]
S({"1ad32"}["list": List(String) NULL])
("1dsc" {"1ad32"}["list": null])
S{"ad3"}["list": List(List(String))]
S({"ad3"}["list": List(List(String))])
("ds" {"ad3"}["list": [["name55", "name3"]]])
S{"ad32"}["list": List(List(String))]
S({"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({"ZYT"}["date": Date])
S({"ZYT2"}["time": Time])
S({"ZYT3"}["timezp": Time])
S({"ZYT4"}["timezm": Time])
S({"ZYT5"}["datetime": DateTime])
("ABC" {"ZYT"}["date": 1999-01-01])
("ABC2" {"ZYT2"}["time": 11:15:32])
("ABC3" {"ZYT3"}["timezp": 11:15:32+01:30])
Expand Down

0 comments on commit 36d3916

Please sign in to comment.