-
Notifications
You must be signed in to change notification settings - Fork 87
/
Copy pathcql2.bnf
621 lines (511 loc) · 26 KB
/
cql2.bnf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
#
# MODULE: cql2.bnf
# PURPOSE: A BNF grammar for the Common Query Language (CQL2).
# HISTORY:
# DATE EMAIL DESCRIPTION
# 13-SEP-2019 pvretano[at]cubewerx.com Initial creation
# 28-OCT-2019 pvretano[at]cubewerx.com Initial check-in into github
# 22-DEC-2020 pvretano[at]cubewerx.com 1.0.0-draft.1 (version for public review)
# portele[at]interactive-instruments.de
# 07-MAR-2024 pvretano[at]cubewerx.com 1.0.0-rc.1 (release candidate)
# portele[at]interactive-instruments.de
# 02-JUL-2024 pvretano[at]cubewerx.com 1.0.0 (final release)
# portele[at]interactive-instruments.de
# xx-xxx-2024 pvretano[at]cubewerx.com 1.0.1-SNAPHOST
# portele[at]interactive-instruments.de
#=============================================================================#
# A CQL2 filter is a logically connected expression of one or more predicates.
# Predicates include scalar or comparison predicates, spatial predicates or
# temporal predicates.
#
# *** DISCLAIMER: ***
# Because there are many variations of EBNF, this standard has focused
# on verifying that this grammar validates using the following online
# validator:
#
# https://www.icosaedro.it/bnf_chk/bnf_chk-on-line.html
#
# If other tools are used (e.g. ANTLR), the grammar will likely need to be
# adapted to suite the target implementation context.
#=============================================================================#
booleanExpression = booleanTerm [ {"OR" booleanTerm} ];
booleanTerm = booleanFactor [ {"AND" booleanFactor} ];
booleanFactor = ["NOT"] booleanPrimary;
booleanPrimary = function
| predicate
| booleanLiteral
| "(" booleanExpression ")";
predicate = comparisonPredicate
| spatialPredicate
| temporalPredicate
| arrayPredicate;
#=============================================================================#
# A comparison predicate evaluates if two scalar expression statisfy the
# specified comparison operator. The comparion operators includes an operator
# to evaluate pattern matching expressions (LIKE), a range evaluation operator
# and an operator to test if a scalar expression is NULL or not.
#=============================================================================#
comparisonPredicate = binaryComparisonPredicate
| isLikePredicate
| isBetweenPredicate
| isInListPredicate
| isNullPredicate;
# Binary comparison predicate
#
binaryComparisonPredicate = scalarExpression
comparisonOperator
scalarExpression;
scalarExpression = characterClause
| numericLiteral
| instantInstance
| arithmeticExpression
| booleanLiteral
| propertyName
| function;
comparisonOperator = "=" # equal
| "<" ">" # not equal
| "<" # less than
| ">" # greater than
| "<" "=" # less than or equal
| ">" "="; # greater than or equal
# LIKE predicate
#
isLikePredicate = characterExpression ["NOT"] "LIKE" patternExpression;
patternExpression = "CASEI" "(" patternExpression ")"
| "ACCENTI" "(" patternExpression ")"
| characterLiteral;
# BETWEEN predicate
#
isBetweenPredicate = numericExpression ["NOT"] "BETWEEN"
numericExpression "AND" numericExpression;
numericExpression = arithmeticExpression
| numericLiteral
| propertyName
| function;
# IN LIST predicate
#
isInListPredicate = scalarExpression ["NOT"] "IN" "(" inList ")";
inList = scalarExpression [ {"," scalarExpression} ];
# IS NULL predicate
#
isNullPredicate = isNullOperand "IS" ["NOT"] "NULL";
isNullOperand = characterClause
| numericLiteral
| temporalInstance
| spatialInstance
| arithmeticExpression
| booleanExpression
| propertyName
| function;
#=============================================================================#
# A spatial predicate evaluates if two spatial expressions satisfy the
# condition implied by a standardized spatial comparison function. If the
# conditions of the spatial comparison function are met, the function returns
# a Boolean value of true. Otherwise the function returns false.
#=============================================================================#
spatialPredicate = spatialFunction "(" geomExpression "," geomExpression ")";
# NOTE: The buffer functions (DWITHIN and BEYOND) are not included because
# these are outside the scope of a "simple" core for CQL2. These
# can be added as extensions.
#
spatialFunction = "S_INTERSECTS"
| "S_EQUALS"
| "S_DISJOINT"
| "S_TOUCHES"
| "S_WITHIN"
| "S_OVERLAPS"
| "S_CROSSES"
| "S_CONTAINS";
# A geometric expression is a property name of a geometry-valued property,
# a geometric literal (expressed as WKT) or a function that returns a
# geometric value.
#
geomExpression = spatialInstance
| propertyName
| function;
#=============================================================================#
# A temporal predicate evaluates if two temporal expressions satisfy the
# condition implied by a standardized temporal comparison function. If the
# conditions of the temporal comparison function are met, the function returns
# a Boolean value of true. Otherwise the function returns false.
#=============================================================================#
temporalPredicate = temporalFunction
"(" temporalExpression "," temporalExpression ")";
temporalExpression = temporalInstance
| propertyName
| function;
temporalFunction = "T_AFTER"
| "T_BEFORE"
| "T_CONTAINS"
| "T_DISJOINT"
| "T_DURING"
| "T_EQUALS"
| "T_FINISHEDBY"
| "T_FINISHES"
| "T_INTERSECTS"
| "T_MEETS"
| "T_METBY"
| "T_OVERLAPPEDBY"
| "T_OVERLAPS"
| "T_STARTEDBY"
| "T_STARTS";
#=============================================================================#
# An array predicate evaluates if two array expressions satisfy the
# condition implied by a standardized array comparison function. If the
# conditions of the array comparison function are met, the function returns
# a Boolean value of true. Otherwise the function returns false.
#=============================================================================#
arrayPredicate = arrayFunction
"(" arrayOperand "," arrayOperand ")";
arrayOperand = arrayExpression
| propertyName
| function;
# An array is a parentheses-delimited, comma-separated list of array
# elements.
arrayExpression = "(" ")"
| "(" arrayElement [ { "," arrayElement } ] ")";
# An array element is either a character literal, a numeric literal,
# a geometric literal, a temporal instance, a property name, a function,
# an arithmetic expression or an array.
arrayElement = characterClause
| numericLiteral
| temporalInstance
| spatialInstance
| arrayExpression
| arithmeticExpression
| booleanExpression
| propertyName
| function;
arrayFunction = "A_EQUALS"
| "A_CONTAINS"
| "A_CONTAINEDBY"
| "A_OVERLAPS";
#=============================================================================#
# An arithmetic expression is an expression composed of an arithmetic
# operand (a property name, a number or a function that returns a number),
# an arithmetic operators (+,-,*,/,%,div,^) and another arithmetic operand.
#=============================================================================#
arithmeticExpression = arithmeticTerm [ {arithmeticOperatorPlusMinus arithmeticTerm} ];
arithmeticOperatorPlusMinus = "+" | "-";
arithmeticTerm = powerTerm [ {arithmeticOperatorMultDiv powerTerm} ];
arithmeticOperatorMultDiv = "*" | "/" | "%" | "div";
powerTerm = arithmeticFactor [ "^" arithmeticFactor ];
arithmeticFactor = "(" arithmeticExpression ")"
| [ "-" ] arithmeticOperand;
arithmeticOperand = numericLiteral
| propertyName
| function;
#=============================================================================#
# Definition of a PROPERTYNAME
# Production copied from: https://www.w3.org/TR/REC-xml/#sec-common-syn,
# "Names and Tokens".
#=============================================================================#
propertyName = identifier | "\"" identifier "\"";
identifier = identifierStart [ { identifierPart } ];
identifierPart = identifierStart
| "." # "\x002E"
| digit # 0-9
| "\x0300".."\x036F" # combining and diacritical marks
| "\x203F".."\x2040"; # ‿ and ⁀
identifierStart = "\x003A" # colon
| "\x005F" # underscore
| "\x0041".."\x005A" # A-Z
| "\x0061".."\x007A" # a-z
| "\x00C0".."\x00D6" # À-Ö Latin-1 Supplement Letters
| "\x00D8".."\x00F6" # Ø-ö Latin-1 Supplement Letters
| "\x00F8".."\x02FF" # ø-ÿ Latin-1 Supplement Letters
| "\x0370".."\x037D" # Ͱ-ͽ Greek and Coptic (without ";")
| "\x037F".."\x1FFE" # See note 1.
| "\x200C".."\x200D" # zero width non-joiner and joiner
| "\x2070".."\x218F" # See note 2.
| "\x2C00".."\x2FEF" # See note 3.
| "\x3001".."\xD7FF" # See note 4.
| "\xF900".."\xFDCF" # See note 5.
| "\xFDF0".."\xFFFD" # See note 6.
| "\x10000".."\xEFFFF"; # See note 7.
# See: https://unicode-table.com/en/blocks/
# Note 1: Greek, Coptic, Cyrillic, Cyrillic Supplement, Armenian, Hebrew,
# Arabic, Syriac, Arabic Supplement, Thaana, NKo, Samaritan, Mandaic,
# Syriac Supplement, Arabic Extended-A, Devanagari, Bengali, Gurmukhi,
# Gujarati, Oriya, Tamil, Telugu, Kannada, Malayalam, Sinhala, Thai,
# Lao, Tibetan, Myanmar, Georgian, Hangul Jamo, Ethiopic, Ethiopic
# Supplement, Cherokee, Unified Canadian Aboriginal Syllabics, Ogham,
# Runic, Tagalog, Hanunoo, Buhid, Tagbanwa, Khmer, Mongolian, Unified
# Canadian Aboriginal Syllabics Extended, Limbu, Tai Le, New Tai Lue,
# Khmer Symbols, Buginese, Tai Tham, Combining Diacritical Marks
# Extended, Balinese, Sundanese, Batak, Lepcha, Ol Chiki, Cyrillic
# Extended C, Georgian Extended, Sundanese Supplement, Vedic
# Extensions, Phonetic Extensions, Phonetic Extensions Supplement,
# Combining Diacritical Marks Supplement, Latin Extended Additional,
# Greek Extended
#
# Note 2: Superscripts and Subscripts, Currency Symbols, Combining Diacritical
# Marks for Symbols, Letterlike Symbols, Number Forms (e.g. Roman
# numbers)
#
# Note 3: Glagolitic, Latin Extended-C, Coptic, Georgian Supplement, Tifinagh,
# Ethiopic Extended, Cyrillic Extended-A, Supplemental Punctuation,
# CJK Radicals Supplement, Kangxi Radicals
#
# Note 4: CJK Symbols and Punctuation Hiragana, Katakana, Bopomofo, Hangul
# Compatibility Jamo, Kanbun, Bopomofo Extended, CJK Strokes, Katakana
# Phonetic Extensions, Enclosed CJK Letters and Months, CJK
# Compatibility, CJK Unified Ideographs Extension A, Yijing Hexagram
# Symbols, CJK Unified Ideographs, Yi Syllables, Yi Radicals, Lisu,
# Vai, Cyrillic Extended-B, Bamum, Modifier Tone Letters, Latin
# Extended-D, Syloti Nagri, Common Indic Number Forms, Phags-pa,
# Saurashtra, Devanagari Extended, Kayah Li, Rejang, Hangul Jamo
# Extended-A, Javanese, Myanmar Extended-B, Cham, Myanmar Extended-A,
# Tai Viet, Meetei Mayek Extensions, Ethiopic Extended-A, Latin
# Extended-E, Cherokee Supplement, Meetei Mayek, Hangul Syllables,
# Hangul Jamo Extended-B
#
# Note 5: CJK Compatibility Ideographs, Alphabetic Presentation Forms,
# Arabic Presentation Forms-A
#
# Note 6: Arabic Presentation Forms-A, Variation Selectors, Vertical Forms,
# Combining Half Marks, CJK Compatibility Forms, Small Form Variants,
# Arabic Presentation Forms-B, Halfwidth and Fullwidth Forms, Specials
#
# Note 7: Linear B Syllabary, Linear B Ideograms, Aegean Numbers, Ancient
# Greek Numbers, Ancient Symbols, Phaistos Disc, Lycian, Carian,
# Coptic Epact Numbers, Old Italic, Gothic, Old Permic, Ugaritic, Old
# Persian, Deseret, Shavian, Osmanya, Osage, Elbasan, Caucasian
# Albanian, Linear A, Cypriot Syllabary, Imperial Aramaic, Palmyrene,
# Nabataean, Hatran, Phoenician, Lydian, Meroitic Hieroglyphs,
# Meroitic Cursive, Kharoshthi, Old South Arabian, Old North Arabian,
# Manichaean, Avestan, Inscriptional Parthian, Inscriptional Pahlavi,
# Psalter Pahlavi, Old Turkic, Old Hungarian, Hanifi Rohingya, Rumi
# Numeral Symbols, Yezidi, Old Sogdian, Sogdian, Chorasmian, Elymaic,
# Brahmi, Kaithi, Sora Sompeng, Chakma, Mahajani, Sharada, Sinhala
# Archaic Numbers, Khojki, Multani, Khudawadi, Grantha, Newa, Tirhuta,
# Siddham, Modi, Mongolian Supplement, Takri, Ahom, Dogra, Warang Citi,
# Dives Akuru, Nandinagari, Zanabazar Square, Soyombo, Pau Cin Hau,
# Bhaiksuki, Marchen, Masaram Gondi, Gunjala Gondi, Makasar, Lisu
# Supplement, Tamil Supplement, Cuneiform, Cuneiform Numbers and
# Punctuation, Early Dynastic Cuneiform, Egyptian Hieroglyphs,
# Egyptian Hieroglyph Format Controls, Anatolian Hieroglyphs,Bamum
# Supplement, Mro, Bassa Vah, Pahawh Hmong, Medefaidrin, Miao,
# Ideographic Symbols and Punctuation, Tangut, Tangut Components,
# Khitan Small Script, Tangut Supplement, Kana Supplement, Kana
# Extended-A, Small Kana Extension, Nushu, Duployan, Shorthand Format
# Controls, Byzantine Musical Symbols, Musical Symbols, Ancient Greek
# Musical Notation, Mayan Numerals, Tai Xuan Jing Symbols, Counting
# Rod Numerals, Mathematical Alphanumeric Symbols, Sutton SignWriting,
# Glagolitic Supplement, Nyiakeng Puachue Hmong, Wancho, Mende Kikakui,
# Adlam, Indic Siyaq Numbers, Ottoman Siyaq Numbers, Arabic
# Mathematical Alphabetic Symbols, Mahjong Tiles, Domino Tiles,
# Playing Cards, Enclosed Alphanumeric Supplement, Enclosed Ideographic
# Supplement, Miscellaneous Symbols and Pictographs, Emoticons (Emoji),
# Ornamental Dingbats, Transport and Map Symbols, Alchemical Symbols,
# Geometric Shapes Extended, Supplemental Arrows-C, Supplemental
# Symbols and Pictographs, Chess Symbols, Symbols and Pictographs
# Extended-A, Symbols for Legacy Computing, CJK Unified Ideographs
# Extension B, CJK Unified Ideographs Extension C, CJK Unified
# Ideographs Extension D, CJK Unified Ideographs Extension E, CJK
# Unified Ideographs Extension F, CJK Compatibility Ideographs
# Supplement, CJK Unified Ideographs Extension G, Tags, Variation
# Selectors Supplement
#=============================================================================#
# Definition of a FUNCTION
#=============================================================================#
function = identifier "(" {argumentList} ")";
argumentList = argument [ { "," argument } ];
argument = characterClause
| numericLiteral
| temporalInstance
| spatialInstance
| arrayExpression
| arithmeticExpression
| booleanExpression
| propertyName
| function;
#=============================================================================#
# Character expression
#=============================================================================#
characterExpression = characterClause
| propertyName
| function;
characterClause = "CASEI" "(" characterExpression ")"
| "ACCENTI" "(" characterExpression ")"
| characterLiteral;
#=============================================================================#
# Definition of CHARACTER literals
#=============================================================================#
characterLiteral = "'" [ {character} ] "'";
character = alpha | digit | whitespace | escapeQuote;
escapeQuote = "''" | "\\'";
# character & digit productions copied from:
# https://www.w3.org/TR/REC-xml/#charsets
#
alpha = "\x0007".."\x0008" # bell, bs
| "\x0021".."\x0026" # !, ", #, $, %, &
| "\x0028".."\x002F" # (, ), *, +, comma, -, ., /
| "\x003A".."\x0084" # --+
| "\x0086".."\x009F" # |
| "\x00A1".."\x167F" # |
| "\x1681".."\x1FFF" # |
| "\x200B".."\x2027" # +-> :,;,<,=,>,?,@,A-Z,[,\,],^,_,`,a-z,...
| "\x202A".."\x202E" # |
| "\x2030".."\x205E" # |
| "\x2060".."\x2FFF" # |
| "\x3001".."\xD7FF" # --+
| "\xE000".."\xFFFD" # See note 8.
| "\x10000".."\x10FFFF"; # See note 9.
# Note 8: Private Use, CJK Compatibility Ideographs, Alphabetic Presentation
# Forms, Arabic Presentation Forms-A, Combining Half Marks, CJK
# Compatibility Forms, Small Form Variants, Arabic Presentation Forms-B,
# Specials, Halfwidth and Fullwidth Forms, Specials
# Note 9: Linear B Syllabary, Linear B Ideograms, Aegean Numbers, Ancient Greek
# Numbers, Ancient Symbols, Phaistos Disc, Lycian, Carian, Coptic
# Epact Numbers, Old Italic, Gothic, Old Permic, Ugaritic, Old Persian,
# Deseret, Shavian, Osmanya, Osage, Elbasan, Caucasian Albanian,
# Vithkuqi, Linear A, Latin Extended-F, Cypriot Syllabary, Imperial
# Aramaic, Palmyrene, Nabataean, Hatran, Phoenician, Lydian, Meroitic
# Hieroglyphs, Meroitic Cursive, Kharoshthi, Old South Arabian, Old
# North Arabian, Manichaean, Avestan, Inscriptional Parthian,
# Inscriptional Pahlavi, Psalter Pahlavi, Old Turkic, Old Hungarian,
# Hanifi Rohingya, Rumi Numeral Symbols, Yezidi, Arabic Extended-C,
# Old Sogdian, Sogdian, Old Uyghur, Chorasmian, Elymaic, Brahmi,
# Kaithi, Sora Sompeng, Chakma, Mahajani, Sharada, Sinhala Archaic
# Numbers, Khojki, Multani, Khudawadi, Grantha, Newa, Tirhuta, Siddham,
# Modi, Mongolian Supplement, Takri, Ahom, Dogra, Warang Citi, Dives
# Akuru, Nandinagari, Zanabazar Square, Soyombo, Unified Canadian
# Aboriginal Syllabics Extended-A, Pau Cin Hau, Devanagari Extended-A,
# Bhaiksuki, Marchen, Masaram Gondi, Gunjala Gondi, Makasar, Kawi,
# Lisu Supplement, Tamil Supplement, Cuneiform, Cuneiform Numbers and
# Punctuation, Early Dynastic Cuneiform, Cypro-Minoan, Egyptian
# Hieroglyphs, Egyptian Hieroglyph Format Controls, Anatolian
# Hieroglyphs, Bamum Supplement, Mro, Tangsa, Bassa Vah, Pahawh Hmong,
# Medefaidrin, Miao, Ideographic Symbols and Punctuation, Tangut,
# Tangut Components, Khitan Small Script, Tangut Supplement, Kana
# Extended-B, Kana Supplement, Kana Extended-A, Small Kana Extension,
# Nushu, Duployan, Shorthand Format Controls, Znamenny Musical Notation,
# Byzantine Musical Symbols, Musical Symbols, Ancient Greek Musical
# Notation, Kaktovik Numerals, Mayan Numerals, Tai Xuan Jing Symbols,
# Counting Rod Numerals, Mathematical Alphanumeric Symbols, Sutton
# SignWriting, Latin Extended-G, Glagolitic Supplement, Cyrillic
# Extended-D, Nyiakeng Puachue Hmong, Toto, Wancho, Nag Mundari,
# Ethiopic Extended-B, Mende Kikakui, Adlam, Indic Siyaq Numbers,
# Ottoman Siyaq Numbers, Arabic Mathematical Alphabetic Symbols,
# Mahjong Tiles, Domino Tiles, Playing Cards, Enclosed Alphanumeric
# Supplement, Enclosed Ideographic Supplement, Miscellaneous Symbols
# and Pictographs, Emoticons, Ornamental Dingbats, Transport and Map
# Symbols, Alchemical Symbols, Geometric Shapes Extended, Supplemental
# Arrows-C, Supplemental Symbols and Pictographs, Chess Symbols, Symbols
# and Pictographs Extended-A, Symbols for Legacy Computing, CJK Unified
# Ideographs Extension B, CJK Unified Ideographs Extension C, CJK
# Unified Ideographs Extension D, CJK Unified Ideographs Extension E,
# CJK Unified Ideographs Extension F, CJK Compatibility Ideographs
# Supplement, CJK Unified Ideographs Extension G, CJK Unified
# Ideographs Extension H, Tags, Variation Selectors Supplement,
# Supplementary Private Use Area-A, Supplementary Private Use Area-B
digit = "\x0030".."\x0039";
whitespace = "\x0009" # Character tabulation
| "\x000A" # Line feed
| "\x000B" # Line tabulation
| "\x000C" # Form feed
| "\x000D" # Carriage return
| "\x0020" # Space
| "\x0085" # Next line
| "\x00A0" # No-break space
| "\x1680" # Ogham space mark
| "\x2000" # En quad
| "\x2001" # Em quad
| "\x2002" # En space
| "\x2003" # Em space
| "\x2004" # Three-per-em space
| "\x2005" # Four-per-em space
| "\x2006" # Six-per-em space
| "\x2007" # Figure space
| "\x2008" # Punctuation space
| "\x2009" # Thin space
| "\x200A" # Hair space
| "\x2028" # Line separator
| "\x2029" # Paragraph separator
| "\x202F" # Narrow no-break space
| "\x205F" # Medium mathematical space
| "\x3000"; # Ideographic space
#=============================================================================#
# Definition of NUMERIC literals
#=============================================================================#
numericLiteral = unsignedNumericLiteral | signedNumericLiteral;
unsignedNumericLiteral = decimalNumericLiteral | scientificNumericLiteral;
signedNumericLiteral = [sign] unsignedNumericLiteral;
decimalNumericLiteral = unsignedInteger [ "." [ unsignedInteger ] ]
| "." unsignedInteger;
scientificNumericLiteral = mantissa "E" exponent;
mantissa = decimalNumericLiteral;
exponent = signedInteger;
signedInteger = [ sign ] unsignedInteger;
unsignedInteger = {digit};
sign = "+" | "-";
#=============================================================================#
# Boolean literal
#=============================================================================#
#
booleanLiteral = "TRUE" | "FALSE";
#=============================================================================#
# Definition of GEOMETRIC literals
#
# NOTE: This is basically BNF that define WKT encoding. It would be nice
# to instead reference some normative BNF for WKT.
#=============================================================================#
spatialInstance = geometryLiteral
| geometryCollectionTaggedText
| bboxTaggedText;
geometryLiteral = pointTaggedText
| linestringTaggedText
| polygonTaggedText
| multipointTaggedText
| multilinestringTaggedText
| multipolygonTaggedText;
pointTaggedText = "POINT" ["Z"] pointText;
linestringTaggedText = "LINESTRING" ["Z"] lineStringText;
polygonTaggedText = "POLYGON" ["Z"] polygonText;
multipointTaggedText = "MULTIPOINT" ["Z"] multiPointText;
multilinestringTaggedText = "MULTILINESTRING" ["Z"] multiLineStringText;
multipolygonTaggedText = "MULTIPOLYGON" ["Z"] multiPolygonText;
geometryCollectionTaggedText = "GEOMETRYCOLLECTION" ["Z"] geometryCollectionText;
pointText = "(" point ")";
point = xCoord yCoord [zCoord];
xCoord = signedNumericLiteral;
yCoord = signedNumericLiteral;
zCoord = signedNumericLiteral;
lineStringText = "(" point "," point {"," point} ")";
linearRingText = emptySet | "(" point "," point "," point "," point {"," point } ")";
polygonText = "(" linearRingText {"," linearRingText} ")";
multiPointText = "(" pointText {"," pointText} ")";
multiLineStringText = "(" lineStringText {"," lineStringText} ")";
multiPolygonText = "(" polygonText {"," polygonText} ")";
geometryCollectionText = "(" geometryLiteral {"," geometryLiteral} ")";
bboxTaggedText = "BBOX" bboxText;
bboxText = "(" westBoundLon "," southBoundLat "," [minElev ","] eastBoundLon "," northBoundLat ["," maxElev] ")";
westBoundLon = signedNumericLiteral;
eastBoundLon = signedNumericLiteral;
northBoundLat = signedNumericLiteral;
southBoundLat = signedNumericLiteral;
minElev = signedNumericLiteral;
maxElev = signedNumericLiteral;
temporalInstance = instantInstance | intervalInstance;
instantInstance = dateInstant | timestampInstant;
dateInstant = "DATE"
"(" dateInstantString ")";
dateInstantString = "'" fullDate "'";
timestampInstant = "TIMESTAMP"
"(" timestampInstantString ")";
timestampInstantString = "'" fullDate "T" utcTime "'";
intervalInstance = "INTERVAL" "(" instantParameter "," instantParameter ")";
instantParameter = dateInstantString
| timestampInstantString
| "'..'"
| propertyName
| function;
fullDate = dateYear "-" dateMonth "-" dateDay;
dateYear = digit digit digit digit;
dateMonth = digit digit;
dateDay = digit digit;
utcTime = timeHour ":" timeMinute ":" timeSecond "Z";
timeHour = digit digit;
timeMinute = digit digit;
timeSecond = digit digit ["." digit {digit}];