Skip to content

Commit

Permalink
Case-insensitive names
Browse files Browse the repository at this point in the history
  • Loading branch information
lszeremeta committed Nov 29, 2021
1 parent c575a11 commit 96b38ee
Show file tree
Hide file tree
Showing 3 changed files with 102 additions and 41 deletions.
68 changes: 48 additions & 20 deletions other-notations/YARSpg.ebnf
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ variable_declaration_schema
variable_name
::= ALNUMPLUS
graph_id
::= 'default'
::= DEFAULT
| ALNUMPLUS
prop_list
::= ( '[' ( ( prop | variable ) ( ',' ( prop | variable ) )* )? ']' )?
Expand Down Expand Up @@ -106,37 +106,37 @@ cardinality
::= min_cardinality max_cardinality?
| max_cardinality
min_cardinality
::= 'MIN' card_num
::= MIN card_num
max_cardinality
::= 'MAX' card_num
::= 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'
| 'Integer'
| 'BigInt'
| 'Float'
| 'Real'
| 'Double'
| 'Bool'
| 'String'
| 'Date'
| 'DateTime'
| 'Time'
::= DECIMAL
| SMALLINT
| INTEGER
| BIGINT
| FLOAT
| REAL
| DOUBLE
| BOOL
| STRING_TYPE
| DATE
| DATETIME
| TIME
| ALNUMPLUS
complex_value_schema
::= set_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 All @@ -146,6 +146,34 @@ undirected_schema
::= 'S' '(' node_id_schema ')' '-' ( '(' ( '{' ( edge_label ( ',' edge_label )* )? '}' )? prop_list_schema? ')' )? '-' '(' node_id_schema1 ')' graphs_list?
graph_schema
::= 'S' '/' graph_id '/' prop_list_schema?

/* CASE-INSENSITIVE NAMES */
DEFAULT ::= ( 'D' | 'd' ) ( 'E' | 'e' ) ( 'F' | 'f' ) ( 'A' | 'a' ) ( 'U' | 'u' ) ( 'L' | 'l' ) ( 'T' | 't' )
MIN ::= ( 'M' | 'm' ) ( 'I' | 'i' ) ( 'N' | 'n' )
MAX ::= ( 'M' | 'm' ) ( 'A' | 'a' ) ( 'X' | 'x' )
UNIQUE ::= ( 'U' | 'u' ) ( 'N' | 'n' ) ( 'I' | 'i' ) ( 'Q' | 'q' ) ( 'U' | 'u' ) ( 'E' | 'e' )
NULL ::= ( 'N' | 'n' ) ( 'U' | 'u' ) ( 'L' | 'l' ) ( 'L' | 'l' )
OPTIONAL ::= ( 'O' | 'o' ) ( 'P' | 'p' ) ( 'T' | 't' ) ( 'I' | 'i' ) ( 'O' | 'o' ) ( 'N' | 'n' ) ( 'A' | 'a' ) ( 'L' | 'l' )

DECIMAL ::= ( 'D' | 'd' ) ( 'E' | 'e' ) ( 'C' | 'c' ) ( 'I' | 'i' ) ( 'M' | 'm' ) ( 'A' | 'a' ) ( 'L' | 'l' )
SMALLINT ::= ( 'S' | 's' ) ( 'M' | 'm' ) ( 'A' | 'a' ) ( 'L' | 'l' ) ( 'L' | 'l' ) ( 'I' | 'i' ) ( 'N' | 'n' ) ( 'T' | 't' )
INTEGER ::= ( 'I' | 'i' ) ( 'N' | 'n' ) ( 'T' | 't' ) ( 'E' | 'e' ) ( 'G' | 'g' ) ( 'E' | 'e' ) ( 'R' | 'r' )
BIGINT ::= ( 'B' | 'b' ) ( 'I' | 'i' ) ( 'G' | 'g' ) ( 'I' | 'i' ) ( 'N' | 'n' ) ( 'T' | 't' )
FLOAT ::= ( 'F' | 'f' ) ( 'L' | 'l' ) ( 'O' | 'o' ) ( 'A' | 'a' ) ( 'T' | 't' )
REAL ::= ( 'R' | 'r' ) ( 'E' | 'e' ) ( 'A' | 'a' ) ( 'L' | 'l' )
DOUBLE ::= ( 'D' | 'd' ) ( 'O' | 'o' ) ( 'U' | 'u' ) ( 'B' | 'b' ) ( 'L' | 'l' ) ( 'E' | 'e' )
BOOL ::= ( 'B' | 'b' ) ( 'O' | 'o' ) ( 'O' | 'o' ) ( 'L' | 'l' )
STRING_TYPE
::= ( 'S' | 's' ) ( 'T' | 't' ) ( 'R' | 'r' ) ( 'I' | 'i' ) ( 'N' | 'n' ) ( 'G' | 'g' )
DATE ::= ( 'D' | 'd' ) ( 'A' | 'a' ) ( 'T' | 't' ) ( 'E' | 'e' )
DATETIME ::= ( 'D' | 'd' ) ( 'A' | 'a' ) ( 'T' | 't' ) ( 'E' | 'e' ) ( 'T' | 't' ) ( 'I' | 'i' ) ( 'M' | 'm' ) ( 'E' | 'e' )
TIME ::= ( 'T' | 't' ) ( 'I' | 'i' ) ( 'M' | 'm' ) ( 'E' | 'e' )

SET ::= ( 'S' | 's' ) ( 'E' | 'e' ) ( 'T' | 't' )
LIST ::= ( 'L' | 'l' ) ( 'I' | 'i' ) ( 'S' | 's' ) ( 'T' | 't' )
STRUCT ::= ( 'S' | 's' ) ( 'T' | 't' ) ( 'R' | 'r' ) ( 'U' | 'u' ) ( 'C' | 'c' ) ( 'T' | 't' )
/* END CASE-INSENSITIVE NAMES */

COMMENT ::= '#' [^#xd#xa#xc]*
STRING ::= '"' ([^"\#xd#xa] | "'" | '\"')* '"'
UNSIGNED_INT
Expand Down
70 changes: 49 additions & 21 deletions yarspg/YARSpg.g4
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ variable_name
;

graph_id
: 'default'
: DEFAULT
| ALNUMPLUS
;

Expand Down Expand Up @@ -181,39 +181,39 @@ cardinality
;

min_cardinality
: 'MIN' card_num
: MIN card_num
;

max_cardinality
: 'MAX' card_num
: 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
// NUMBER
: 'Decimal'
| 'SmallInt'
| 'Integer'
| 'BigInt'
| 'Float'
| 'Real'
| 'Double'
: DECIMAL
| SMALLINT
| INTEGER
| BIGINT
| FLOAT
| REAL
| DOUBLE
// BOOL
| 'Bool'
| BOOL
// STRING
| 'String'
| STRING_TYPE
// DATETYPE
| 'Date'
| 'DateTime'
| 'Time'
| DATE
| DATETIME
| TIME
| ALNUMPLUS
;

Expand All @@ -224,15 +224,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 All @@ -252,6 +252,34 @@ graph_schema
: 'S' '/' graph_id '/' prop_list_schema?
;

// CASE-INSENSITIVE NAMES
DEFAULT : ( 'D' | 'd' ) ( 'E' | 'e' ) ( 'F' | 'f' ) ( 'A' | 'a' ) ( 'U' | 'u' ) ( 'L' | 'l' ) ( 'T' | 't' );
MIN: ( 'M' | 'm' ) ( 'I' | 'i' ) ( 'N' | 'n' );
MAX: ( 'M' | 'm' ) ( 'A' | 'a' ) ( 'X' | 'x' );
UNIQUE: ( 'U' | 'u' ) ( 'N' | 'n' ) ( 'I' | 'i' ) ( 'Q' | 'q' ) ( 'U' | 'u' ) ( 'E' | 'e' );
NULL: ( 'N' | 'n' ) ( 'U' | 'u' ) ( 'L' | 'l' ) ( 'L' | 'l' );
OPTIONAL: ( 'O' | 'o' ) ( 'P' | 'p' ) ( 'T' | 't' ) ( 'I' | 'i' ) ( 'O' | 'o' ) ( 'N' | 'n' ) ( 'A' | 'a' ) ( 'L' | 'l' );

// primitive datetypes
DECIMAL: ( 'D' | 'd' ) ( 'E' | 'e' ) ( 'C' | 'c' ) ( 'I' | 'i' ) ( 'M' | 'm' ) ( 'A' | 'a' ) ( 'L' | 'l' );
SMALLINT: ( 'S' | 's' ) ( 'M' | 'm' ) ( 'A' | 'a' ) ( 'L' | 'l' ) ( 'L' | 'l' ) ( 'I' | 'i' ) ( 'N' | 'n' ) ( 'T' | 't' );
INTEGER: ( 'I' | 'i' ) ( 'N' | 'n' ) ( 'T' | 't' ) ( 'E' | 'e' ) ( 'G' | 'g' ) ( 'E' | 'e' ) ( 'R' | 'r' );
BIGINT: ( 'B' | 'b' ) ( 'I' | 'i' ) ( 'G' | 'g' ) ( 'I' | 'i' ) ( 'N' | 'n' ) ( 'T' | 't' );
FLOAT: ( 'F' | 'f' ) ( 'L' | 'l' ) ( 'O' | 'o' ) ( 'A' | 'a' ) ( 'T' | 't' );
REAL: ( 'R' | 'r' ) ( 'E' | 'e' ) ( 'A' | 'a' ) ( 'L' | 'l' );
DOUBLE: ( 'D' | 'd' ) ( 'O' | 'o' ) ( 'U' | 'u' ) ( 'B' | 'b' ) ( 'L' | 'l' ) ( 'E' | 'e' );
BOOL: ( 'B' | 'b' ) ( 'O' | 'o' ) ( 'O' | 'o' ) ( 'L' | 'l' );
STRING_TYPE: ( 'S' | 's' ) ( 'T' | 't' ) ( 'R' | 'r' ) ( 'I' | 'i' ) ( 'N' | 'n' ) ( 'G' | 'g' );
DATE: ( 'D' | 'd' ) ( 'A' | 'a' ) ( 'T' | 't' ) ( 'E' | 'e' );
DATETIME: ( 'D' | 'd' ) ( 'A' | 'a' ) ( 'T' | 't' ) ( 'E' | 'e' ) ( 'T' | 't' ) ( 'I' | 'i' ) ( 'M' | 'm' ) ( 'E' | 'e' );
TIME: ( 'T' | 't' ) ( 'I' | 'i' ) ( 'M' | 'm' ) ( 'E' | 'e' );

// complex datetypes
SET: ( 'S' | 's' ) ( 'E' | 'e' ) ( 'T' | 't' );
LIST: ( 'L' | 'l' ) ( 'I' | 'i' ) ( 'S' | 's' ) ( 'T' | 't' );
STRUCT: ( 'S' | 's' ) ( 'T' | 't' ) ( 'R' | 'r' ) ( 'U' | 'u' ) ( 'C' | 'c' ) ( 'T' | 't' );
// END CASE-INSENSITIVE NAMES

COMMENT
: '#' ~[\r\n\f]* -> skip
;
Expand All @@ -270,4 +298,4 @@ ALNUMPLUS
WS
: [ \t\n]+ -> skip
;
;
5 changes: 5 additions & 0 deletions yarspg/examples/test-example.yarspg
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,18 @@ $var44 = "aa1a":"true","a2aa":"text"
(b43b {"label1"}["value":"5"])+["foaf:maker": "Łukasz Szeremeta and Dominik Tomaszuk"] #b43b
S(NS1 {}[])/graph2/
$var4_schema = "value": String,"lang": String
$var4_schema = "value": string,"lang": sTRIng
$var44_schema = "value": String NULL,"lang": String OPTIONAL
$var44_schema = "value": String NULL,"lang": String opTionaL
S(NS2 {"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(NS3 {"label333","c"}["value": String,"lang": String,"valid": Bool UNIQUE])/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(NS4 {"label333","c"}["value": String UNIQUE,"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(NS5 {"label546"}["key": Float])
S(NS52 {"label546"}["key": Float OPTIONAL])
S(NS6 {"label546"}["key": Float UNIQUE])
S(NS6 {"label546"}["key": floAt UNIQUE])
S(NS6 {"label546"}["key": Float UniquE])
(d {"label546"}["key":".1333"])
(d {"label546"}["key":".1333e+5"])
(d {"label546"}["key":"1333E-2"])
Expand Down Expand Up @@ -89,6 +93,7 @@ S(NS15 {"1ad32"}["list": List(String)])
S(NS16 {"1ad32"}["list": List(String NULL)])
S(NS163 {"1ad32"}["list": List(String MAX 3)])
S(NS164 {"1ad32"}["list": List(String MIN 1)])
S(NS164 {"1ad32"}["list": list(string min 1)])
S(NS165 {"1ad32"}["list": List(String MAX 1)])
(c1dsc {"1ad32"}["list": ["name55", "null"]])
S(NS17 {"1ad32"}["list": List(String) NULL])
Expand Down

0 comments on commit 96b38ee

Please sign in to comment.