Skip to content

Commit

Permalink
BNF/JSON: update grammar (s/t/a functions, temporal literals, scalar …
Browse files Browse the repository at this point in the history
…with instants)

WIP: updates in text/examples/etc to follow
  • Loading branch information
cportele committed Jul 5, 2021
1 parent 2bae926 commit 7c3e18c
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 49 deletions.
48 changes: 32 additions & 16 deletions extensions/cql/standard/schema/cql.bnf
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ binaryComparisonPredicate = scalarExpression
scalarExpression = characterLiteral
| numericLiteral
| booleanLiteral
| instantLiteral
| propertyName
| function
| arithmeticExpression;
Expand Down Expand Up @@ -91,7 +92,7 @@ isInListPredicate = inListOperand ["NOT"] "IN" leftParen inList rightParen;
inList = inListOperand [ {comma inListOperand} ];

inListOperand = scalarExpression
| temporalLiteral
| intervalLiteral
| spatialLiteral;

# IS NULL predicate
Expand Down Expand Up @@ -130,7 +131,8 @@ geomExpression = spatialLiteral
# A temporal predicate evaluates if two temporal expressions satisfy the
# specified temporal operator.
#=============================================================================#
temporalPredicate = temporalExpression temporalOperator temporalExpression;
temporalPredicate = temporalOperator
leftParen temporalExpression comma temporalExpression rightParen;

temporalExpression = temporalLiteral
| propertyName
Expand Down Expand Up @@ -158,7 +160,8 @@ temporalOperator = "T_AFTER"
# not equal, less than, greater than, less than or equal, greater than or equal,
# superset, subset and overlap operators.
#=============================================================================#
arrayPredicate = arrayExpression arrayOperator arrayExpression;
arrayPredicate = arrayOperator
leftParen arrayExpression comma arrayExpression rightParen;

# An array expression is a bracket-delimited, comma-separated list of array
# elements. An array element is either a character literal, a numeric literal,
Expand All @@ -182,7 +185,7 @@ arrayElement = characterLiteral

arrayOperator = "A_EQUALS"
| "A_CONTAINS"
| "A_CONTAINED BY"
| "A_CONTAINEDBY"
| "A_OVERLAPS";

#=============================================================================#
Expand Down Expand Up @@ -511,18 +514,31 @@ maxElev = signedNumericLiteral;
# NOTE: Is the fact the time zones are supported too complicated for a
# simple CQL? Perhaps the "core" of CQL should just support UTC.
#=============================================================================#
temporalLiteral = instant | interval;

instant = fullDate | fullDate "T" utcTime;

interval = solidus
| solidus dotdot
| dotdot solidus
| instant solidus
| solidus instant
| instant solidus dotdot
| dotdot solidus instant
| instant solidus instant;
temporalLiteral = instantLiteral | intervalLiteral;

instantLiteral = dateInstant | timestampInstant;

dateInstant = "DATE"
leftParen dateInstantString rightParen;

dateInstantString = quote fullDate quote;

timestampInstant = "TIMESTAMP"
leftParen timestampInstantString rightParen;

timestampInstantString = quote fullDate "T" utcTime quote;

instantLiteral = fullDate | fullDate "T" utcTime;

intervalLiteral = "INTERVAL"
leftParen instantParameter comma instantParameter rightParen;

instantParameter = instantLiteral
| dateInstantString
| timestampInstantString
| quote dotdot quote
| propertyName
| function;

fullDate = dateYear "-" dateMonth "-" dateDay;

Expand Down
87 changes: 54 additions & 33 deletions extensions/cql/standard/schema/cql.json
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@
"oneOf": [
{"$ref": "#/$defs/scalarExpression"},
{"$ref": "#/$defs/spatialLiteral"},
{"$ref": "#/$defs/typedTemporalLiteral"}
{"$ref": "#/$defs/intervalLiteral"}
]
},

Expand Down Expand Up @@ -532,12 +532,12 @@
"type": "array",
"items": {
"oneOf": [
{"$ref": "#/$defs/scalarLiteral"},
{"$ref": "#/$defs/spatialLiteral"},
{"$ref": "#/$defs/typedTemporalLiteral"},
{ "$ref": "#/$defs/scalarLiteral"},
{ "$ref": "#/$defs/spatialLiteral"},
{ "$ref": "#/$defs/intervalLiteral"},
{ "$ref": "#/$defs/propertyRef" },
{ "$ref": "#/$defs/functionRef" },
{"$ref": "#/$defs/arithmeticExpression"},
{ "$ref": "#/$defs/arithmeticExpression"},
{ "$ref": "#/$defs/arrayLiteral" }
]
}
Expand Down Expand Up @@ -636,7 +636,7 @@
"oneOf": [
{ "$ref": "#/$defs/scalarLiteral" },
{ "$ref": "#/$defs/spatialLiteral" },
{ "$ref": "#/$defs/typedTemporalLiteral" },
{ "$ref": "#/$defs/intervalLiteral" },
{ "$ref": "#/$defs/propertyRef" },
{ "$ref": "#/$defs/functionRef" },
{ "$ref": "#/$defs/arithmeticExpression" },
Expand All @@ -655,7 +655,8 @@
"oneOf": [
{ "type": "string" },
{ "type": "number" },
{ "type": "boolean"}
{ "type": "boolean"},
{ "$ref": "#/$defs/instantLiteral" }
]
},

Expand Down Expand Up @@ -885,54 +886,74 @@

"temporalLiteral": {
"oneOf": [
{ "$ref": "#/$defs/instantString" },
{ "$ref": "#/$defs/intervalString" }
{ "$ref": "#/$defs/instantLiteral" },
{ "$ref": "#/$defs/intervalLiteral" }
]
},

"instantString": {
"instantLiteral": {
"oneOf": [
{ "type": "string", "format": "date" },
{ "type": "string", "format": "date-time" }
{ "$ref": "#/$defs/dateLiteral" },
{ "$ref": "#/$defs/timestampLiteral" }
]
},

"intervalString": {
"type": "array",
"minItems": 2,
"maxItems": 2,
"items": {
"oneOf": [
{ "$ref": "#/$defs/instantString" },
{ "type": "string", "enum": [".."] }
]
"dateLiteral": {
"type": "object",
"required": ["date"],
"properties": {
"date": {
"$ref": "#/$defs/dateString"
}
}
},

"timestampLiteral": {
"type": "object",
"required": ["timestamp"],
"properties": {
"timestamp": {
"$ref": "#/$defs/timestampString"
}
}
},

"typedTemporalLiteral": {
"instantString": {
"oneOf": [
{ "$ref": "#/$defs/typedInstantString" },
{ "$ref": "#/$defs/typedIntervalString" }
{ "$ref": "#/$defs/dateString" },
{ "$ref": "#/$defs/timestampString" }
]
},

"typedInstantString": {
"dateString": {
"type": "string",
"format": "date"
},

"timestampString": {
"type": "string",
"format": "date-time"
},

"intervalLiteral": {
"type": "object",
"required": ["datetime"],
"properties": {
"datetime": {
"$ref": "#/$defs/instantString"
"$ref": "#/$defs/intervalArray"
}
}
},

"typedIntervalString": {
"type": "object",
"required": ["datetime"],
"properties": {
"datetime": {
"$ref": "#/$defs/intervalString"
}
"intervalArray": {
"type": "array",
"minItems": 2,
"maxItems": 2,
"items": {
"oneOf": [
{ "$ref": "#/$defs/instantString" },
{ "type": "string", "enum": [".."] }
]
}
}
}
Expand Down

0 comments on commit 7c3e18c

Please sign in to comment.