From 3f4a980e196f2ad7c5473e1a426b54068dbd58e8 Mon Sep 17 00:00:00 2001 From: Ezequiel Rozen Date: Tue, 9 Jan 2024 14:35:10 -0300 Subject: [PATCH 1/2] [RE-361] Add datetime operator --- parser/JsonQuery.g4 | 5 + parser/JsonQuery.interp | 4 +- parser/JsonQuery.tokens | 19 +- parser/JsonQueryLexer.interp | 5 +- parser/JsonQueryLexer.tokens | 19 +- parser/datetime_operation.go | 86 +++++++++ parser/evaluate.go | 11 +- parser/jsonquery_lexer.go | 310 ++++++++++++++++--------------- parser/jsonquery_parser.go | 264 +++++++++++++++----------- parser/jsonquery_visitor.go | 3 + parser/jsonquery_visitor_impl.go | 12 ++ parser/parse_logical_test.go | 57 ++++++ parser/parse_simple_test.go | 240 ++++++++++++++++++++++++ 13 files changed, 749 insertions(+), 286 deletions(-) create mode 100644 parser/datetime_operation.go diff --git a/parser/JsonQuery.g4 b/parser/JsonQuery.g4 index 82024ae..2ed6401 100644 --- a/parser/JsonQuery.g4 +++ b/parser/JsonQuery.g4 @@ -69,12 +69,17 @@ value | VERSION #version | STRING #string | DOUBLE #double + | DATETIME #datetime | '-'? INT EXP? #long | listInts #listOfInts | listDoubles #listOfDoubles | listStrings #listOfStrings ; +DATETIME + : DIGIT DIGIT DIGIT DIGIT '-' DIGIT DIGIT '-' DIGIT DIGIT 'T' DIGIT DIGIT ':' DIGIT DIGIT + ; + VERSION : INT '.' INT '.' INT ; diff --git a/parser/JsonQuery.interp b/parser/JsonQuery.interp index 90366fd..1227293 100644 --- a/parser/JsonQuery.interp +++ b/parser/JsonQuery.interp @@ -31,6 +31,7 @@ null null null null +null '\n' null null @@ -63,6 +64,7 @@ PLUS MINUS DIVISON ATTRNAME +DATETIME VERSION STRING DOUBLE @@ -88,4 +90,4 @@ subListOfInts atn: -[4, 1, 34, 137, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 2, 5, 7, 5, 2, 6, 7, 6, 2, 7, 7, 7, 2, 8, 7, 8, 2, 9, 7, 9, 2, 10, 7, 10, 2, 11, 7, 11, 1, 0, 1, 0, 3, 0, 27, 8, 0, 1, 0, 3, 0, 30, 8, 0, 1, 0, 1, 0, 3, 0, 34, 8, 0, 1, 0, 1, 0, 3, 0, 38, 8, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 3, 0, 62, 8, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 5, 0, 69, 8, 0, 10, 0, 12, 0, 72, 9, 0, 1, 1, 1, 1, 3, 1, 76, 8, 1, 1, 2, 1, 2, 1, 2, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 3, 3, 87, 8, 3, 1, 3, 1, 3, 3, 3, 91, 8, 3, 1, 3, 1, 3, 1, 3, 3, 3, 96, 8, 3, 1, 4, 1, 4, 1, 4, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 3, 5, 106, 8, 5, 1, 6, 1, 6, 1, 6, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 3, 7, 116, 8, 7, 1, 8, 1, 8, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 3, 9, 125, 8, 9, 1, 10, 1, 10, 1, 10, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 3, 11, 135, 8, 11, 1, 11, 0, 1, 0, 12, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 0, 3, 1, 0, 12, 21, 1, 0, 22, 25, 1, 0, 13, 18, 147, 0, 61, 1, 0, 0, 0, 2, 73, 1, 0, 0, 0, 4, 77, 1, 0, 0, 0, 6, 95, 1, 0, 0, 0, 8, 97, 1, 0, 0, 0, 10, 105, 1, 0, 0, 0, 12, 107, 1, 0, 0, 0, 14, 115, 1, 0, 0, 0, 16, 117, 1, 0, 0, 0, 18, 124, 1, 0, 0, 0, 20, 126, 1, 0, 0, 0, 22, 134, 1, 0, 0, 0, 24, 26, 6, 0, -1, 0, 25, 27, 5, 8, 0, 0, 26, 25, 1, 0, 0, 0, 26, 27, 1, 0, 0, 0, 27, 29, 1, 0, 0, 0, 28, 30, 5, 34, 0, 0, 29, 28, 1, 0, 0, 0, 29, 30, 1, 0, 0, 0, 30, 31, 1, 0, 0, 0, 31, 33, 5, 1, 0, 0, 32, 34, 5, 34, 0, 0, 33, 32, 1, 0, 0, 0, 33, 34, 1, 0, 0, 0, 34, 35, 1, 0, 0, 0, 35, 37, 3, 0, 0, 0, 36, 38, 5, 34, 0, 0, 37, 36, 1, 0, 0, 0, 37, 38, 1, 0, 0, 0, 38, 39, 1, 0, 0, 0, 39, 40, 5, 2, 0, 0, 40, 62, 1, 0, 0, 0, 41, 42, 3, 2, 1, 0, 42, 43, 5, 34, 0, 0, 43, 44, 5, 3, 0, 0, 44, 62, 1, 0, 0, 0, 45, 46, 3, 2, 1, 0, 46, 47, 5, 34, 0, 0, 47, 48, 7, 0, 0, 0, 48, 49, 5, 34, 0, 0, 49, 50, 3, 6, 3, 0, 50, 62, 1, 0, 0, 0, 51, 52, 7, 1, 0, 0, 52, 53, 5, 34, 0, 0, 53, 54, 5, 1, 0, 0, 54, 55, 3, 16, 8, 0, 55, 56, 5, 2, 0, 0, 56, 57, 5, 34, 0, 0, 57, 58, 7, 2, 0, 0, 58, 59, 5, 34, 0, 0, 59, 60, 3, 6, 3, 0, 60, 62, 1, 0, 0, 0, 61, 24, 1, 0, 0, 0, 61, 41, 1, 0, 0, 0, 61, 45, 1, 0, 0, 0, 61, 51, 1, 0, 0, 0, 62, 70, 1, 0, 0, 0, 63, 64, 10, 4, 0, 0, 64, 65, 5, 34, 0, 0, 65, 66, 5, 9, 0, 0, 66, 67, 5, 34, 0, 0, 67, 69, 3, 0, 0, 5, 68, 63, 1, 0, 0, 0, 69, 72, 1, 0, 0, 0, 70, 68, 1, 0, 0, 0, 70, 71, 1, 0, 0, 0, 71, 1, 1, 0, 0, 0, 72, 70, 1, 0, 0, 0, 73, 75, 5, 26, 0, 0, 74, 76, 3, 4, 2, 0, 75, 74, 1, 0, 0, 0, 75, 76, 1, 0, 0, 0, 76, 3, 1, 0, 0, 0, 77, 78, 5, 4, 0, 0, 78, 79, 3, 2, 1, 0, 79, 5, 1, 0, 0, 0, 80, 96, 5, 10, 0, 0, 81, 96, 5, 11, 0, 0, 82, 96, 5, 27, 0, 0, 83, 96, 5, 28, 0, 0, 84, 96, 5, 29, 0, 0, 85, 87, 5, 5, 0, 0, 86, 85, 1, 0, 0, 0, 86, 87, 1, 0, 0, 0, 87, 88, 1, 0, 0, 0, 88, 90, 5, 30, 0, 0, 89, 91, 5, 31, 0, 0, 90, 89, 1, 0, 0, 0, 90, 91, 1, 0, 0, 0, 91, 96, 1, 0, 0, 0, 92, 96, 3, 20, 10, 0, 93, 96, 3, 12, 6, 0, 94, 96, 3, 8, 4, 0, 95, 80, 1, 0, 0, 0, 95, 81, 1, 0, 0, 0, 95, 82, 1, 0, 0, 0, 95, 83, 1, 0, 0, 0, 95, 84, 1, 0, 0, 0, 95, 86, 1, 0, 0, 0, 95, 92, 1, 0, 0, 0, 95, 93, 1, 0, 0, 0, 95, 94, 1, 0, 0, 0, 96, 7, 1, 0, 0, 0, 97, 98, 5, 6, 0, 0, 98, 99, 3, 10, 5, 0, 99, 9, 1, 0, 0, 0, 100, 101, 5, 28, 0, 0, 101, 102, 5, 33, 0, 0, 102, 106, 3, 10, 5, 0, 103, 104, 5, 28, 0, 0, 104, 106, 5, 7, 0, 0, 105, 100, 1, 0, 0, 0, 105, 103, 1, 0, 0, 0, 106, 11, 1, 0, 0, 0, 107, 108, 5, 6, 0, 0, 108, 109, 3, 14, 7, 0, 109, 13, 1, 0, 0, 0, 110, 111, 5, 29, 0, 0, 111, 112, 5, 33, 0, 0, 112, 116, 3, 14, 7, 0, 113, 114, 5, 29, 0, 0, 114, 116, 5, 7, 0, 0, 115, 110, 1, 0, 0, 0, 115, 113, 1, 0, 0, 0, 116, 15, 1, 0, 0, 0, 117, 118, 3, 18, 9, 0, 118, 17, 1, 0, 0, 0, 119, 120, 3, 2, 1, 0, 120, 121, 5, 33, 0, 0, 121, 122, 3, 18, 9, 0, 122, 125, 1, 0, 0, 0, 123, 125, 3, 2, 1, 0, 124, 119, 1, 0, 0, 0, 124, 123, 1, 0, 0, 0, 125, 19, 1, 0, 0, 0, 126, 127, 5, 6, 0, 0, 127, 128, 3, 22, 11, 0, 128, 21, 1, 0, 0, 0, 129, 130, 5, 30, 0, 0, 130, 131, 5, 33, 0, 0, 131, 135, 3, 22, 11, 0, 132, 133, 5, 30, 0, 0, 133, 135, 5, 7, 0, 0, 134, 129, 1, 0, 0, 0, 134, 132, 1, 0, 0, 0, 135, 23, 1, 0, 0, 0, 14, 26, 29, 33, 37, 61, 70, 75, 86, 90, 95, 105, 115, 124, 134] \ No newline at end of file +[4, 1, 35, 138, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 2, 5, 7, 5, 2, 6, 7, 6, 2, 7, 7, 7, 2, 8, 7, 8, 2, 9, 7, 9, 2, 10, 7, 10, 2, 11, 7, 11, 1, 0, 1, 0, 3, 0, 27, 8, 0, 1, 0, 3, 0, 30, 8, 0, 1, 0, 1, 0, 3, 0, 34, 8, 0, 1, 0, 1, 0, 3, 0, 38, 8, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 3, 0, 62, 8, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 5, 0, 69, 8, 0, 10, 0, 12, 0, 72, 9, 0, 1, 1, 1, 1, 3, 1, 76, 8, 1, 1, 2, 1, 2, 1, 2, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 3, 3, 88, 8, 3, 1, 3, 1, 3, 3, 3, 92, 8, 3, 1, 3, 1, 3, 1, 3, 3, 3, 97, 8, 3, 1, 4, 1, 4, 1, 4, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 3, 5, 107, 8, 5, 1, 6, 1, 6, 1, 6, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 3, 7, 117, 8, 7, 1, 8, 1, 8, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 3, 9, 126, 8, 9, 1, 10, 1, 10, 1, 10, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 3, 11, 136, 8, 11, 1, 11, 0, 1, 0, 12, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 0, 3, 1, 0, 12, 21, 1, 0, 22, 25, 1, 0, 13, 18, 149, 0, 61, 1, 0, 0, 0, 2, 73, 1, 0, 0, 0, 4, 77, 1, 0, 0, 0, 6, 96, 1, 0, 0, 0, 8, 98, 1, 0, 0, 0, 10, 106, 1, 0, 0, 0, 12, 108, 1, 0, 0, 0, 14, 116, 1, 0, 0, 0, 16, 118, 1, 0, 0, 0, 18, 125, 1, 0, 0, 0, 20, 127, 1, 0, 0, 0, 22, 135, 1, 0, 0, 0, 24, 26, 6, 0, -1, 0, 25, 27, 5, 8, 0, 0, 26, 25, 1, 0, 0, 0, 26, 27, 1, 0, 0, 0, 27, 29, 1, 0, 0, 0, 28, 30, 5, 35, 0, 0, 29, 28, 1, 0, 0, 0, 29, 30, 1, 0, 0, 0, 30, 31, 1, 0, 0, 0, 31, 33, 5, 1, 0, 0, 32, 34, 5, 35, 0, 0, 33, 32, 1, 0, 0, 0, 33, 34, 1, 0, 0, 0, 34, 35, 1, 0, 0, 0, 35, 37, 3, 0, 0, 0, 36, 38, 5, 35, 0, 0, 37, 36, 1, 0, 0, 0, 37, 38, 1, 0, 0, 0, 38, 39, 1, 0, 0, 0, 39, 40, 5, 2, 0, 0, 40, 62, 1, 0, 0, 0, 41, 42, 3, 2, 1, 0, 42, 43, 5, 35, 0, 0, 43, 44, 5, 3, 0, 0, 44, 62, 1, 0, 0, 0, 45, 46, 3, 2, 1, 0, 46, 47, 5, 35, 0, 0, 47, 48, 7, 0, 0, 0, 48, 49, 5, 35, 0, 0, 49, 50, 3, 6, 3, 0, 50, 62, 1, 0, 0, 0, 51, 52, 7, 1, 0, 0, 52, 53, 5, 35, 0, 0, 53, 54, 5, 1, 0, 0, 54, 55, 3, 16, 8, 0, 55, 56, 5, 2, 0, 0, 56, 57, 5, 35, 0, 0, 57, 58, 7, 2, 0, 0, 58, 59, 5, 35, 0, 0, 59, 60, 3, 6, 3, 0, 60, 62, 1, 0, 0, 0, 61, 24, 1, 0, 0, 0, 61, 41, 1, 0, 0, 0, 61, 45, 1, 0, 0, 0, 61, 51, 1, 0, 0, 0, 62, 70, 1, 0, 0, 0, 63, 64, 10, 4, 0, 0, 64, 65, 5, 35, 0, 0, 65, 66, 5, 9, 0, 0, 66, 67, 5, 35, 0, 0, 67, 69, 3, 0, 0, 5, 68, 63, 1, 0, 0, 0, 69, 72, 1, 0, 0, 0, 70, 68, 1, 0, 0, 0, 70, 71, 1, 0, 0, 0, 71, 1, 1, 0, 0, 0, 72, 70, 1, 0, 0, 0, 73, 75, 5, 26, 0, 0, 74, 76, 3, 4, 2, 0, 75, 74, 1, 0, 0, 0, 75, 76, 1, 0, 0, 0, 76, 3, 1, 0, 0, 0, 77, 78, 5, 4, 0, 0, 78, 79, 3, 2, 1, 0, 79, 5, 1, 0, 0, 0, 80, 97, 5, 10, 0, 0, 81, 97, 5, 11, 0, 0, 82, 97, 5, 28, 0, 0, 83, 97, 5, 29, 0, 0, 84, 97, 5, 30, 0, 0, 85, 97, 5, 27, 0, 0, 86, 88, 5, 5, 0, 0, 87, 86, 1, 0, 0, 0, 87, 88, 1, 0, 0, 0, 88, 89, 1, 0, 0, 0, 89, 91, 5, 31, 0, 0, 90, 92, 5, 32, 0, 0, 91, 90, 1, 0, 0, 0, 91, 92, 1, 0, 0, 0, 92, 97, 1, 0, 0, 0, 93, 97, 3, 20, 10, 0, 94, 97, 3, 12, 6, 0, 95, 97, 3, 8, 4, 0, 96, 80, 1, 0, 0, 0, 96, 81, 1, 0, 0, 0, 96, 82, 1, 0, 0, 0, 96, 83, 1, 0, 0, 0, 96, 84, 1, 0, 0, 0, 96, 85, 1, 0, 0, 0, 96, 87, 1, 0, 0, 0, 96, 93, 1, 0, 0, 0, 96, 94, 1, 0, 0, 0, 96, 95, 1, 0, 0, 0, 97, 7, 1, 0, 0, 0, 98, 99, 5, 6, 0, 0, 99, 100, 3, 10, 5, 0, 100, 9, 1, 0, 0, 0, 101, 102, 5, 29, 0, 0, 102, 103, 5, 34, 0, 0, 103, 107, 3, 10, 5, 0, 104, 105, 5, 29, 0, 0, 105, 107, 5, 7, 0, 0, 106, 101, 1, 0, 0, 0, 106, 104, 1, 0, 0, 0, 107, 11, 1, 0, 0, 0, 108, 109, 5, 6, 0, 0, 109, 110, 3, 14, 7, 0, 110, 13, 1, 0, 0, 0, 111, 112, 5, 30, 0, 0, 112, 113, 5, 34, 0, 0, 113, 117, 3, 14, 7, 0, 114, 115, 5, 30, 0, 0, 115, 117, 5, 7, 0, 0, 116, 111, 1, 0, 0, 0, 116, 114, 1, 0, 0, 0, 117, 15, 1, 0, 0, 0, 118, 119, 3, 18, 9, 0, 119, 17, 1, 0, 0, 0, 120, 121, 3, 2, 1, 0, 121, 122, 5, 34, 0, 0, 122, 123, 3, 18, 9, 0, 123, 126, 1, 0, 0, 0, 124, 126, 3, 2, 1, 0, 125, 120, 1, 0, 0, 0, 125, 124, 1, 0, 0, 0, 126, 19, 1, 0, 0, 0, 127, 128, 5, 6, 0, 0, 128, 129, 3, 22, 11, 0, 129, 21, 1, 0, 0, 0, 130, 131, 5, 31, 0, 0, 131, 132, 5, 34, 0, 0, 132, 136, 3, 22, 11, 0, 133, 134, 5, 31, 0, 0, 134, 136, 5, 7, 0, 0, 135, 130, 1, 0, 0, 0, 135, 133, 1, 0, 0, 0, 136, 23, 1, 0, 0, 0, 14, 26, 29, 33, 37, 61, 70, 75, 87, 91, 96, 106, 116, 125, 135] \ No newline at end of file diff --git a/parser/JsonQuery.tokens b/parser/JsonQuery.tokens index 5f9a87c..9f833df 100644 --- a/parser/JsonQuery.tokens +++ b/parser/JsonQuery.tokens @@ -24,14 +24,15 @@ PLUS=23 MINUS=24 DIVISON=25 ATTRNAME=26 -VERSION=27 -STRING=28 -DOUBLE=29 -INT=30 -EXP=31 -NEWLINE=32 -COMMA=33 -SP=34 +DATETIME=27 +VERSION=28 +STRING=29 +DOUBLE=30 +INT=31 +EXP=32 +NEWLINE=33 +COMMA=34 +SP=35 '('=1 ')'=2 'pr'=3 @@ -44,4 +45,4 @@ SP=34 'SUM'=23 'SUBTRACT'=24 'DIV'=25 -'\n'=32 +'\n'=33 diff --git a/parser/JsonQueryLexer.interp b/parser/JsonQueryLexer.interp index a792d41..214a85b 100644 --- a/parser/JsonQueryLexer.interp +++ b/parser/JsonQueryLexer.interp @@ -31,6 +31,7 @@ null null null null +null '\n' null null @@ -63,6 +64,7 @@ PLUS MINUS DIVISON ATTRNAME +DATETIME VERSION STRING DOUBLE @@ -102,6 +104,7 @@ ATTRNAME ATTR_NAME_CHAR DIGIT ALPHA +DATETIME VERSION STRING ESC @@ -122,4 +125,4 @@ mode names: DEFAULT_MODE atn: -[4, 0, 34, 309, 6, -1, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 2, 5, 7, 5, 2, 6, 7, 6, 2, 7, 7, 7, 2, 8, 7, 8, 2, 9, 7, 9, 2, 10, 7, 10, 2, 11, 7, 11, 2, 12, 7, 12, 2, 13, 7, 13, 2, 14, 7, 14, 2, 15, 7, 15, 2, 16, 7, 16, 2, 17, 7, 17, 2, 18, 7, 18, 2, 19, 7, 19, 2, 20, 7, 20, 2, 21, 7, 21, 2, 22, 7, 22, 2, 23, 7, 23, 2, 24, 7, 24, 2, 25, 7, 25, 2, 26, 7, 26, 2, 27, 7, 27, 2, 28, 7, 28, 2, 29, 7, 29, 2, 30, 7, 30, 2, 31, 7, 31, 2, 32, 7, 32, 2, 33, 7, 33, 2, 34, 7, 34, 2, 35, 7, 35, 2, 36, 7, 36, 2, 37, 7, 37, 2, 38, 7, 38, 2, 39, 7, 39, 1, 0, 1, 0, 1, 1, 1, 1, 1, 2, 1, 2, 1, 2, 1, 3, 1, 3, 1, 4, 1, 4, 1, 5, 1, 5, 1, 6, 1, 6, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 3, 7, 103, 8, 7, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 3, 8, 110, 8, 8, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 3, 9, 121, 8, 9, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 11, 1, 11, 1, 11, 1, 11, 3, 11, 132, 8, 11, 1, 12, 1, 12, 1, 12, 1, 12, 1, 12, 1, 12, 3, 12, 140, 8, 12, 1, 13, 1, 13, 1, 13, 1, 13, 1, 13, 1, 13, 3, 13, 148, 8, 13, 1, 14, 1, 14, 1, 14, 1, 14, 1, 14, 3, 14, 155, 8, 14, 1, 15, 1, 15, 1, 15, 1, 15, 1, 15, 3, 15, 162, 8, 15, 1, 16, 1, 16, 1, 16, 1, 16, 1, 16, 1, 16, 3, 16, 170, 8, 16, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 3, 17, 178, 8, 17, 1, 18, 1, 18, 1, 18, 1, 18, 3, 18, 184, 8, 18, 1, 19, 1, 19, 1, 19, 1, 19, 3, 19, 190, 8, 19, 1, 20, 1, 20, 1, 20, 1, 20, 3, 20, 196, 8, 20, 1, 21, 1, 21, 1, 21, 1, 21, 1, 22, 1, 22, 1, 22, 1, 22, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 24, 1, 24, 1, 24, 1, 24, 1, 25, 1, 25, 5, 25, 221, 8, 25, 10, 25, 12, 25, 224, 9, 25, 1, 26, 1, 26, 1, 26, 1, 26, 3, 26, 230, 8, 26, 1, 27, 1, 27, 1, 28, 1, 28, 1, 29, 1, 29, 1, 29, 1, 29, 1, 29, 1, 29, 1, 30, 1, 30, 1, 30, 5, 30, 245, 8, 30, 10, 30, 12, 30, 248, 9, 30, 1, 30, 1, 30, 1, 31, 1, 31, 1, 31, 3, 31, 255, 8, 31, 1, 32, 1, 32, 1, 32, 1, 32, 1, 32, 1, 32, 1, 33, 1, 33, 1, 34, 3, 34, 266, 8, 34, 1, 34, 1, 34, 1, 34, 4, 34, 271, 8, 34, 11, 34, 12, 34, 272, 1, 34, 3, 34, 276, 8, 34, 1, 35, 1, 35, 1, 35, 5, 35, 281, 8, 35, 10, 35, 12, 35, 284, 9, 35, 3, 35, 286, 8, 35, 1, 36, 1, 36, 3, 36, 290, 8, 36, 1, 36, 1, 36, 1, 37, 1, 37, 1, 38, 1, 38, 5, 38, 298, 8, 38, 10, 38, 12, 38, 301, 9, 38, 1, 39, 1, 39, 5, 39, 305, 8, 39, 10, 39, 12, 39, 308, 9, 39, 0, 0, 40, 1, 1, 3, 2, 5, 3, 7, 4, 9, 5, 11, 6, 13, 7, 15, 8, 17, 9, 19, 10, 21, 11, 23, 12, 25, 13, 27, 14, 29, 15, 31, 16, 33, 17, 35, 18, 37, 19, 39, 20, 41, 21, 43, 22, 45, 23, 47, 24, 49, 25, 51, 26, 53, 0, 55, 0, 57, 0, 59, 27, 61, 28, 63, 0, 65, 0, 67, 0, 69, 29, 71, 30, 73, 31, 75, 32, 77, 33, 79, 34, 1, 0, 9, 3, 0, 45, 45, 58, 58, 95, 95, 2, 0, 65, 90, 97, 122, 2, 0, 34, 34, 92, 92, 8, 0, 34, 34, 47, 47, 92, 92, 98, 98, 102, 102, 110, 110, 114, 114, 116, 116, 3, 0, 48, 57, 65, 70, 97, 102, 1, 0, 48, 57, 1, 0, 49, 57, 2, 0, 69, 69, 101, 101, 2, 0, 43, 43, 45, 45, 336, 0, 1, 1, 0, 0, 0, 0, 3, 1, 0, 0, 0, 0, 5, 1, 0, 0, 0, 0, 7, 1, 0, 0, 0, 0, 9, 1, 0, 0, 0, 0, 11, 1, 0, 0, 0, 0, 13, 1, 0, 0, 0, 0, 15, 1, 0, 0, 0, 0, 17, 1, 0, 0, 0, 0, 19, 1, 0, 0, 0, 0, 21, 1, 0, 0, 0, 0, 23, 1, 0, 0, 0, 0, 25, 1, 0, 0, 0, 0, 27, 1, 0, 0, 0, 0, 29, 1, 0, 0, 0, 0, 31, 1, 0, 0, 0, 0, 33, 1, 0, 0, 0, 0, 35, 1, 0, 0, 0, 0, 37, 1, 0, 0, 0, 0, 39, 1, 0, 0, 0, 0, 41, 1, 0, 0, 0, 0, 43, 1, 0, 0, 0, 0, 45, 1, 0, 0, 0, 0, 47, 1, 0, 0, 0, 0, 49, 1, 0, 0, 0, 0, 51, 1, 0, 0, 0, 0, 59, 1, 0, 0, 0, 0, 61, 1, 0, 0, 0, 0, 69, 1, 0, 0, 0, 0, 71, 1, 0, 0, 0, 0, 73, 1, 0, 0, 0, 0, 75, 1, 0, 0, 0, 0, 77, 1, 0, 0, 0, 0, 79, 1, 0, 0, 0, 1, 81, 1, 0, 0, 0, 3, 83, 1, 0, 0, 0, 5, 85, 1, 0, 0, 0, 7, 88, 1, 0, 0, 0, 9, 90, 1, 0, 0, 0, 11, 92, 1, 0, 0, 0, 13, 94, 1, 0, 0, 0, 15, 102, 1, 0, 0, 0, 17, 109, 1, 0, 0, 0, 19, 120, 1, 0, 0, 0, 21, 122, 1, 0, 0, 0, 23, 131, 1, 0, 0, 0, 25, 139, 1, 0, 0, 0, 27, 147, 1, 0, 0, 0, 29, 154, 1, 0, 0, 0, 31, 161, 1, 0, 0, 0, 33, 169, 1, 0, 0, 0, 35, 177, 1, 0, 0, 0, 37, 183, 1, 0, 0, 0, 39, 189, 1, 0, 0, 0, 41, 195, 1, 0, 0, 0, 43, 197, 1, 0, 0, 0, 45, 201, 1, 0, 0, 0, 47, 205, 1, 0, 0, 0, 49, 214, 1, 0, 0, 0, 51, 218, 1, 0, 0, 0, 53, 229, 1, 0, 0, 0, 55, 231, 1, 0, 0, 0, 57, 233, 1, 0, 0, 0, 59, 235, 1, 0, 0, 0, 61, 241, 1, 0, 0, 0, 63, 251, 1, 0, 0, 0, 65, 256, 1, 0, 0, 0, 67, 262, 1, 0, 0, 0, 69, 265, 1, 0, 0, 0, 71, 285, 1, 0, 0, 0, 73, 287, 1, 0, 0, 0, 75, 293, 1, 0, 0, 0, 77, 295, 1, 0, 0, 0, 79, 302, 1, 0, 0, 0, 81, 82, 5, 40, 0, 0, 82, 2, 1, 0, 0, 0, 83, 84, 5, 41, 0, 0, 84, 4, 1, 0, 0, 0, 85, 86, 5, 112, 0, 0, 86, 87, 5, 114, 0, 0, 87, 6, 1, 0, 0, 0, 88, 89, 5, 46, 0, 0, 89, 8, 1, 0, 0, 0, 90, 91, 5, 45, 0, 0, 91, 10, 1, 0, 0, 0, 92, 93, 5, 91, 0, 0, 93, 12, 1, 0, 0, 0, 94, 95, 5, 93, 0, 0, 95, 14, 1, 0, 0, 0, 96, 97, 5, 110, 0, 0, 97, 98, 5, 111, 0, 0, 98, 103, 5, 116, 0, 0, 99, 100, 5, 78, 0, 0, 100, 101, 5, 79, 0, 0, 101, 103, 5, 84, 0, 0, 102, 96, 1, 0, 0, 0, 102, 99, 1, 0, 0, 0, 103, 16, 1, 0, 0, 0, 104, 105, 5, 97, 0, 0, 105, 106, 5, 110, 0, 0, 106, 110, 5, 100, 0, 0, 107, 108, 5, 111, 0, 0, 108, 110, 5, 114, 0, 0, 109, 104, 1, 0, 0, 0, 109, 107, 1, 0, 0, 0, 110, 18, 1, 0, 0, 0, 111, 112, 5, 116, 0, 0, 112, 113, 5, 114, 0, 0, 113, 114, 5, 117, 0, 0, 114, 121, 5, 101, 0, 0, 115, 116, 5, 102, 0, 0, 116, 117, 5, 97, 0, 0, 117, 118, 5, 108, 0, 0, 118, 119, 5, 115, 0, 0, 119, 121, 5, 101, 0, 0, 120, 111, 1, 0, 0, 0, 120, 115, 1, 0, 0, 0, 121, 20, 1, 0, 0, 0, 122, 123, 5, 110, 0, 0, 123, 124, 5, 117, 0, 0, 124, 125, 5, 108, 0, 0, 125, 126, 5, 108, 0, 0, 126, 22, 1, 0, 0, 0, 127, 128, 5, 73, 0, 0, 128, 132, 5, 78, 0, 0, 129, 130, 5, 105, 0, 0, 130, 132, 5, 110, 0, 0, 131, 127, 1, 0, 0, 0, 131, 129, 1, 0, 0, 0, 132, 24, 1, 0, 0, 0, 133, 134, 5, 101, 0, 0, 134, 140, 5, 113, 0, 0, 135, 136, 5, 69, 0, 0, 136, 140, 5, 81, 0, 0, 137, 138, 5, 61, 0, 0, 138, 140, 5, 61, 0, 0, 139, 133, 1, 0, 0, 0, 139, 135, 1, 0, 0, 0, 139, 137, 1, 0, 0, 0, 140, 26, 1, 0, 0, 0, 141, 142, 5, 110, 0, 0, 142, 148, 5, 101, 0, 0, 143, 144, 5, 78, 0, 0, 144, 148, 5, 69, 0, 0, 145, 146, 5, 33, 0, 0, 146, 148, 5, 61, 0, 0, 147, 141, 1, 0, 0, 0, 147, 143, 1, 0, 0, 0, 147, 145, 1, 0, 0, 0, 148, 28, 1, 0, 0, 0, 149, 150, 5, 103, 0, 0, 150, 155, 5, 116, 0, 0, 151, 152, 5, 71, 0, 0, 152, 155, 5, 84, 0, 0, 153, 155, 5, 62, 0, 0, 154, 149, 1, 0, 0, 0, 154, 151, 1, 0, 0, 0, 154, 153, 1, 0, 0, 0, 155, 30, 1, 0, 0, 0, 156, 157, 5, 108, 0, 0, 157, 162, 5, 116, 0, 0, 158, 159, 5, 76, 0, 0, 159, 162, 5, 84, 0, 0, 160, 162, 5, 60, 0, 0, 161, 156, 1, 0, 0, 0, 161, 158, 1, 0, 0, 0, 161, 160, 1, 0, 0, 0, 162, 32, 1, 0, 0, 0, 163, 164, 5, 103, 0, 0, 164, 170, 5, 101, 0, 0, 165, 166, 5, 71, 0, 0, 166, 170, 5, 69, 0, 0, 167, 168, 5, 62, 0, 0, 168, 170, 5, 61, 0, 0, 169, 163, 1, 0, 0, 0, 169, 165, 1, 0, 0, 0, 169, 167, 1, 0, 0, 0, 170, 34, 1, 0, 0, 0, 171, 172, 5, 108, 0, 0, 172, 178, 5, 101, 0, 0, 173, 174, 5, 76, 0, 0, 174, 178, 5, 69, 0, 0, 175, 176, 5, 60, 0, 0, 176, 178, 5, 61, 0, 0, 177, 171, 1, 0, 0, 0, 177, 173, 1, 0, 0, 0, 177, 175, 1, 0, 0, 0, 178, 36, 1, 0, 0, 0, 179, 180, 5, 99, 0, 0, 180, 184, 5, 111, 0, 0, 181, 182, 5, 67, 0, 0, 182, 184, 5, 79, 0, 0, 183, 179, 1, 0, 0, 0, 183, 181, 1, 0, 0, 0, 184, 38, 1, 0, 0, 0, 185, 186, 5, 115, 0, 0, 186, 190, 5, 119, 0, 0, 187, 188, 5, 83, 0, 0, 188, 190, 5, 87, 0, 0, 189, 185, 1, 0, 0, 0, 189, 187, 1, 0, 0, 0, 190, 40, 1, 0, 0, 0, 191, 192, 5, 101, 0, 0, 192, 196, 5, 119, 0, 0, 193, 194, 5, 69, 0, 0, 194, 196, 5, 87, 0, 0, 195, 191, 1, 0, 0, 0, 195, 193, 1, 0, 0, 0, 196, 42, 1, 0, 0, 0, 197, 198, 5, 77, 0, 0, 198, 199, 5, 76, 0, 0, 199, 200, 5, 80, 0, 0, 200, 44, 1, 0, 0, 0, 201, 202, 5, 83, 0, 0, 202, 203, 5, 85, 0, 0, 203, 204, 5, 77, 0, 0, 204, 46, 1, 0, 0, 0, 205, 206, 5, 83, 0, 0, 206, 207, 5, 85, 0, 0, 207, 208, 5, 66, 0, 0, 208, 209, 5, 84, 0, 0, 209, 210, 5, 82, 0, 0, 210, 211, 5, 65, 0, 0, 211, 212, 5, 67, 0, 0, 212, 213, 5, 84, 0, 0, 213, 48, 1, 0, 0, 0, 214, 215, 5, 68, 0, 0, 215, 216, 5, 73, 0, 0, 216, 217, 5, 86, 0, 0, 217, 50, 1, 0, 0, 0, 218, 222, 3, 57, 28, 0, 219, 221, 3, 53, 26, 0, 220, 219, 1, 0, 0, 0, 221, 224, 1, 0, 0, 0, 222, 220, 1, 0, 0, 0, 222, 223, 1, 0, 0, 0, 223, 52, 1, 0, 0, 0, 224, 222, 1, 0, 0, 0, 225, 230, 7, 0, 0, 0, 226, 230, 3, 55, 27, 0, 227, 230, 3, 57, 28, 0, 228, 230, 3, 77, 38, 0, 229, 225, 1, 0, 0, 0, 229, 226, 1, 0, 0, 0, 229, 227, 1, 0, 0, 0, 229, 228, 1, 0, 0, 0, 230, 54, 1, 0, 0, 0, 231, 232, 2, 48, 57, 0, 232, 56, 1, 0, 0, 0, 233, 234, 7, 1, 0, 0, 234, 58, 1, 0, 0, 0, 235, 236, 3, 71, 35, 0, 236, 237, 5, 46, 0, 0, 237, 238, 3, 71, 35, 0, 238, 239, 5, 46, 0, 0, 239, 240, 3, 71, 35, 0, 240, 60, 1, 0, 0, 0, 241, 246, 5, 34, 0, 0, 242, 245, 3, 63, 31, 0, 243, 245, 8, 2, 0, 0, 244, 242, 1, 0, 0, 0, 244, 243, 1, 0, 0, 0, 245, 248, 1, 0, 0, 0, 246, 244, 1, 0, 0, 0, 246, 247, 1, 0, 0, 0, 247, 249, 1, 0, 0, 0, 248, 246, 1, 0, 0, 0, 249, 250, 5, 34, 0, 0, 250, 62, 1, 0, 0, 0, 251, 254, 5, 92, 0, 0, 252, 255, 7, 3, 0, 0, 253, 255, 3, 65, 32, 0, 254, 252, 1, 0, 0, 0, 254, 253, 1, 0, 0, 0, 255, 64, 1, 0, 0, 0, 256, 257, 5, 117, 0, 0, 257, 258, 3, 67, 33, 0, 258, 259, 3, 67, 33, 0, 259, 260, 3, 67, 33, 0, 260, 261, 3, 67, 33, 0, 261, 66, 1, 0, 0, 0, 262, 263, 7, 4, 0, 0, 263, 68, 1, 0, 0, 0, 264, 266, 5, 45, 0, 0, 265, 264, 1, 0, 0, 0, 265, 266, 1, 0, 0, 0, 266, 267, 1, 0, 0, 0, 267, 268, 3, 71, 35, 0, 268, 270, 5, 46, 0, 0, 269, 271, 7, 5, 0, 0, 270, 269, 1, 0, 0, 0, 271, 272, 1, 0, 0, 0, 272, 270, 1, 0, 0, 0, 272, 273, 1, 0, 0, 0, 273, 275, 1, 0, 0, 0, 274, 276, 3, 73, 36, 0, 275, 274, 1, 0, 0, 0, 275, 276, 1, 0, 0, 0, 276, 70, 1, 0, 0, 0, 277, 286, 5, 48, 0, 0, 278, 282, 7, 6, 0, 0, 279, 281, 7, 5, 0, 0, 280, 279, 1, 0, 0, 0, 281, 284, 1, 0, 0, 0, 282, 280, 1, 0, 0, 0, 282, 283, 1, 0, 0, 0, 283, 286, 1, 0, 0, 0, 284, 282, 1, 0, 0, 0, 285, 277, 1, 0, 0, 0, 285, 278, 1, 0, 0, 0, 286, 72, 1, 0, 0, 0, 287, 289, 7, 7, 0, 0, 288, 290, 7, 8, 0, 0, 289, 288, 1, 0, 0, 0, 289, 290, 1, 0, 0, 0, 290, 291, 1, 0, 0, 0, 291, 292, 3, 71, 35, 0, 292, 74, 1, 0, 0, 0, 293, 294, 5, 10, 0, 0, 294, 76, 1, 0, 0, 0, 295, 299, 5, 44, 0, 0, 296, 298, 5, 32, 0, 0, 297, 296, 1, 0, 0, 0, 298, 301, 1, 0, 0, 0, 299, 297, 1, 0, 0, 0, 299, 300, 1, 0, 0, 0, 300, 78, 1, 0, 0, 0, 301, 299, 1, 0, 0, 0, 302, 306, 5, 32, 0, 0, 303, 305, 3, 75, 37, 0, 304, 303, 1, 0, 0, 0, 305, 308, 1, 0, 0, 0, 306, 304, 1, 0, 0, 0, 306, 307, 1, 0, 0, 0, 307, 80, 1, 0, 0, 0, 308, 306, 1, 0, 0, 0, 27, 0, 102, 109, 120, 131, 139, 147, 154, 161, 169, 177, 183, 189, 195, 222, 229, 244, 246, 254, 265, 272, 275, 282, 285, 289, 299, 306, 0] \ No newline at end of file +[4, 0, 35, 328, 6, -1, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 2, 5, 7, 5, 2, 6, 7, 6, 2, 7, 7, 7, 2, 8, 7, 8, 2, 9, 7, 9, 2, 10, 7, 10, 2, 11, 7, 11, 2, 12, 7, 12, 2, 13, 7, 13, 2, 14, 7, 14, 2, 15, 7, 15, 2, 16, 7, 16, 2, 17, 7, 17, 2, 18, 7, 18, 2, 19, 7, 19, 2, 20, 7, 20, 2, 21, 7, 21, 2, 22, 7, 22, 2, 23, 7, 23, 2, 24, 7, 24, 2, 25, 7, 25, 2, 26, 7, 26, 2, 27, 7, 27, 2, 28, 7, 28, 2, 29, 7, 29, 2, 30, 7, 30, 2, 31, 7, 31, 2, 32, 7, 32, 2, 33, 7, 33, 2, 34, 7, 34, 2, 35, 7, 35, 2, 36, 7, 36, 2, 37, 7, 37, 2, 38, 7, 38, 2, 39, 7, 39, 2, 40, 7, 40, 1, 0, 1, 0, 1, 1, 1, 1, 1, 2, 1, 2, 1, 2, 1, 3, 1, 3, 1, 4, 1, 4, 1, 5, 1, 5, 1, 6, 1, 6, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 3, 7, 105, 8, 7, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 3, 8, 112, 8, 8, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 3, 9, 123, 8, 9, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 11, 1, 11, 1, 11, 1, 11, 3, 11, 134, 8, 11, 1, 12, 1, 12, 1, 12, 1, 12, 1, 12, 1, 12, 3, 12, 142, 8, 12, 1, 13, 1, 13, 1, 13, 1, 13, 1, 13, 1, 13, 3, 13, 150, 8, 13, 1, 14, 1, 14, 1, 14, 1, 14, 1, 14, 3, 14, 157, 8, 14, 1, 15, 1, 15, 1, 15, 1, 15, 1, 15, 3, 15, 164, 8, 15, 1, 16, 1, 16, 1, 16, 1, 16, 1, 16, 1, 16, 3, 16, 172, 8, 16, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 3, 17, 180, 8, 17, 1, 18, 1, 18, 1, 18, 1, 18, 3, 18, 186, 8, 18, 1, 19, 1, 19, 1, 19, 1, 19, 3, 19, 192, 8, 19, 1, 20, 1, 20, 1, 20, 1, 20, 3, 20, 198, 8, 20, 1, 21, 1, 21, 1, 21, 1, 21, 1, 22, 1, 22, 1, 22, 1, 22, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 24, 1, 24, 1, 24, 1, 24, 1, 25, 1, 25, 5, 25, 223, 8, 25, 10, 25, 12, 25, 226, 9, 25, 1, 26, 1, 26, 1, 26, 1, 26, 3, 26, 232, 8, 26, 1, 27, 1, 27, 1, 28, 1, 28, 1, 29, 1, 29, 1, 29, 1, 29, 1, 29, 1, 29, 1, 29, 1, 29, 1, 29, 1, 29, 1, 29, 1, 29, 1, 29, 1, 29, 1, 29, 1, 29, 1, 29, 1, 30, 1, 30, 1, 30, 1, 30, 1, 30, 1, 30, 1, 31, 1, 31, 1, 31, 5, 31, 264, 8, 31, 10, 31, 12, 31, 267, 9, 31, 1, 31, 1, 31, 1, 32, 1, 32, 1, 32, 3, 32, 274, 8, 32, 1, 33, 1, 33, 1, 33, 1, 33, 1, 33, 1, 33, 1, 34, 1, 34, 1, 35, 3, 35, 285, 8, 35, 1, 35, 1, 35, 1, 35, 4, 35, 290, 8, 35, 11, 35, 12, 35, 291, 1, 35, 3, 35, 295, 8, 35, 1, 36, 1, 36, 1, 36, 5, 36, 300, 8, 36, 10, 36, 12, 36, 303, 9, 36, 3, 36, 305, 8, 36, 1, 37, 1, 37, 3, 37, 309, 8, 37, 1, 37, 1, 37, 1, 38, 1, 38, 1, 39, 1, 39, 5, 39, 317, 8, 39, 10, 39, 12, 39, 320, 9, 39, 1, 40, 1, 40, 5, 40, 324, 8, 40, 10, 40, 12, 40, 327, 9, 40, 0, 0, 41, 1, 1, 3, 2, 5, 3, 7, 4, 9, 5, 11, 6, 13, 7, 15, 8, 17, 9, 19, 10, 21, 11, 23, 12, 25, 13, 27, 14, 29, 15, 31, 16, 33, 17, 35, 18, 37, 19, 39, 20, 41, 21, 43, 22, 45, 23, 47, 24, 49, 25, 51, 26, 53, 0, 55, 0, 57, 0, 59, 27, 61, 28, 63, 29, 65, 0, 67, 0, 69, 0, 71, 30, 73, 31, 75, 32, 77, 33, 79, 34, 81, 35, 1, 0, 9, 3, 0, 45, 45, 58, 58, 95, 95, 2, 0, 65, 90, 97, 122, 2, 0, 34, 34, 92, 92, 8, 0, 34, 34, 47, 47, 92, 92, 98, 98, 102, 102, 110, 110, 114, 114, 116, 116, 3, 0, 48, 57, 65, 70, 97, 102, 1, 0, 48, 57, 1, 0, 49, 57, 2, 0, 69, 69, 101, 101, 2, 0, 43, 43, 45, 45, 355, 0, 1, 1, 0, 0, 0, 0, 3, 1, 0, 0, 0, 0, 5, 1, 0, 0, 0, 0, 7, 1, 0, 0, 0, 0, 9, 1, 0, 0, 0, 0, 11, 1, 0, 0, 0, 0, 13, 1, 0, 0, 0, 0, 15, 1, 0, 0, 0, 0, 17, 1, 0, 0, 0, 0, 19, 1, 0, 0, 0, 0, 21, 1, 0, 0, 0, 0, 23, 1, 0, 0, 0, 0, 25, 1, 0, 0, 0, 0, 27, 1, 0, 0, 0, 0, 29, 1, 0, 0, 0, 0, 31, 1, 0, 0, 0, 0, 33, 1, 0, 0, 0, 0, 35, 1, 0, 0, 0, 0, 37, 1, 0, 0, 0, 0, 39, 1, 0, 0, 0, 0, 41, 1, 0, 0, 0, 0, 43, 1, 0, 0, 0, 0, 45, 1, 0, 0, 0, 0, 47, 1, 0, 0, 0, 0, 49, 1, 0, 0, 0, 0, 51, 1, 0, 0, 0, 0, 59, 1, 0, 0, 0, 0, 61, 1, 0, 0, 0, 0, 63, 1, 0, 0, 0, 0, 71, 1, 0, 0, 0, 0, 73, 1, 0, 0, 0, 0, 75, 1, 0, 0, 0, 0, 77, 1, 0, 0, 0, 0, 79, 1, 0, 0, 0, 0, 81, 1, 0, 0, 0, 1, 83, 1, 0, 0, 0, 3, 85, 1, 0, 0, 0, 5, 87, 1, 0, 0, 0, 7, 90, 1, 0, 0, 0, 9, 92, 1, 0, 0, 0, 11, 94, 1, 0, 0, 0, 13, 96, 1, 0, 0, 0, 15, 104, 1, 0, 0, 0, 17, 111, 1, 0, 0, 0, 19, 122, 1, 0, 0, 0, 21, 124, 1, 0, 0, 0, 23, 133, 1, 0, 0, 0, 25, 141, 1, 0, 0, 0, 27, 149, 1, 0, 0, 0, 29, 156, 1, 0, 0, 0, 31, 163, 1, 0, 0, 0, 33, 171, 1, 0, 0, 0, 35, 179, 1, 0, 0, 0, 37, 185, 1, 0, 0, 0, 39, 191, 1, 0, 0, 0, 41, 197, 1, 0, 0, 0, 43, 199, 1, 0, 0, 0, 45, 203, 1, 0, 0, 0, 47, 207, 1, 0, 0, 0, 49, 216, 1, 0, 0, 0, 51, 220, 1, 0, 0, 0, 53, 231, 1, 0, 0, 0, 55, 233, 1, 0, 0, 0, 57, 235, 1, 0, 0, 0, 59, 237, 1, 0, 0, 0, 61, 254, 1, 0, 0, 0, 63, 260, 1, 0, 0, 0, 65, 270, 1, 0, 0, 0, 67, 275, 1, 0, 0, 0, 69, 281, 1, 0, 0, 0, 71, 284, 1, 0, 0, 0, 73, 304, 1, 0, 0, 0, 75, 306, 1, 0, 0, 0, 77, 312, 1, 0, 0, 0, 79, 314, 1, 0, 0, 0, 81, 321, 1, 0, 0, 0, 83, 84, 5, 40, 0, 0, 84, 2, 1, 0, 0, 0, 85, 86, 5, 41, 0, 0, 86, 4, 1, 0, 0, 0, 87, 88, 5, 112, 0, 0, 88, 89, 5, 114, 0, 0, 89, 6, 1, 0, 0, 0, 90, 91, 5, 46, 0, 0, 91, 8, 1, 0, 0, 0, 92, 93, 5, 45, 0, 0, 93, 10, 1, 0, 0, 0, 94, 95, 5, 91, 0, 0, 95, 12, 1, 0, 0, 0, 96, 97, 5, 93, 0, 0, 97, 14, 1, 0, 0, 0, 98, 99, 5, 110, 0, 0, 99, 100, 5, 111, 0, 0, 100, 105, 5, 116, 0, 0, 101, 102, 5, 78, 0, 0, 102, 103, 5, 79, 0, 0, 103, 105, 5, 84, 0, 0, 104, 98, 1, 0, 0, 0, 104, 101, 1, 0, 0, 0, 105, 16, 1, 0, 0, 0, 106, 107, 5, 97, 0, 0, 107, 108, 5, 110, 0, 0, 108, 112, 5, 100, 0, 0, 109, 110, 5, 111, 0, 0, 110, 112, 5, 114, 0, 0, 111, 106, 1, 0, 0, 0, 111, 109, 1, 0, 0, 0, 112, 18, 1, 0, 0, 0, 113, 114, 5, 116, 0, 0, 114, 115, 5, 114, 0, 0, 115, 116, 5, 117, 0, 0, 116, 123, 5, 101, 0, 0, 117, 118, 5, 102, 0, 0, 118, 119, 5, 97, 0, 0, 119, 120, 5, 108, 0, 0, 120, 121, 5, 115, 0, 0, 121, 123, 5, 101, 0, 0, 122, 113, 1, 0, 0, 0, 122, 117, 1, 0, 0, 0, 123, 20, 1, 0, 0, 0, 124, 125, 5, 110, 0, 0, 125, 126, 5, 117, 0, 0, 126, 127, 5, 108, 0, 0, 127, 128, 5, 108, 0, 0, 128, 22, 1, 0, 0, 0, 129, 130, 5, 73, 0, 0, 130, 134, 5, 78, 0, 0, 131, 132, 5, 105, 0, 0, 132, 134, 5, 110, 0, 0, 133, 129, 1, 0, 0, 0, 133, 131, 1, 0, 0, 0, 134, 24, 1, 0, 0, 0, 135, 136, 5, 101, 0, 0, 136, 142, 5, 113, 0, 0, 137, 138, 5, 69, 0, 0, 138, 142, 5, 81, 0, 0, 139, 140, 5, 61, 0, 0, 140, 142, 5, 61, 0, 0, 141, 135, 1, 0, 0, 0, 141, 137, 1, 0, 0, 0, 141, 139, 1, 0, 0, 0, 142, 26, 1, 0, 0, 0, 143, 144, 5, 110, 0, 0, 144, 150, 5, 101, 0, 0, 145, 146, 5, 78, 0, 0, 146, 150, 5, 69, 0, 0, 147, 148, 5, 33, 0, 0, 148, 150, 5, 61, 0, 0, 149, 143, 1, 0, 0, 0, 149, 145, 1, 0, 0, 0, 149, 147, 1, 0, 0, 0, 150, 28, 1, 0, 0, 0, 151, 152, 5, 103, 0, 0, 152, 157, 5, 116, 0, 0, 153, 154, 5, 71, 0, 0, 154, 157, 5, 84, 0, 0, 155, 157, 5, 62, 0, 0, 156, 151, 1, 0, 0, 0, 156, 153, 1, 0, 0, 0, 156, 155, 1, 0, 0, 0, 157, 30, 1, 0, 0, 0, 158, 159, 5, 108, 0, 0, 159, 164, 5, 116, 0, 0, 160, 161, 5, 76, 0, 0, 161, 164, 5, 84, 0, 0, 162, 164, 5, 60, 0, 0, 163, 158, 1, 0, 0, 0, 163, 160, 1, 0, 0, 0, 163, 162, 1, 0, 0, 0, 164, 32, 1, 0, 0, 0, 165, 166, 5, 103, 0, 0, 166, 172, 5, 101, 0, 0, 167, 168, 5, 71, 0, 0, 168, 172, 5, 69, 0, 0, 169, 170, 5, 62, 0, 0, 170, 172, 5, 61, 0, 0, 171, 165, 1, 0, 0, 0, 171, 167, 1, 0, 0, 0, 171, 169, 1, 0, 0, 0, 172, 34, 1, 0, 0, 0, 173, 174, 5, 108, 0, 0, 174, 180, 5, 101, 0, 0, 175, 176, 5, 76, 0, 0, 176, 180, 5, 69, 0, 0, 177, 178, 5, 60, 0, 0, 178, 180, 5, 61, 0, 0, 179, 173, 1, 0, 0, 0, 179, 175, 1, 0, 0, 0, 179, 177, 1, 0, 0, 0, 180, 36, 1, 0, 0, 0, 181, 182, 5, 99, 0, 0, 182, 186, 5, 111, 0, 0, 183, 184, 5, 67, 0, 0, 184, 186, 5, 79, 0, 0, 185, 181, 1, 0, 0, 0, 185, 183, 1, 0, 0, 0, 186, 38, 1, 0, 0, 0, 187, 188, 5, 115, 0, 0, 188, 192, 5, 119, 0, 0, 189, 190, 5, 83, 0, 0, 190, 192, 5, 87, 0, 0, 191, 187, 1, 0, 0, 0, 191, 189, 1, 0, 0, 0, 192, 40, 1, 0, 0, 0, 193, 194, 5, 101, 0, 0, 194, 198, 5, 119, 0, 0, 195, 196, 5, 69, 0, 0, 196, 198, 5, 87, 0, 0, 197, 193, 1, 0, 0, 0, 197, 195, 1, 0, 0, 0, 198, 42, 1, 0, 0, 0, 199, 200, 5, 77, 0, 0, 200, 201, 5, 76, 0, 0, 201, 202, 5, 80, 0, 0, 202, 44, 1, 0, 0, 0, 203, 204, 5, 83, 0, 0, 204, 205, 5, 85, 0, 0, 205, 206, 5, 77, 0, 0, 206, 46, 1, 0, 0, 0, 207, 208, 5, 83, 0, 0, 208, 209, 5, 85, 0, 0, 209, 210, 5, 66, 0, 0, 210, 211, 5, 84, 0, 0, 211, 212, 5, 82, 0, 0, 212, 213, 5, 65, 0, 0, 213, 214, 5, 67, 0, 0, 214, 215, 5, 84, 0, 0, 215, 48, 1, 0, 0, 0, 216, 217, 5, 68, 0, 0, 217, 218, 5, 73, 0, 0, 218, 219, 5, 86, 0, 0, 219, 50, 1, 0, 0, 0, 220, 224, 3, 57, 28, 0, 221, 223, 3, 53, 26, 0, 222, 221, 1, 0, 0, 0, 223, 226, 1, 0, 0, 0, 224, 222, 1, 0, 0, 0, 224, 225, 1, 0, 0, 0, 225, 52, 1, 0, 0, 0, 226, 224, 1, 0, 0, 0, 227, 232, 7, 0, 0, 0, 228, 232, 3, 55, 27, 0, 229, 232, 3, 57, 28, 0, 230, 232, 3, 79, 39, 0, 231, 227, 1, 0, 0, 0, 231, 228, 1, 0, 0, 0, 231, 229, 1, 0, 0, 0, 231, 230, 1, 0, 0, 0, 232, 54, 1, 0, 0, 0, 233, 234, 2, 48, 57, 0, 234, 56, 1, 0, 0, 0, 235, 236, 7, 1, 0, 0, 236, 58, 1, 0, 0, 0, 237, 238, 3, 55, 27, 0, 238, 239, 3, 55, 27, 0, 239, 240, 3, 55, 27, 0, 240, 241, 3, 55, 27, 0, 241, 242, 5, 45, 0, 0, 242, 243, 3, 55, 27, 0, 243, 244, 3, 55, 27, 0, 244, 245, 5, 45, 0, 0, 245, 246, 3, 55, 27, 0, 246, 247, 3, 55, 27, 0, 247, 248, 5, 84, 0, 0, 248, 249, 3, 55, 27, 0, 249, 250, 3, 55, 27, 0, 250, 251, 5, 58, 0, 0, 251, 252, 3, 55, 27, 0, 252, 253, 3, 55, 27, 0, 253, 60, 1, 0, 0, 0, 254, 255, 3, 73, 36, 0, 255, 256, 5, 46, 0, 0, 256, 257, 3, 73, 36, 0, 257, 258, 5, 46, 0, 0, 258, 259, 3, 73, 36, 0, 259, 62, 1, 0, 0, 0, 260, 265, 5, 34, 0, 0, 261, 264, 3, 65, 32, 0, 262, 264, 8, 2, 0, 0, 263, 261, 1, 0, 0, 0, 263, 262, 1, 0, 0, 0, 264, 267, 1, 0, 0, 0, 265, 263, 1, 0, 0, 0, 265, 266, 1, 0, 0, 0, 266, 268, 1, 0, 0, 0, 267, 265, 1, 0, 0, 0, 268, 269, 5, 34, 0, 0, 269, 64, 1, 0, 0, 0, 270, 273, 5, 92, 0, 0, 271, 274, 7, 3, 0, 0, 272, 274, 3, 67, 33, 0, 273, 271, 1, 0, 0, 0, 273, 272, 1, 0, 0, 0, 274, 66, 1, 0, 0, 0, 275, 276, 5, 117, 0, 0, 276, 277, 3, 69, 34, 0, 277, 278, 3, 69, 34, 0, 278, 279, 3, 69, 34, 0, 279, 280, 3, 69, 34, 0, 280, 68, 1, 0, 0, 0, 281, 282, 7, 4, 0, 0, 282, 70, 1, 0, 0, 0, 283, 285, 5, 45, 0, 0, 284, 283, 1, 0, 0, 0, 284, 285, 1, 0, 0, 0, 285, 286, 1, 0, 0, 0, 286, 287, 3, 73, 36, 0, 287, 289, 5, 46, 0, 0, 288, 290, 7, 5, 0, 0, 289, 288, 1, 0, 0, 0, 290, 291, 1, 0, 0, 0, 291, 289, 1, 0, 0, 0, 291, 292, 1, 0, 0, 0, 292, 294, 1, 0, 0, 0, 293, 295, 3, 75, 37, 0, 294, 293, 1, 0, 0, 0, 294, 295, 1, 0, 0, 0, 295, 72, 1, 0, 0, 0, 296, 305, 5, 48, 0, 0, 297, 301, 7, 6, 0, 0, 298, 300, 7, 5, 0, 0, 299, 298, 1, 0, 0, 0, 300, 303, 1, 0, 0, 0, 301, 299, 1, 0, 0, 0, 301, 302, 1, 0, 0, 0, 302, 305, 1, 0, 0, 0, 303, 301, 1, 0, 0, 0, 304, 296, 1, 0, 0, 0, 304, 297, 1, 0, 0, 0, 305, 74, 1, 0, 0, 0, 306, 308, 7, 7, 0, 0, 307, 309, 7, 8, 0, 0, 308, 307, 1, 0, 0, 0, 308, 309, 1, 0, 0, 0, 309, 310, 1, 0, 0, 0, 310, 311, 3, 73, 36, 0, 311, 76, 1, 0, 0, 0, 312, 313, 5, 10, 0, 0, 313, 78, 1, 0, 0, 0, 314, 318, 5, 44, 0, 0, 315, 317, 5, 32, 0, 0, 316, 315, 1, 0, 0, 0, 317, 320, 1, 0, 0, 0, 318, 316, 1, 0, 0, 0, 318, 319, 1, 0, 0, 0, 319, 80, 1, 0, 0, 0, 320, 318, 1, 0, 0, 0, 321, 325, 5, 32, 0, 0, 322, 324, 3, 77, 38, 0, 323, 322, 1, 0, 0, 0, 324, 327, 1, 0, 0, 0, 325, 323, 1, 0, 0, 0, 325, 326, 1, 0, 0, 0, 326, 82, 1, 0, 0, 0, 327, 325, 1, 0, 0, 0, 27, 0, 104, 111, 122, 133, 141, 149, 156, 163, 171, 179, 185, 191, 197, 224, 231, 263, 265, 273, 284, 291, 294, 301, 304, 308, 318, 325, 0] \ No newline at end of file diff --git a/parser/JsonQueryLexer.tokens b/parser/JsonQueryLexer.tokens index 5f9a87c..9f833df 100644 --- a/parser/JsonQueryLexer.tokens +++ b/parser/JsonQueryLexer.tokens @@ -24,14 +24,15 @@ PLUS=23 MINUS=24 DIVISON=25 ATTRNAME=26 -VERSION=27 -STRING=28 -DOUBLE=29 -INT=30 -EXP=31 -NEWLINE=32 -COMMA=33 -SP=34 +DATETIME=27 +VERSION=28 +STRING=29 +DOUBLE=30 +INT=31 +EXP=32 +NEWLINE=33 +COMMA=34 +SP=35 '('=1 ')'=2 'pr'=3 @@ -44,4 +45,4 @@ SP=34 'SUM'=23 'SUBTRACT'=24 'DIV'=25 -'\n'=32 +'\n'=33 diff --git a/parser/datetime_operation.go b/parser/datetime_operation.go new file mode 100644 index 0000000..c772219 --- /dev/null +++ b/parser/datetime_operation.go @@ -0,0 +1,86 @@ +package parser + +import ( + "time" +) + +const timeLayout = "2006-01-02T15:04" + +type DateTimeOperation struct { + NullOperation +} + +func (o *DateTimeOperation) getTime(operand Operand) (time.Time, error) { + switch opVal := operand.(type) { + case string: + return time.Parse(timeLayout, opVal) + case time.Time: + return opVal, nil + default: + return time.Time{}, newErrInvalidOperand(operand, opVal) + } +} + +func (o *DateTimeOperation) get(left Operand, right Operand) (time.Time, time.Time, error) { + if left == nil { + return time.Time{}, time.Time{}, ErrEvalOperandMissing + } + leftVal, err := o.getTime(left) + if err != nil { + return time.Time{}, time.Time{}, err + } + rightVal, err := o.getTime(right) + if err != nil { + return time.Time{}, time.Time{}, err + } + return leftVal, rightVal, nil + +} + +func (o *DateTimeOperation) EQ(left Operand, right Operand) (bool, error) { + l, r, err := o.get(left, right) + if err != nil { + return false, err + } + return l.Equal(r), nil +} + +func (o *DateTimeOperation) NE(left Operand, right Operand) (bool, error) { + l, r, err := o.get(left, right) + if err != nil { + return false, err + } + return !l.Equal(r), nil +} + +func (o *DateTimeOperation) GT(left Operand, right Operand) (bool, error) { + l, r, err := o.get(left, right) + if err != nil { + return false, err + } + return l.After(r), nil +} + +func (o *DateTimeOperation) LT(left Operand, right Operand) (bool, error) { + l, r, err := o.get(left, right) + if err != nil { + return false, err + } + return l.Before(r), nil +} + +func (o *DateTimeOperation) GE(left Operand, right Operand) (bool, error) { + l, r, err := o.get(left, right) + if err != nil { + return false, err + } + return l.After(r) || l.Equal(r), nil +} + +func (o *DateTimeOperation) LE(left Operand, right Operand) (bool, error) { + l, r, err := o.get(left, right) + if err != nil { + return false, err + } + return l.Before(r) || l.Equal(r), nil +} diff --git a/parser/evaluate.go b/parser/evaluate.go index 19a7fe4..6f8b6e5 100644 --- a/parser/evaluate.go +++ b/parser/evaluate.go @@ -2,6 +2,7 @@ package parser import ( "fmt" + "runtime/debug" "github.com/antlr4-go/antlr/v4" ) @@ -19,9 +20,8 @@ func NewEvaluator(rule string) (ret *Evaluator, retErr error) { // antlr lib has panics for exceptions so we have to put a recover here // in the unlikely case there is an exception defer func() { - info := recover() - if info != nil { - retErr = fmt.Errorf("%q", info) + if r := recover(); r != nil { + retErr = fmt.Errorf("stacktrace from panic: \n" + string(debug.Stack())) } }() input := antlr.NewInputStream(rule) @@ -53,9 +53,8 @@ func (e *Evaluator) Process(items map[string]interface{}) (ret bool, retErr erro // antlr lib has panics for exceptions so we have to put a recover here // in the unlikely case there is an exception defer func() { - info := recover() - if info != nil { - retErr = fmt.Errorf("%q", info) + if r := recover(); r != nil { + retErr = fmt.Errorf("stacktrace from panic: \n" + string(debug.Stack())) ret = false } }() diff --git a/parser/jsonquery_lexer.go b/parser/jsonquery_lexer.go index ad7f579..9aa506a 100644 --- a/parser/jsonquery_lexer.go +++ b/parser/jsonquery_lexer.go @@ -45,167 +45,174 @@ func jsonquerylexerLexerInit() { staticData.LiteralNames = []string{ "", "'('", "')'", "'pr'", "'.'", "'-'", "'['", "']'", "", "", "", "'null'", "", "", "", "", "", "", "", "", "", "", "'MLP'", "'SUM'", "'SUBTRACT'", - "'DIV'", "", "", "", "", "", "", "'\\n'", + "'DIV'", "", "", "", "", "", "", "", "'\\n'", } staticData.SymbolicNames = []string{ "", "", "", "", "", "", "", "", "NOT", "LOGICAL_OPERATOR", "BOOLEAN", "NULL", "IN", "EQ", "NE", "GT", "LT", "GE", "LE", "CO", "SW", "EW", - "ASTERISK", "PLUS", "MINUS", "DIVISON", "ATTRNAME", "VERSION", "STRING", - "DOUBLE", "INT", "EXP", "NEWLINE", "COMMA", "SP", + "ASTERISK", "PLUS", "MINUS", "DIVISON", "ATTRNAME", "DATETIME", "VERSION", + "STRING", "DOUBLE", "INT", "EXP", "NEWLINE", "COMMA", "SP", } staticData.RuleNames = []string{ "T__0", "T__1", "T__2", "T__3", "T__4", "T__5", "T__6", "NOT", "LOGICAL_OPERATOR", "BOOLEAN", "NULL", "IN", "EQ", "NE", "GT", "LT", "GE", "LE", "CO", "SW", "EW", "ASTERISK", "PLUS", "MINUS", "DIVISON", "ATTRNAME", "ATTR_NAME_CHAR", - "DIGIT", "ALPHA", "VERSION", "STRING", "ESC", "UNICODE", "HEX", "DOUBLE", - "INT", "EXP", "NEWLINE", "COMMA", "SP", + "DIGIT", "ALPHA", "DATETIME", "VERSION", "STRING", "ESC", "UNICODE", + "HEX", "DOUBLE", "INT", "EXP", "NEWLINE", "COMMA", "SP", } staticData.PredictionContextCache = antlr.NewPredictionContextCache() staticData.serializedATN = []int32{ - 4, 0, 34, 309, 6, -1, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, + 4, 0, 35, 328, 6, -1, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 2, 5, 7, 5, 2, 6, 7, 6, 2, 7, 7, 7, 2, 8, 7, 8, 2, 9, 7, 9, 2, 10, 7, 10, 2, 11, 7, 11, 2, 12, 7, 12, 2, 13, 7, 13, 2, 14, 7, 14, 2, 15, 7, 15, 2, 16, 7, 16, 2, 17, 7, 17, 2, 18, 7, 18, 2, 19, 7, 19, 2, 20, 7, 20, 2, 21, 7, 21, 2, 22, 7, 22, 2, 23, 7, 23, 2, 24, 7, 24, 2, 25, 7, 25, 2, 26, 7, 26, 2, 27, 7, 27, 2, 28, 7, 28, 2, 29, 7, 29, 2, 30, 7, 30, 2, 31, 7, 31, 2, 32, 7, 32, 2, 33, 7, 33, 2, 34, 7, 34, 2, 35, 7, 35, 2, 36, - 7, 36, 2, 37, 7, 37, 2, 38, 7, 38, 2, 39, 7, 39, 1, 0, 1, 0, 1, 1, 1, 1, - 1, 2, 1, 2, 1, 2, 1, 3, 1, 3, 1, 4, 1, 4, 1, 5, 1, 5, 1, 6, 1, 6, 1, 7, - 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 3, 7, 103, 8, 7, 1, 8, 1, 8, 1, 8, 1, 8, - 1, 8, 3, 8, 110, 8, 8, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, - 1, 9, 3, 9, 121, 8, 9, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 11, 1, 11, - 1, 11, 1, 11, 3, 11, 132, 8, 11, 1, 12, 1, 12, 1, 12, 1, 12, 1, 12, 1, - 12, 3, 12, 140, 8, 12, 1, 13, 1, 13, 1, 13, 1, 13, 1, 13, 1, 13, 3, 13, - 148, 8, 13, 1, 14, 1, 14, 1, 14, 1, 14, 1, 14, 3, 14, 155, 8, 14, 1, 15, - 1, 15, 1, 15, 1, 15, 1, 15, 3, 15, 162, 8, 15, 1, 16, 1, 16, 1, 16, 1, - 16, 1, 16, 1, 16, 3, 16, 170, 8, 16, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, - 1, 17, 3, 17, 178, 8, 17, 1, 18, 1, 18, 1, 18, 1, 18, 3, 18, 184, 8, 18, - 1, 19, 1, 19, 1, 19, 1, 19, 3, 19, 190, 8, 19, 1, 20, 1, 20, 1, 20, 1, - 20, 3, 20, 196, 8, 20, 1, 21, 1, 21, 1, 21, 1, 21, 1, 22, 1, 22, 1, 22, - 1, 22, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, - 24, 1, 24, 1, 24, 1, 24, 1, 25, 1, 25, 5, 25, 221, 8, 25, 10, 25, 12, 25, - 224, 9, 25, 1, 26, 1, 26, 1, 26, 1, 26, 3, 26, 230, 8, 26, 1, 27, 1, 27, - 1, 28, 1, 28, 1, 29, 1, 29, 1, 29, 1, 29, 1, 29, 1, 29, 1, 30, 1, 30, 1, - 30, 5, 30, 245, 8, 30, 10, 30, 12, 30, 248, 9, 30, 1, 30, 1, 30, 1, 31, - 1, 31, 1, 31, 3, 31, 255, 8, 31, 1, 32, 1, 32, 1, 32, 1, 32, 1, 32, 1, - 32, 1, 33, 1, 33, 1, 34, 3, 34, 266, 8, 34, 1, 34, 1, 34, 1, 34, 4, 34, - 271, 8, 34, 11, 34, 12, 34, 272, 1, 34, 3, 34, 276, 8, 34, 1, 35, 1, 35, - 1, 35, 5, 35, 281, 8, 35, 10, 35, 12, 35, 284, 9, 35, 3, 35, 286, 8, 35, - 1, 36, 1, 36, 3, 36, 290, 8, 36, 1, 36, 1, 36, 1, 37, 1, 37, 1, 38, 1, - 38, 5, 38, 298, 8, 38, 10, 38, 12, 38, 301, 9, 38, 1, 39, 1, 39, 5, 39, - 305, 8, 39, 10, 39, 12, 39, 308, 9, 39, 0, 0, 40, 1, 1, 3, 2, 5, 3, 7, - 4, 9, 5, 11, 6, 13, 7, 15, 8, 17, 9, 19, 10, 21, 11, 23, 12, 25, 13, 27, - 14, 29, 15, 31, 16, 33, 17, 35, 18, 37, 19, 39, 20, 41, 21, 43, 22, 45, - 23, 47, 24, 49, 25, 51, 26, 53, 0, 55, 0, 57, 0, 59, 27, 61, 28, 63, 0, - 65, 0, 67, 0, 69, 29, 71, 30, 73, 31, 75, 32, 77, 33, 79, 34, 1, 0, 9, - 3, 0, 45, 45, 58, 58, 95, 95, 2, 0, 65, 90, 97, 122, 2, 0, 34, 34, 92, - 92, 8, 0, 34, 34, 47, 47, 92, 92, 98, 98, 102, 102, 110, 110, 114, 114, - 116, 116, 3, 0, 48, 57, 65, 70, 97, 102, 1, 0, 48, 57, 1, 0, 49, 57, 2, - 0, 69, 69, 101, 101, 2, 0, 43, 43, 45, 45, 336, 0, 1, 1, 0, 0, 0, 0, 3, - 1, 0, 0, 0, 0, 5, 1, 0, 0, 0, 0, 7, 1, 0, 0, 0, 0, 9, 1, 0, 0, 0, 0, 11, - 1, 0, 0, 0, 0, 13, 1, 0, 0, 0, 0, 15, 1, 0, 0, 0, 0, 17, 1, 0, 0, 0, 0, - 19, 1, 0, 0, 0, 0, 21, 1, 0, 0, 0, 0, 23, 1, 0, 0, 0, 0, 25, 1, 0, 0, 0, - 0, 27, 1, 0, 0, 0, 0, 29, 1, 0, 0, 0, 0, 31, 1, 0, 0, 0, 0, 33, 1, 0, 0, - 0, 0, 35, 1, 0, 0, 0, 0, 37, 1, 0, 0, 0, 0, 39, 1, 0, 0, 0, 0, 41, 1, 0, - 0, 0, 0, 43, 1, 0, 0, 0, 0, 45, 1, 0, 0, 0, 0, 47, 1, 0, 0, 0, 0, 49, 1, - 0, 0, 0, 0, 51, 1, 0, 0, 0, 0, 59, 1, 0, 0, 0, 0, 61, 1, 0, 0, 0, 0, 69, - 1, 0, 0, 0, 0, 71, 1, 0, 0, 0, 0, 73, 1, 0, 0, 0, 0, 75, 1, 0, 0, 0, 0, - 77, 1, 0, 0, 0, 0, 79, 1, 0, 0, 0, 1, 81, 1, 0, 0, 0, 3, 83, 1, 0, 0, 0, - 5, 85, 1, 0, 0, 0, 7, 88, 1, 0, 0, 0, 9, 90, 1, 0, 0, 0, 11, 92, 1, 0, - 0, 0, 13, 94, 1, 0, 0, 0, 15, 102, 1, 0, 0, 0, 17, 109, 1, 0, 0, 0, 19, - 120, 1, 0, 0, 0, 21, 122, 1, 0, 0, 0, 23, 131, 1, 0, 0, 0, 25, 139, 1, - 0, 0, 0, 27, 147, 1, 0, 0, 0, 29, 154, 1, 0, 0, 0, 31, 161, 1, 0, 0, 0, - 33, 169, 1, 0, 0, 0, 35, 177, 1, 0, 0, 0, 37, 183, 1, 0, 0, 0, 39, 189, - 1, 0, 0, 0, 41, 195, 1, 0, 0, 0, 43, 197, 1, 0, 0, 0, 45, 201, 1, 0, 0, - 0, 47, 205, 1, 0, 0, 0, 49, 214, 1, 0, 0, 0, 51, 218, 1, 0, 0, 0, 53, 229, - 1, 0, 0, 0, 55, 231, 1, 0, 0, 0, 57, 233, 1, 0, 0, 0, 59, 235, 1, 0, 0, - 0, 61, 241, 1, 0, 0, 0, 63, 251, 1, 0, 0, 0, 65, 256, 1, 0, 0, 0, 67, 262, - 1, 0, 0, 0, 69, 265, 1, 0, 0, 0, 71, 285, 1, 0, 0, 0, 73, 287, 1, 0, 0, - 0, 75, 293, 1, 0, 0, 0, 77, 295, 1, 0, 0, 0, 79, 302, 1, 0, 0, 0, 81, 82, - 5, 40, 0, 0, 82, 2, 1, 0, 0, 0, 83, 84, 5, 41, 0, 0, 84, 4, 1, 0, 0, 0, - 85, 86, 5, 112, 0, 0, 86, 87, 5, 114, 0, 0, 87, 6, 1, 0, 0, 0, 88, 89, - 5, 46, 0, 0, 89, 8, 1, 0, 0, 0, 90, 91, 5, 45, 0, 0, 91, 10, 1, 0, 0, 0, - 92, 93, 5, 91, 0, 0, 93, 12, 1, 0, 0, 0, 94, 95, 5, 93, 0, 0, 95, 14, 1, - 0, 0, 0, 96, 97, 5, 110, 0, 0, 97, 98, 5, 111, 0, 0, 98, 103, 5, 116, 0, - 0, 99, 100, 5, 78, 0, 0, 100, 101, 5, 79, 0, 0, 101, 103, 5, 84, 0, 0, - 102, 96, 1, 0, 0, 0, 102, 99, 1, 0, 0, 0, 103, 16, 1, 0, 0, 0, 104, 105, - 5, 97, 0, 0, 105, 106, 5, 110, 0, 0, 106, 110, 5, 100, 0, 0, 107, 108, - 5, 111, 0, 0, 108, 110, 5, 114, 0, 0, 109, 104, 1, 0, 0, 0, 109, 107, 1, - 0, 0, 0, 110, 18, 1, 0, 0, 0, 111, 112, 5, 116, 0, 0, 112, 113, 5, 114, - 0, 0, 113, 114, 5, 117, 0, 0, 114, 121, 5, 101, 0, 0, 115, 116, 5, 102, - 0, 0, 116, 117, 5, 97, 0, 0, 117, 118, 5, 108, 0, 0, 118, 119, 5, 115, - 0, 0, 119, 121, 5, 101, 0, 0, 120, 111, 1, 0, 0, 0, 120, 115, 1, 0, 0, - 0, 121, 20, 1, 0, 0, 0, 122, 123, 5, 110, 0, 0, 123, 124, 5, 117, 0, 0, - 124, 125, 5, 108, 0, 0, 125, 126, 5, 108, 0, 0, 126, 22, 1, 0, 0, 0, 127, - 128, 5, 73, 0, 0, 128, 132, 5, 78, 0, 0, 129, 130, 5, 105, 0, 0, 130, 132, - 5, 110, 0, 0, 131, 127, 1, 0, 0, 0, 131, 129, 1, 0, 0, 0, 132, 24, 1, 0, - 0, 0, 133, 134, 5, 101, 0, 0, 134, 140, 5, 113, 0, 0, 135, 136, 5, 69, - 0, 0, 136, 140, 5, 81, 0, 0, 137, 138, 5, 61, 0, 0, 138, 140, 5, 61, 0, - 0, 139, 133, 1, 0, 0, 0, 139, 135, 1, 0, 0, 0, 139, 137, 1, 0, 0, 0, 140, - 26, 1, 0, 0, 0, 141, 142, 5, 110, 0, 0, 142, 148, 5, 101, 0, 0, 143, 144, - 5, 78, 0, 0, 144, 148, 5, 69, 0, 0, 145, 146, 5, 33, 0, 0, 146, 148, 5, - 61, 0, 0, 147, 141, 1, 0, 0, 0, 147, 143, 1, 0, 0, 0, 147, 145, 1, 0, 0, - 0, 148, 28, 1, 0, 0, 0, 149, 150, 5, 103, 0, 0, 150, 155, 5, 116, 0, 0, - 151, 152, 5, 71, 0, 0, 152, 155, 5, 84, 0, 0, 153, 155, 5, 62, 0, 0, 154, - 149, 1, 0, 0, 0, 154, 151, 1, 0, 0, 0, 154, 153, 1, 0, 0, 0, 155, 30, 1, - 0, 0, 0, 156, 157, 5, 108, 0, 0, 157, 162, 5, 116, 0, 0, 158, 159, 5, 76, - 0, 0, 159, 162, 5, 84, 0, 0, 160, 162, 5, 60, 0, 0, 161, 156, 1, 0, 0, - 0, 161, 158, 1, 0, 0, 0, 161, 160, 1, 0, 0, 0, 162, 32, 1, 0, 0, 0, 163, - 164, 5, 103, 0, 0, 164, 170, 5, 101, 0, 0, 165, 166, 5, 71, 0, 0, 166, - 170, 5, 69, 0, 0, 167, 168, 5, 62, 0, 0, 168, 170, 5, 61, 0, 0, 169, 163, - 1, 0, 0, 0, 169, 165, 1, 0, 0, 0, 169, 167, 1, 0, 0, 0, 170, 34, 1, 0, - 0, 0, 171, 172, 5, 108, 0, 0, 172, 178, 5, 101, 0, 0, 173, 174, 5, 76, - 0, 0, 174, 178, 5, 69, 0, 0, 175, 176, 5, 60, 0, 0, 176, 178, 5, 61, 0, - 0, 177, 171, 1, 0, 0, 0, 177, 173, 1, 0, 0, 0, 177, 175, 1, 0, 0, 0, 178, - 36, 1, 0, 0, 0, 179, 180, 5, 99, 0, 0, 180, 184, 5, 111, 0, 0, 181, 182, - 5, 67, 0, 0, 182, 184, 5, 79, 0, 0, 183, 179, 1, 0, 0, 0, 183, 181, 1, - 0, 0, 0, 184, 38, 1, 0, 0, 0, 185, 186, 5, 115, 0, 0, 186, 190, 5, 119, - 0, 0, 187, 188, 5, 83, 0, 0, 188, 190, 5, 87, 0, 0, 189, 185, 1, 0, 0, - 0, 189, 187, 1, 0, 0, 0, 190, 40, 1, 0, 0, 0, 191, 192, 5, 101, 0, 0, 192, - 196, 5, 119, 0, 0, 193, 194, 5, 69, 0, 0, 194, 196, 5, 87, 0, 0, 195, 191, - 1, 0, 0, 0, 195, 193, 1, 0, 0, 0, 196, 42, 1, 0, 0, 0, 197, 198, 5, 77, - 0, 0, 198, 199, 5, 76, 0, 0, 199, 200, 5, 80, 0, 0, 200, 44, 1, 0, 0, 0, - 201, 202, 5, 83, 0, 0, 202, 203, 5, 85, 0, 0, 203, 204, 5, 77, 0, 0, 204, - 46, 1, 0, 0, 0, 205, 206, 5, 83, 0, 0, 206, 207, 5, 85, 0, 0, 207, 208, - 5, 66, 0, 0, 208, 209, 5, 84, 0, 0, 209, 210, 5, 82, 0, 0, 210, 211, 5, - 65, 0, 0, 211, 212, 5, 67, 0, 0, 212, 213, 5, 84, 0, 0, 213, 48, 1, 0, - 0, 0, 214, 215, 5, 68, 0, 0, 215, 216, 5, 73, 0, 0, 216, 217, 5, 86, 0, - 0, 217, 50, 1, 0, 0, 0, 218, 222, 3, 57, 28, 0, 219, 221, 3, 53, 26, 0, - 220, 219, 1, 0, 0, 0, 221, 224, 1, 0, 0, 0, 222, 220, 1, 0, 0, 0, 222, - 223, 1, 0, 0, 0, 223, 52, 1, 0, 0, 0, 224, 222, 1, 0, 0, 0, 225, 230, 7, - 0, 0, 0, 226, 230, 3, 55, 27, 0, 227, 230, 3, 57, 28, 0, 228, 230, 3, 77, - 38, 0, 229, 225, 1, 0, 0, 0, 229, 226, 1, 0, 0, 0, 229, 227, 1, 0, 0, 0, - 229, 228, 1, 0, 0, 0, 230, 54, 1, 0, 0, 0, 231, 232, 2, 48, 57, 0, 232, - 56, 1, 0, 0, 0, 233, 234, 7, 1, 0, 0, 234, 58, 1, 0, 0, 0, 235, 236, 3, - 71, 35, 0, 236, 237, 5, 46, 0, 0, 237, 238, 3, 71, 35, 0, 238, 239, 5, - 46, 0, 0, 239, 240, 3, 71, 35, 0, 240, 60, 1, 0, 0, 0, 241, 246, 5, 34, - 0, 0, 242, 245, 3, 63, 31, 0, 243, 245, 8, 2, 0, 0, 244, 242, 1, 0, 0, - 0, 244, 243, 1, 0, 0, 0, 245, 248, 1, 0, 0, 0, 246, 244, 1, 0, 0, 0, 246, - 247, 1, 0, 0, 0, 247, 249, 1, 0, 0, 0, 248, 246, 1, 0, 0, 0, 249, 250, - 5, 34, 0, 0, 250, 62, 1, 0, 0, 0, 251, 254, 5, 92, 0, 0, 252, 255, 7, 3, - 0, 0, 253, 255, 3, 65, 32, 0, 254, 252, 1, 0, 0, 0, 254, 253, 1, 0, 0, - 0, 255, 64, 1, 0, 0, 0, 256, 257, 5, 117, 0, 0, 257, 258, 3, 67, 33, 0, - 258, 259, 3, 67, 33, 0, 259, 260, 3, 67, 33, 0, 260, 261, 3, 67, 33, 0, - 261, 66, 1, 0, 0, 0, 262, 263, 7, 4, 0, 0, 263, 68, 1, 0, 0, 0, 264, 266, - 5, 45, 0, 0, 265, 264, 1, 0, 0, 0, 265, 266, 1, 0, 0, 0, 266, 267, 1, 0, - 0, 0, 267, 268, 3, 71, 35, 0, 268, 270, 5, 46, 0, 0, 269, 271, 7, 5, 0, - 0, 270, 269, 1, 0, 0, 0, 271, 272, 1, 0, 0, 0, 272, 270, 1, 0, 0, 0, 272, - 273, 1, 0, 0, 0, 273, 275, 1, 0, 0, 0, 274, 276, 3, 73, 36, 0, 275, 274, - 1, 0, 0, 0, 275, 276, 1, 0, 0, 0, 276, 70, 1, 0, 0, 0, 277, 286, 5, 48, - 0, 0, 278, 282, 7, 6, 0, 0, 279, 281, 7, 5, 0, 0, 280, 279, 1, 0, 0, 0, - 281, 284, 1, 0, 0, 0, 282, 280, 1, 0, 0, 0, 282, 283, 1, 0, 0, 0, 283, - 286, 1, 0, 0, 0, 284, 282, 1, 0, 0, 0, 285, 277, 1, 0, 0, 0, 285, 278, - 1, 0, 0, 0, 286, 72, 1, 0, 0, 0, 287, 289, 7, 7, 0, 0, 288, 290, 7, 8, - 0, 0, 289, 288, 1, 0, 0, 0, 289, 290, 1, 0, 0, 0, 290, 291, 1, 0, 0, 0, - 291, 292, 3, 71, 35, 0, 292, 74, 1, 0, 0, 0, 293, 294, 5, 10, 0, 0, 294, - 76, 1, 0, 0, 0, 295, 299, 5, 44, 0, 0, 296, 298, 5, 32, 0, 0, 297, 296, - 1, 0, 0, 0, 298, 301, 1, 0, 0, 0, 299, 297, 1, 0, 0, 0, 299, 300, 1, 0, - 0, 0, 300, 78, 1, 0, 0, 0, 301, 299, 1, 0, 0, 0, 302, 306, 5, 32, 0, 0, - 303, 305, 3, 75, 37, 0, 304, 303, 1, 0, 0, 0, 305, 308, 1, 0, 0, 0, 306, - 304, 1, 0, 0, 0, 306, 307, 1, 0, 0, 0, 307, 80, 1, 0, 0, 0, 308, 306, 1, - 0, 0, 0, 27, 0, 102, 109, 120, 131, 139, 147, 154, 161, 169, 177, 183, - 189, 195, 222, 229, 244, 246, 254, 265, 272, 275, 282, 285, 289, 299, 306, - 0, + 7, 36, 2, 37, 7, 37, 2, 38, 7, 38, 2, 39, 7, 39, 2, 40, 7, 40, 1, 0, 1, + 0, 1, 1, 1, 1, 1, 2, 1, 2, 1, 2, 1, 3, 1, 3, 1, 4, 1, 4, 1, 5, 1, 5, 1, + 6, 1, 6, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 3, 7, 105, 8, 7, 1, 8, 1, + 8, 1, 8, 1, 8, 1, 8, 3, 8, 112, 8, 8, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, + 9, 1, 9, 1, 9, 1, 9, 3, 9, 123, 8, 9, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, + 1, 11, 1, 11, 1, 11, 1, 11, 3, 11, 134, 8, 11, 1, 12, 1, 12, 1, 12, 1, + 12, 1, 12, 1, 12, 3, 12, 142, 8, 12, 1, 13, 1, 13, 1, 13, 1, 13, 1, 13, + 1, 13, 3, 13, 150, 8, 13, 1, 14, 1, 14, 1, 14, 1, 14, 1, 14, 3, 14, 157, + 8, 14, 1, 15, 1, 15, 1, 15, 1, 15, 1, 15, 3, 15, 164, 8, 15, 1, 16, 1, + 16, 1, 16, 1, 16, 1, 16, 1, 16, 3, 16, 172, 8, 16, 1, 17, 1, 17, 1, 17, + 1, 17, 1, 17, 1, 17, 3, 17, 180, 8, 17, 1, 18, 1, 18, 1, 18, 1, 18, 3, + 18, 186, 8, 18, 1, 19, 1, 19, 1, 19, 1, 19, 3, 19, 192, 8, 19, 1, 20, 1, + 20, 1, 20, 1, 20, 3, 20, 198, 8, 20, 1, 21, 1, 21, 1, 21, 1, 21, 1, 22, + 1, 22, 1, 22, 1, 22, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, + 23, 1, 23, 1, 24, 1, 24, 1, 24, 1, 24, 1, 25, 1, 25, 5, 25, 223, 8, 25, + 10, 25, 12, 25, 226, 9, 25, 1, 26, 1, 26, 1, 26, 1, 26, 3, 26, 232, 8, + 26, 1, 27, 1, 27, 1, 28, 1, 28, 1, 29, 1, 29, 1, 29, 1, 29, 1, 29, 1, 29, + 1, 29, 1, 29, 1, 29, 1, 29, 1, 29, 1, 29, 1, 29, 1, 29, 1, 29, 1, 29, 1, + 29, 1, 30, 1, 30, 1, 30, 1, 30, 1, 30, 1, 30, 1, 31, 1, 31, 1, 31, 5, 31, + 264, 8, 31, 10, 31, 12, 31, 267, 9, 31, 1, 31, 1, 31, 1, 32, 1, 32, 1, + 32, 3, 32, 274, 8, 32, 1, 33, 1, 33, 1, 33, 1, 33, 1, 33, 1, 33, 1, 34, + 1, 34, 1, 35, 3, 35, 285, 8, 35, 1, 35, 1, 35, 1, 35, 4, 35, 290, 8, 35, + 11, 35, 12, 35, 291, 1, 35, 3, 35, 295, 8, 35, 1, 36, 1, 36, 1, 36, 5, + 36, 300, 8, 36, 10, 36, 12, 36, 303, 9, 36, 3, 36, 305, 8, 36, 1, 37, 1, + 37, 3, 37, 309, 8, 37, 1, 37, 1, 37, 1, 38, 1, 38, 1, 39, 1, 39, 5, 39, + 317, 8, 39, 10, 39, 12, 39, 320, 9, 39, 1, 40, 1, 40, 5, 40, 324, 8, 40, + 10, 40, 12, 40, 327, 9, 40, 0, 0, 41, 1, 1, 3, 2, 5, 3, 7, 4, 9, 5, 11, + 6, 13, 7, 15, 8, 17, 9, 19, 10, 21, 11, 23, 12, 25, 13, 27, 14, 29, 15, + 31, 16, 33, 17, 35, 18, 37, 19, 39, 20, 41, 21, 43, 22, 45, 23, 47, 24, + 49, 25, 51, 26, 53, 0, 55, 0, 57, 0, 59, 27, 61, 28, 63, 29, 65, 0, 67, + 0, 69, 0, 71, 30, 73, 31, 75, 32, 77, 33, 79, 34, 81, 35, 1, 0, 9, 3, 0, + 45, 45, 58, 58, 95, 95, 2, 0, 65, 90, 97, 122, 2, 0, 34, 34, 92, 92, 8, + 0, 34, 34, 47, 47, 92, 92, 98, 98, 102, 102, 110, 110, 114, 114, 116, 116, + 3, 0, 48, 57, 65, 70, 97, 102, 1, 0, 48, 57, 1, 0, 49, 57, 2, 0, 69, 69, + 101, 101, 2, 0, 43, 43, 45, 45, 355, 0, 1, 1, 0, 0, 0, 0, 3, 1, 0, 0, 0, + 0, 5, 1, 0, 0, 0, 0, 7, 1, 0, 0, 0, 0, 9, 1, 0, 0, 0, 0, 11, 1, 0, 0, 0, + 0, 13, 1, 0, 0, 0, 0, 15, 1, 0, 0, 0, 0, 17, 1, 0, 0, 0, 0, 19, 1, 0, 0, + 0, 0, 21, 1, 0, 0, 0, 0, 23, 1, 0, 0, 0, 0, 25, 1, 0, 0, 0, 0, 27, 1, 0, + 0, 0, 0, 29, 1, 0, 0, 0, 0, 31, 1, 0, 0, 0, 0, 33, 1, 0, 0, 0, 0, 35, 1, + 0, 0, 0, 0, 37, 1, 0, 0, 0, 0, 39, 1, 0, 0, 0, 0, 41, 1, 0, 0, 0, 0, 43, + 1, 0, 0, 0, 0, 45, 1, 0, 0, 0, 0, 47, 1, 0, 0, 0, 0, 49, 1, 0, 0, 0, 0, + 51, 1, 0, 0, 0, 0, 59, 1, 0, 0, 0, 0, 61, 1, 0, 0, 0, 0, 63, 1, 0, 0, 0, + 0, 71, 1, 0, 0, 0, 0, 73, 1, 0, 0, 0, 0, 75, 1, 0, 0, 0, 0, 77, 1, 0, 0, + 0, 0, 79, 1, 0, 0, 0, 0, 81, 1, 0, 0, 0, 1, 83, 1, 0, 0, 0, 3, 85, 1, 0, + 0, 0, 5, 87, 1, 0, 0, 0, 7, 90, 1, 0, 0, 0, 9, 92, 1, 0, 0, 0, 11, 94, + 1, 0, 0, 0, 13, 96, 1, 0, 0, 0, 15, 104, 1, 0, 0, 0, 17, 111, 1, 0, 0, + 0, 19, 122, 1, 0, 0, 0, 21, 124, 1, 0, 0, 0, 23, 133, 1, 0, 0, 0, 25, 141, + 1, 0, 0, 0, 27, 149, 1, 0, 0, 0, 29, 156, 1, 0, 0, 0, 31, 163, 1, 0, 0, + 0, 33, 171, 1, 0, 0, 0, 35, 179, 1, 0, 0, 0, 37, 185, 1, 0, 0, 0, 39, 191, + 1, 0, 0, 0, 41, 197, 1, 0, 0, 0, 43, 199, 1, 0, 0, 0, 45, 203, 1, 0, 0, + 0, 47, 207, 1, 0, 0, 0, 49, 216, 1, 0, 0, 0, 51, 220, 1, 0, 0, 0, 53, 231, + 1, 0, 0, 0, 55, 233, 1, 0, 0, 0, 57, 235, 1, 0, 0, 0, 59, 237, 1, 0, 0, + 0, 61, 254, 1, 0, 0, 0, 63, 260, 1, 0, 0, 0, 65, 270, 1, 0, 0, 0, 67, 275, + 1, 0, 0, 0, 69, 281, 1, 0, 0, 0, 71, 284, 1, 0, 0, 0, 73, 304, 1, 0, 0, + 0, 75, 306, 1, 0, 0, 0, 77, 312, 1, 0, 0, 0, 79, 314, 1, 0, 0, 0, 81, 321, + 1, 0, 0, 0, 83, 84, 5, 40, 0, 0, 84, 2, 1, 0, 0, 0, 85, 86, 5, 41, 0, 0, + 86, 4, 1, 0, 0, 0, 87, 88, 5, 112, 0, 0, 88, 89, 5, 114, 0, 0, 89, 6, 1, + 0, 0, 0, 90, 91, 5, 46, 0, 0, 91, 8, 1, 0, 0, 0, 92, 93, 5, 45, 0, 0, 93, + 10, 1, 0, 0, 0, 94, 95, 5, 91, 0, 0, 95, 12, 1, 0, 0, 0, 96, 97, 5, 93, + 0, 0, 97, 14, 1, 0, 0, 0, 98, 99, 5, 110, 0, 0, 99, 100, 5, 111, 0, 0, + 100, 105, 5, 116, 0, 0, 101, 102, 5, 78, 0, 0, 102, 103, 5, 79, 0, 0, 103, + 105, 5, 84, 0, 0, 104, 98, 1, 0, 0, 0, 104, 101, 1, 0, 0, 0, 105, 16, 1, + 0, 0, 0, 106, 107, 5, 97, 0, 0, 107, 108, 5, 110, 0, 0, 108, 112, 5, 100, + 0, 0, 109, 110, 5, 111, 0, 0, 110, 112, 5, 114, 0, 0, 111, 106, 1, 0, 0, + 0, 111, 109, 1, 0, 0, 0, 112, 18, 1, 0, 0, 0, 113, 114, 5, 116, 0, 0, 114, + 115, 5, 114, 0, 0, 115, 116, 5, 117, 0, 0, 116, 123, 5, 101, 0, 0, 117, + 118, 5, 102, 0, 0, 118, 119, 5, 97, 0, 0, 119, 120, 5, 108, 0, 0, 120, + 121, 5, 115, 0, 0, 121, 123, 5, 101, 0, 0, 122, 113, 1, 0, 0, 0, 122, 117, + 1, 0, 0, 0, 123, 20, 1, 0, 0, 0, 124, 125, 5, 110, 0, 0, 125, 126, 5, 117, + 0, 0, 126, 127, 5, 108, 0, 0, 127, 128, 5, 108, 0, 0, 128, 22, 1, 0, 0, + 0, 129, 130, 5, 73, 0, 0, 130, 134, 5, 78, 0, 0, 131, 132, 5, 105, 0, 0, + 132, 134, 5, 110, 0, 0, 133, 129, 1, 0, 0, 0, 133, 131, 1, 0, 0, 0, 134, + 24, 1, 0, 0, 0, 135, 136, 5, 101, 0, 0, 136, 142, 5, 113, 0, 0, 137, 138, + 5, 69, 0, 0, 138, 142, 5, 81, 0, 0, 139, 140, 5, 61, 0, 0, 140, 142, 5, + 61, 0, 0, 141, 135, 1, 0, 0, 0, 141, 137, 1, 0, 0, 0, 141, 139, 1, 0, 0, + 0, 142, 26, 1, 0, 0, 0, 143, 144, 5, 110, 0, 0, 144, 150, 5, 101, 0, 0, + 145, 146, 5, 78, 0, 0, 146, 150, 5, 69, 0, 0, 147, 148, 5, 33, 0, 0, 148, + 150, 5, 61, 0, 0, 149, 143, 1, 0, 0, 0, 149, 145, 1, 0, 0, 0, 149, 147, + 1, 0, 0, 0, 150, 28, 1, 0, 0, 0, 151, 152, 5, 103, 0, 0, 152, 157, 5, 116, + 0, 0, 153, 154, 5, 71, 0, 0, 154, 157, 5, 84, 0, 0, 155, 157, 5, 62, 0, + 0, 156, 151, 1, 0, 0, 0, 156, 153, 1, 0, 0, 0, 156, 155, 1, 0, 0, 0, 157, + 30, 1, 0, 0, 0, 158, 159, 5, 108, 0, 0, 159, 164, 5, 116, 0, 0, 160, 161, + 5, 76, 0, 0, 161, 164, 5, 84, 0, 0, 162, 164, 5, 60, 0, 0, 163, 158, 1, + 0, 0, 0, 163, 160, 1, 0, 0, 0, 163, 162, 1, 0, 0, 0, 164, 32, 1, 0, 0, + 0, 165, 166, 5, 103, 0, 0, 166, 172, 5, 101, 0, 0, 167, 168, 5, 71, 0, + 0, 168, 172, 5, 69, 0, 0, 169, 170, 5, 62, 0, 0, 170, 172, 5, 61, 0, 0, + 171, 165, 1, 0, 0, 0, 171, 167, 1, 0, 0, 0, 171, 169, 1, 0, 0, 0, 172, + 34, 1, 0, 0, 0, 173, 174, 5, 108, 0, 0, 174, 180, 5, 101, 0, 0, 175, 176, + 5, 76, 0, 0, 176, 180, 5, 69, 0, 0, 177, 178, 5, 60, 0, 0, 178, 180, 5, + 61, 0, 0, 179, 173, 1, 0, 0, 0, 179, 175, 1, 0, 0, 0, 179, 177, 1, 0, 0, + 0, 180, 36, 1, 0, 0, 0, 181, 182, 5, 99, 0, 0, 182, 186, 5, 111, 0, 0, + 183, 184, 5, 67, 0, 0, 184, 186, 5, 79, 0, 0, 185, 181, 1, 0, 0, 0, 185, + 183, 1, 0, 0, 0, 186, 38, 1, 0, 0, 0, 187, 188, 5, 115, 0, 0, 188, 192, + 5, 119, 0, 0, 189, 190, 5, 83, 0, 0, 190, 192, 5, 87, 0, 0, 191, 187, 1, + 0, 0, 0, 191, 189, 1, 0, 0, 0, 192, 40, 1, 0, 0, 0, 193, 194, 5, 101, 0, + 0, 194, 198, 5, 119, 0, 0, 195, 196, 5, 69, 0, 0, 196, 198, 5, 87, 0, 0, + 197, 193, 1, 0, 0, 0, 197, 195, 1, 0, 0, 0, 198, 42, 1, 0, 0, 0, 199, 200, + 5, 77, 0, 0, 200, 201, 5, 76, 0, 0, 201, 202, 5, 80, 0, 0, 202, 44, 1, + 0, 0, 0, 203, 204, 5, 83, 0, 0, 204, 205, 5, 85, 0, 0, 205, 206, 5, 77, + 0, 0, 206, 46, 1, 0, 0, 0, 207, 208, 5, 83, 0, 0, 208, 209, 5, 85, 0, 0, + 209, 210, 5, 66, 0, 0, 210, 211, 5, 84, 0, 0, 211, 212, 5, 82, 0, 0, 212, + 213, 5, 65, 0, 0, 213, 214, 5, 67, 0, 0, 214, 215, 5, 84, 0, 0, 215, 48, + 1, 0, 0, 0, 216, 217, 5, 68, 0, 0, 217, 218, 5, 73, 0, 0, 218, 219, 5, + 86, 0, 0, 219, 50, 1, 0, 0, 0, 220, 224, 3, 57, 28, 0, 221, 223, 3, 53, + 26, 0, 222, 221, 1, 0, 0, 0, 223, 226, 1, 0, 0, 0, 224, 222, 1, 0, 0, 0, + 224, 225, 1, 0, 0, 0, 225, 52, 1, 0, 0, 0, 226, 224, 1, 0, 0, 0, 227, 232, + 7, 0, 0, 0, 228, 232, 3, 55, 27, 0, 229, 232, 3, 57, 28, 0, 230, 232, 3, + 79, 39, 0, 231, 227, 1, 0, 0, 0, 231, 228, 1, 0, 0, 0, 231, 229, 1, 0, + 0, 0, 231, 230, 1, 0, 0, 0, 232, 54, 1, 0, 0, 0, 233, 234, 2, 48, 57, 0, + 234, 56, 1, 0, 0, 0, 235, 236, 7, 1, 0, 0, 236, 58, 1, 0, 0, 0, 237, 238, + 3, 55, 27, 0, 238, 239, 3, 55, 27, 0, 239, 240, 3, 55, 27, 0, 240, 241, + 3, 55, 27, 0, 241, 242, 5, 45, 0, 0, 242, 243, 3, 55, 27, 0, 243, 244, + 3, 55, 27, 0, 244, 245, 5, 45, 0, 0, 245, 246, 3, 55, 27, 0, 246, 247, + 3, 55, 27, 0, 247, 248, 5, 84, 0, 0, 248, 249, 3, 55, 27, 0, 249, 250, + 3, 55, 27, 0, 250, 251, 5, 58, 0, 0, 251, 252, 3, 55, 27, 0, 252, 253, + 3, 55, 27, 0, 253, 60, 1, 0, 0, 0, 254, 255, 3, 73, 36, 0, 255, 256, 5, + 46, 0, 0, 256, 257, 3, 73, 36, 0, 257, 258, 5, 46, 0, 0, 258, 259, 3, 73, + 36, 0, 259, 62, 1, 0, 0, 0, 260, 265, 5, 34, 0, 0, 261, 264, 3, 65, 32, + 0, 262, 264, 8, 2, 0, 0, 263, 261, 1, 0, 0, 0, 263, 262, 1, 0, 0, 0, 264, + 267, 1, 0, 0, 0, 265, 263, 1, 0, 0, 0, 265, 266, 1, 0, 0, 0, 266, 268, + 1, 0, 0, 0, 267, 265, 1, 0, 0, 0, 268, 269, 5, 34, 0, 0, 269, 64, 1, 0, + 0, 0, 270, 273, 5, 92, 0, 0, 271, 274, 7, 3, 0, 0, 272, 274, 3, 67, 33, + 0, 273, 271, 1, 0, 0, 0, 273, 272, 1, 0, 0, 0, 274, 66, 1, 0, 0, 0, 275, + 276, 5, 117, 0, 0, 276, 277, 3, 69, 34, 0, 277, 278, 3, 69, 34, 0, 278, + 279, 3, 69, 34, 0, 279, 280, 3, 69, 34, 0, 280, 68, 1, 0, 0, 0, 281, 282, + 7, 4, 0, 0, 282, 70, 1, 0, 0, 0, 283, 285, 5, 45, 0, 0, 284, 283, 1, 0, + 0, 0, 284, 285, 1, 0, 0, 0, 285, 286, 1, 0, 0, 0, 286, 287, 3, 73, 36, + 0, 287, 289, 5, 46, 0, 0, 288, 290, 7, 5, 0, 0, 289, 288, 1, 0, 0, 0, 290, + 291, 1, 0, 0, 0, 291, 289, 1, 0, 0, 0, 291, 292, 1, 0, 0, 0, 292, 294, + 1, 0, 0, 0, 293, 295, 3, 75, 37, 0, 294, 293, 1, 0, 0, 0, 294, 295, 1, + 0, 0, 0, 295, 72, 1, 0, 0, 0, 296, 305, 5, 48, 0, 0, 297, 301, 7, 6, 0, + 0, 298, 300, 7, 5, 0, 0, 299, 298, 1, 0, 0, 0, 300, 303, 1, 0, 0, 0, 301, + 299, 1, 0, 0, 0, 301, 302, 1, 0, 0, 0, 302, 305, 1, 0, 0, 0, 303, 301, + 1, 0, 0, 0, 304, 296, 1, 0, 0, 0, 304, 297, 1, 0, 0, 0, 305, 74, 1, 0, + 0, 0, 306, 308, 7, 7, 0, 0, 307, 309, 7, 8, 0, 0, 308, 307, 1, 0, 0, 0, + 308, 309, 1, 0, 0, 0, 309, 310, 1, 0, 0, 0, 310, 311, 3, 73, 36, 0, 311, + 76, 1, 0, 0, 0, 312, 313, 5, 10, 0, 0, 313, 78, 1, 0, 0, 0, 314, 318, 5, + 44, 0, 0, 315, 317, 5, 32, 0, 0, 316, 315, 1, 0, 0, 0, 317, 320, 1, 0, + 0, 0, 318, 316, 1, 0, 0, 0, 318, 319, 1, 0, 0, 0, 319, 80, 1, 0, 0, 0, + 320, 318, 1, 0, 0, 0, 321, 325, 5, 32, 0, 0, 322, 324, 3, 77, 38, 0, 323, + 322, 1, 0, 0, 0, 324, 327, 1, 0, 0, 0, 325, 323, 1, 0, 0, 0, 325, 326, + 1, 0, 0, 0, 326, 82, 1, 0, 0, 0, 327, 325, 1, 0, 0, 0, 27, 0, 104, 111, + 122, 133, 141, 149, 156, 163, 171, 179, 185, 191, 197, 224, 231, 263, 265, + 273, 284, 291, 294, 301, 304, 308, 318, 325, 0, } deserializer := antlr.NewATNDeserializer(nil) staticData.atn = deserializer.Deserialize(staticData.serializedATN) @@ -272,12 +279,13 @@ const ( JsonQueryLexerMINUS = 24 JsonQueryLexerDIVISON = 25 JsonQueryLexerATTRNAME = 26 - JsonQueryLexerVERSION = 27 - JsonQueryLexerSTRING = 28 - JsonQueryLexerDOUBLE = 29 - JsonQueryLexerINT = 30 - JsonQueryLexerEXP = 31 - JsonQueryLexerNEWLINE = 32 - JsonQueryLexerCOMMA = 33 - JsonQueryLexerSP = 34 + JsonQueryLexerDATETIME = 27 + JsonQueryLexerVERSION = 28 + JsonQueryLexerSTRING = 29 + JsonQueryLexerDOUBLE = 30 + JsonQueryLexerINT = 31 + JsonQueryLexerEXP = 32 + JsonQueryLexerNEWLINE = 33 + JsonQueryLexerCOMMA = 34 + JsonQueryLexerSP = 35 ) diff --git a/parser/jsonquery_parser.go b/parser/jsonquery_parser.go index de55470..ce6f2a1 100644 --- a/parser/jsonquery_parser.go +++ b/parser/jsonquery_parser.go @@ -35,13 +35,13 @@ func jsonqueryParserInit() { staticData.LiteralNames = []string{ "", "'('", "')'", "'pr'", "'.'", "'-'", "'['", "']'", "", "", "", "'null'", "", "", "", "", "", "", "", "", "", "", "'MLP'", "'SUM'", "'SUBTRACT'", - "'DIV'", "", "", "", "", "", "", "'\\n'", + "'DIV'", "", "", "", "", "", "", "", "'\\n'", } staticData.SymbolicNames = []string{ "", "", "", "", "", "", "", "", "NOT", "LOGICAL_OPERATOR", "BOOLEAN", "NULL", "IN", "EQ", "NE", "GT", "LT", "GE", "LE", "CO", "SW", "EW", - "ASTERISK", "PLUS", "MINUS", "DIVISON", "ATTRNAME", "VERSION", "STRING", - "DOUBLE", "INT", "EXP", "NEWLINE", "COMMA", "SP", + "ASTERISK", "PLUS", "MINUS", "DIVISON", "ATTRNAME", "DATETIME", "VERSION", + "STRING", "DOUBLE", "INT", "EXP", "NEWLINE", "COMMA", "SP", } staticData.RuleNames = []string{ "query", "attrPath", "subAttr", "value", "listStrings", "subListOfStrings", @@ -50,64 +50,65 @@ func jsonqueryParserInit() { } staticData.PredictionContextCache = antlr.NewPredictionContextCache() staticData.serializedATN = []int32{ - 4, 1, 34, 137, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, + 4, 1, 35, 138, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 2, 5, 7, 5, 2, 6, 7, 6, 2, 7, 7, 7, 2, 8, 7, 8, 2, 9, 7, 9, 2, 10, 7, 10, 2, 11, 7, 11, 1, 0, 1, 0, 3, 0, 27, 8, 0, 1, 0, 3, 0, 30, 8, 0, 1, 0, 1, 0, 3, 0, 34, 8, 0, 1, 0, 1, 0, 3, 0, 38, 8, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 3, 0, 62, 8, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 5, 0, 69, 8, 0, 10, 0, 12, 0, 72, 9, 0, 1, 1, 1, 1, 3, 1, - 76, 8, 1, 1, 2, 1, 2, 1, 2, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 3, 3, 87, - 8, 3, 1, 3, 1, 3, 3, 3, 91, 8, 3, 1, 3, 1, 3, 1, 3, 3, 3, 96, 8, 3, 1, - 4, 1, 4, 1, 4, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 3, 5, 106, 8, 5, 1, 6, 1, - 6, 1, 6, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 3, 7, 116, 8, 7, 1, 8, 1, 8, 1, - 9, 1, 9, 1, 9, 1, 9, 1, 9, 3, 9, 125, 8, 9, 1, 10, 1, 10, 1, 10, 1, 11, - 1, 11, 1, 11, 1, 11, 1, 11, 3, 11, 135, 8, 11, 1, 11, 0, 1, 0, 12, 0, 2, - 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 0, 3, 1, 0, 12, 21, 1, 0, 22, 25, - 1, 0, 13, 18, 147, 0, 61, 1, 0, 0, 0, 2, 73, 1, 0, 0, 0, 4, 77, 1, 0, 0, - 0, 6, 95, 1, 0, 0, 0, 8, 97, 1, 0, 0, 0, 10, 105, 1, 0, 0, 0, 12, 107, - 1, 0, 0, 0, 14, 115, 1, 0, 0, 0, 16, 117, 1, 0, 0, 0, 18, 124, 1, 0, 0, - 0, 20, 126, 1, 0, 0, 0, 22, 134, 1, 0, 0, 0, 24, 26, 6, 0, -1, 0, 25, 27, - 5, 8, 0, 0, 26, 25, 1, 0, 0, 0, 26, 27, 1, 0, 0, 0, 27, 29, 1, 0, 0, 0, - 28, 30, 5, 34, 0, 0, 29, 28, 1, 0, 0, 0, 29, 30, 1, 0, 0, 0, 30, 31, 1, - 0, 0, 0, 31, 33, 5, 1, 0, 0, 32, 34, 5, 34, 0, 0, 33, 32, 1, 0, 0, 0, 33, - 34, 1, 0, 0, 0, 34, 35, 1, 0, 0, 0, 35, 37, 3, 0, 0, 0, 36, 38, 5, 34, - 0, 0, 37, 36, 1, 0, 0, 0, 37, 38, 1, 0, 0, 0, 38, 39, 1, 0, 0, 0, 39, 40, - 5, 2, 0, 0, 40, 62, 1, 0, 0, 0, 41, 42, 3, 2, 1, 0, 42, 43, 5, 34, 0, 0, - 43, 44, 5, 3, 0, 0, 44, 62, 1, 0, 0, 0, 45, 46, 3, 2, 1, 0, 46, 47, 5, - 34, 0, 0, 47, 48, 7, 0, 0, 0, 48, 49, 5, 34, 0, 0, 49, 50, 3, 6, 3, 0, - 50, 62, 1, 0, 0, 0, 51, 52, 7, 1, 0, 0, 52, 53, 5, 34, 0, 0, 53, 54, 5, - 1, 0, 0, 54, 55, 3, 16, 8, 0, 55, 56, 5, 2, 0, 0, 56, 57, 5, 34, 0, 0, - 57, 58, 7, 2, 0, 0, 58, 59, 5, 34, 0, 0, 59, 60, 3, 6, 3, 0, 60, 62, 1, - 0, 0, 0, 61, 24, 1, 0, 0, 0, 61, 41, 1, 0, 0, 0, 61, 45, 1, 0, 0, 0, 61, - 51, 1, 0, 0, 0, 62, 70, 1, 0, 0, 0, 63, 64, 10, 4, 0, 0, 64, 65, 5, 34, - 0, 0, 65, 66, 5, 9, 0, 0, 66, 67, 5, 34, 0, 0, 67, 69, 3, 0, 0, 5, 68, - 63, 1, 0, 0, 0, 69, 72, 1, 0, 0, 0, 70, 68, 1, 0, 0, 0, 70, 71, 1, 0, 0, - 0, 71, 1, 1, 0, 0, 0, 72, 70, 1, 0, 0, 0, 73, 75, 5, 26, 0, 0, 74, 76, - 3, 4, 2, 0, 75, 74, 1, 0, 0, 0, 75, 76, 1, 0, 0, 0, 76, 3, 1, 0, 0, 0, - 77, 78, 5, 4, 0, 0, 78, 79, 3, 2, 1, 0, 79, 5, 1, 0, 0, 0, 80, 96, 5, 10, - 0, 0, 81, 96, 5, 11, 0, 0, 82, 96, 5, 27, 0, 0, 83, 96, 5, 28, 0, 0, 84, - 96, 5, 29, 0, 0, 85, 87, 5, 5, 0, 0, 86, 85, 1, 0, 0, 0, 86, 87, 1, 0, - 0, 0, 87, 88, 1, 0, 0, 0, 88, 90, 5, 30, 0, 0, 89, 91, 5, 31, 0, 0, 90, - 89, 1, 0, 0, 0, 90, 91, 1, 0, 0, 0, 91, 96, 1, 0, 0, 0, 92, 96, 3, 20, - 10, 0, 93, 96, 3, 12, 6, 0, 94, 96, 3, 8, 4, 0, 95, 80, 1, 0, 0, 0, 95, - 81, 1, 0, 0, 0, 95, 82, 1, 0, 0, 0, 95, 83, 1, 0, 0, 0, 95, 84, 1, 0, 0, - 0, 95, 86, 1, 0, 0, 0, 95, 92, 1, 0, 0, 0, 95, 93, 1, 0, 0, 0, 95, 94, - 1, 0, 0, 0, 96, 7, 1, 0, 0, 0, 97, 98, 5, 6, 0, 0, 98, 99, 3, 10, 5, 0, - 99, 9, 1, 0, 0, 0, 100, 101, 5, 28, 0, 0, 101, 102, 5, 33, 0, 0, 102, 106, - 3, 10, 5, 0, 103, 104, 5, 28, 0, 0, 104, 106, 5, 7, 0, 0, 105, 100, 1, - 0, 0, 0, 105, 103, 1, 0, 0, 0, 106, 11, 1, 0, 0, 0, 107, 108, 5, 6, 0, - 0, 108, 109, 3, 14, 7, 0, 109, 13, 1, 0, 0, 0, 110, 111, 5, 29, 0, 0, 111, - 112, 5, 33, 0, 0, 112, 116, 3, 14, 7, 0, 113, 114, 5, 29, 0, 0, 114, 116, - 5, 7, 0, 0, 115, 110, 1, 0, 0, 0, 115, 113, 1, 0, 0, 0, 116, 15, 1, 0, - 0, 0, 117, 118, 3, 18, 9, 0, 118, 17, 1, 0, 0, 0, 119, 120, 3, 2, 1, 0, - 120, 121, 5, 33, 0, 0, 121, 122, 3, 18, 9, 0, 122, 125, 1, 0, 0, 0, 123, - 125, 3, 2, 1, 0, 124, 119, 1, 0, 0, 0, 124, 123, 1, 0, 0, 0, 125, 19, 1, - 0, 0, 0, 126, 127, 5, 6, 0, 0, 127, 128, 3, 22, 11, 0, 128, 21, 1, 0, 0, - 0, 129, 130, 5, 30, 0, 0, 130, 131, 5, 33, 0, 0, 131, 135, 3, 22, 11, 0, - 132, 133, 5, 30, 0, 0, 133, 135, 5, 7, 0, 0, 134, 129, 1, 0, 0, 0, 134, - 132, 1, 0, 0, 0, 135, 23, 1, 0, 0, 0, 14, 26, 29, 33, 37, 61, 70, 75, 86, - 90, 95, 105, 115, 124, 134, + 76, 8, 1, 1, 2, 1, 2, 1, 2, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 3, + 3, 88, 8, 3, 1, 3, 1, 3, 3, 3, 92, 8, 3, 1, 3, 1, 3, 1, 3, 3, 3, 97, 8, + 3, 1, 4, 1, 4, 1, 4, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 3, 5, 107, 8, 5, 1, + 6, 1, 6, 1, 6, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 3, 7, 117, 8, 7, 1, 8, 1, + 8, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 3, 9, 126, 8, 9, 1, 10, 1, 10, 1, 10, + 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 3, 11, 136, 8, 11, 1, 11, 0, 1, 0, 12, + 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 0, 3, 1, 0, 12, 21, 1, 0, 22, + 25, 1, 0, 13, 18, 149, 0, 61, 1, 0, 0, 0, 2, 73, 1, 0, 0, 0, 4, 77, 1, + 0, 0, 0, 6, 96, 1, 0, 0, 0, 8, 98, 1, 0, 0, 0, 10, 106, 1, 0, 0, 0, 12, + 108, 1, 0, 0, 0, 14, 116, 1, 0, 0, 0, 16, 118, 1, 0, 0, 0, 18, 125, 1, + 0, 0, 0, 20, 127, 1, 0, 0, 0, 22, 135, 1, 0, 0, 0, 24, 26, 6, 0, -1, 0, + 25, 27, 5, 8, 0, 0, 26, 25, 1, 0, 0, 0, 26, 27, 1, 0, 0, 0, 27, 29, 1, + 0, 0, 0, 28, 30, 5, 35, 0, 0, 29, 28, 1, 0, 0, 0, 29, 30, 1, 0, 0, 0, 30, + 31, 1, 0, 0, 0, 31, 33, 5, 1, 0, 0, 32, 34, 5, 35, 0, 0, 33, 32, 1, 0, + 0, 0, 33, 34, 1, 0, 0, 0, 34, 35, 1, 0, 0, 0, 35, 37, 3, 0, 0, 0, 36, 38, + 5, 35, 0, 0, 37, 36, 1, 0, 0, 0, 37, 38, 1, 0, 0, 0, 38, 39, 1, 0, 0, 0, + 39, 40, 5, 2, 0, 0, 40, 62, 1, 0, 0, 0, 41, 42, 3, 2, 1, 0, 42, 43, 5, + 35, 0, 0, 43, 44, 5, 3, 0, 0, 44, 62, 1, 0, 0, 0, 45, 46, 3, 2, 1, 0, 46, + 47, 5, 35, 0, 0, 47, 48, 7, 0, 0, 0, 48, 49, 5, 35, 0, 0, 49, 50, 3, 6, + 3, 0, 50, 62, 1, 0, 0, 0, 51, 52, 7, 1, 0, 0, 52, 53, 5, 35, 0, 0, 53, + 54, 5, 1, 0, 0, 54, 55, 3, 16, 8, 0, 55, 56, 5, 2, 0, 0, 56, 57, 5, 35, + 0, 0, 57, 58, 7, 2, 0, 0, 58, 59, 5, 35, 0, 0, 59, 60, 3, 6, 3, 0, 60, + 62, 1, 0, 0, 0, 61, 24, 1, 0, 0, 0, 61, 41, 1, 0, 0, 0, 61, 45, 1, 0, 0, + 0, 61, 51, 1, 0, 0, 0, 62, 70, 1, 0, 0, 0, 63, 64, 10, 4, 0, 0, 64, 65, + 5, 35, 0, 0, 65, 66, 5, 9, 0, 0, 66, 67, 5, 35, 0, 0, 67, 69, 3, 0, 0, + 5, 68, 63, 1, 0, 0, 0, 69, 72, 1, 0, 0, 0, 70, 68, 1, 0, 0, 0, 70, 71, + 1, 0, 0, 0, 71, 1, 1, 0, 0, 0, 72, 70, 1, 0, 0, 0, 73, 75, 5, 26, 0, 0, + 74, 76, 3, 4, 2, 0, 75, 74, 1, 0, 0, 0, 75, 76, 1, 0, 0, 0, 76, 3, 1, 0, + 0, 0, 77, 78, 5, 4, 0, 0, 78, 79, 3, 2, 1, 0, 79, 5, 1, 0, 0, 0, 80, 97, + 5, 10, 0, 0, 81, 97, 5, 11, 0, 0, 82, 97, 5, 28, 0, 0, 83, 97, 5, 29, 0, + 0, 84, 97, 5, 30, 0, 0, 85, 97, 5, 27, 0, 0, 86, 88, 5, 5, 0, 0, 87, 86, + 1, 0, 0, 0, 87, 88, 1, 0, 0, 0, 88, 89, 1, 0, 0, 0, 89, 91, 5, 31, 0, 0, + 90, 92, 5, 32, 0, 0, 91, 90, 1, 0, 0, 0, 91, 92, 1, 0, 0, 0, 92, 97, 1, + 0, 0, 0, 93, 97, 3, 20, 10, 0, 94, 97, 3, 12, 6, 0, 95, 97, 3, 8, 4, 0, + 96, 80, 1, 0, 0, 0, 96, 81, 1, 0, 0, 0, 96, 82, 1, 0, 0, 0, 96, 83, 1, + 0, 0, 0, 96, 84, 1, 0, 0, 0, 96, 85, 1, 0, 0, 0, 96, 87, 1, 0, 0, 0, 96, + 93, 1, 0, 0, 0, 96, 94, 1, 0, 0, 0, 96, 95, 1, 0, 0, 0, 97, 7, 1, 0, 0, + 0, 98, 99, 5, 6, 0, 0, 99, 100, 3, 10, 5, 0, 100, 9, 1, 0, 0, 0, 101, 102, + 5, 29, 0, 0, 102, 103, 5, 34, 0, 0, 103, 107, 3, 10, 5, 0, 104, 105, 5, + 29, 0, 0, 105, 107, 5, 7, 0, 0, 106, 101, 1, 0, 0, 0, 106, 104, 1, 0, 0, + 0, 107, 11, 1, 0, 0, 0, 108, 109, 5, 6, 0, 0, 109, 110, 3, 14, 7, 0, 110, + 13, 1, 0, 0, 0, 111, 112, 5, 30, 0, 0, 112, 113, 5, 34, 0, 0, 113, 117, + 3, 14, 7, 0, 114, 115, 5, 30, 0, 0, 115, 117, 5, 7, 0, 0, 116, 111, 1, + 0, 0, 0, 116, 114, 1, 0, 0, 0, 117, 15, 1, 0, 0, 0, 118, 119, 3, 18, 9, + 0, 119, 17, 1, 0, 0, 0, 120, 121, 3, 2, 1, 0, 121, 122, 5, 34, 0, 0, 122, + 123, 3, 18, 9, 0, 123, 126, 1, 0, 0, 0, 124, 126, 3, 2, 1, 0, 125, 120, + 1, 0, 0, 0, 125, 124, 1, 0, 0, 0, 126, 19, 1, 0, 0, 0, 127, 128, 5, 6, + 0, 0, 128, 129, 3, 22, 11, 0, 129, 21, 1, 0, 0, 0, 130, 131, 5, 31, 0, + 0, 131, 132, 5, 34, 0, 0, 132, 136, 3, 22, 11, 0, 133, 134, 5, 31, 0, 0, + 134, 136, 5, 7, 0, 0, 135, 130, 1, 0, 0, 0, 135, 133, 1, 0, 0, 0, 136, + 23, 1, 0, 0, 0, 14, 26, 29, 33, 37, 61, 70, 75, 87, 91, 96, 106, 116, 125, + 135, } deserializer := antlr.NewATNDeserializer(nil) staticData.atn = deserializer.Deserialize(staticData.serializedATN) @@ -172,14 +173,15 @@ const ( JsonQueryParserMINUS = 24 JsonQueryParserDIVISON = 25 JsonQueryParserATTRNAME = 26 - JsonQueryParserVERSION = 27 - JsonQueryParserSTRING = 28 - JsonQueryParserDOUBLE = 29 - JsonQueryParserINT = 30 - JsonQueryParserEXP = 31 - JsonQueryParserNEWLINE = 32 - JsonQueryParserCOMMA = 33 - JsonQueryParserSP = 34 + JsonQueryParserDATETIME = 27 + JsonQueryParserVERSION = 28 + JsonQueryParserSTRING = 29 + JsonQueryParserDOUBLE = 30 + JsonQueryParserINT = 31 + JsonQueryParserEXP = 32 + JsonQueryParserNEWLINE = 33 + JsonQueryParserCOMMA = 34 + JsonQueryParserSP = 35 ) // JsonQueryParser rules. @@ -1398,6 +1400,38 @@ func (s *ListOfStringsContext) Accept(visitor antlr.ParseTreeVisitor) interface{ } } +type DatetimeContext struct { + ValueContext +} + +func NewDatetimeContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *DatetimeContext { + var p = new(DatetimeContext) + + InitEmptyValueContext(&p.ValueContext) + p.parser = parser + p.CopyAll(ctx.(*ValueContext)) + + return p +} + +func (s *DatetimeContext) GetRuleContext() antlr.RuleContext { + return s +} + +func (s *DatetimeContext) DATETIME() antlr.TerminalNode { + return s.GetToken(JsonQueryParserDATETIME, 0) +} + +func (s *DatetimeContext) Accept(visitor antlr.ParseTreeVisitor) interface{} { + switch t := visitor.(type) { + case JsonQueryVisitor: + return t.VisitDatetime(s) + + default: + return t.VisitChildren(s) + } +} + type BooleanContext struct { ValueContext } @@ -1643,7 +1677,7 @@ func (p *JsonQueryParser) Value() (localctx IValueContext) { p.EnterRule(localctx, 6, JsonQueryParserRULE_value) var _la int - p.SetState(95) + p.SetState(96) p.GetErrorHandler().Sync(p) if p.HasError() { goto errorExit @@ -1711,9 +1745,21 @@ func (p *JsonQueryParser) Value() (localctx IValueContext) { } case 6: - localctx = NewLongContext(p, localctx) + localctx = NewDatetimeContext(p, localctx) p.EnterOuterAlt(localctx, 6) - p.SetState(86) + { + p.SetState(85) + p.Match(JsonQueryParserDATETIME) + if p.HasError() { + // Recognition error - abort rule + goto errorExit + } + } + + case 7: + localctx = NewLongContext(p, localctx) + p.EnterOuterAlt(localctx, 7) + p.SetState(87) p.GetErrorHandler().Sync(p) if p.HasError() { goto errorExit @@ -1722,7 +1768,7 @@ func (p *JsonQueryParser) Value() (localctx IValueContext) { if _la == JsonQueryParserT__4 { { - p.SetState(85) + p.SetState(86) p.Match(JsonQueryParserT__4) if p.HasError() { // Recognition error - abort rule @@ -1732,19 +1778,19 @@ func (p *JsonQueryParser) Value() (localctx IValueContext) { } { - p.SetState(88) + p.SetState(89) p.Match(JsonQueryParserINT) if p.HasError() { // Recognition error - abort rule goto errorExit } } - p.SetState(90) + p.SetState(91) p.GetErrorHandler().Sync(p) if p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 8, p.GetParserRuleContext()) == 1 { { - p.SetState(89) + p.SetState(90) p.Match(JsonQueryParserEXP) if p.HasError() { // Recognition error - abort rule @@ -1756,27 +1802,27 @@ func (p *JsonQueryParser) Value() (localctx IValueContext) { goto errorExit } - case 7: + case 8: localctx = NewListOfIntsContext(p, localctx) - p.EnterOuterAlt(localctx, 7) + p.EnterOuterAlt(localctx, 8) { - p.SetState(92) + p.SetState(93) p.ListInts() } - case 8: + case 9: localctx = NewListOfDoublesContext(p, localctx) - p.EnterOuterAlt(localctx, 8) + p.EnterOuterAlt(localctx, 9) { - p.SetState(93) + p.SetState(94) p.ListDoubles() } - case 9: + case 10: localctx = NewListOfStringsContext(p, localctx) - p.EnterOuterAlt(localctx, 9) + p.EnterOuterAlt(localctx, 10) { - p.SetState(94) + p.SetState(95) p.ListStrings() } @@ -1882,7 +1928,7 @@ func (p *JsonQueryParser) ListStrings() (localctx IListStringsContext) { p.EnterRule(localctx, 8, JsonQueryParserRULE_listStrings) p.EnterOuterAlt(localctx, 1) { - p.SetState(97) + p.SetState(98) p.Match(JsonQueryParserT__5) if p.HasError() { // Recognition error - abort rule @@ -1890,7 +1936,7 @@ func (p *JsonQueryParser) ListStrings() (localctx IListStringsContext) { } } { - p.SetState(98) + p.SetState(99) p.SubListOfStrings() } @@ -2000,7 +2046,7 @@ func (s *SubListOfStringsContext) Accept(visitor antlr.ParseTreeVisitor) interfa func (p *JsonQueryParser) SubListOfStrings() (localctx ISubListOfStringsContext) { localctx = NewSubListOfStringsContext(p, p.GetParserRuleContext(), p.GetState()) p.EnterRule(localctx, 10, JsonQueryParserRULE_subListOfStrings) - p.SetState(105) + p.SetState(106) p.GetErrorHandler().Sync(p) if p.HasError() { goto errorExit @@ -2010,7 +2056,7 @@ func (p *JsonQueryParser) SubListOfStrings() (localctx ISubListOfStringsContext) case 1: p.EnterOuterAlt(localctx, 1) { - p.SetState(100) + p.SetState(101) p.Match(JsonQueryParserSTRING) if p.HasError() { // Recognition error - abort rule @@ -2018,7 +2064,7 @@ func (p *JsonQueryParser) SubListOfStrings() (localctx ISubListOfStringsContext) } } { - p.SetState(101) + p.SetState(102) p.Match(JsonQueryParserCOMMA) if p.HasError() { // Recognition error - abort rule @@ -2026,14 +2072,14 @@ func (p *JsonQueryParser) SubListOfStrings() (localctx ISubListOfStringsContext) } } { - p.SetState(102) + p.SetState(103) p.SubListOfStrings() } case 2: p.EnterOuterAlt(localctx, 2) { - p.SetState(103) + p.SetState(104) p.Match(JsonQueryParserSTRING) if p.HasError() { // Recognition error - abort rule @@ -2041,7 +2087,7 @@ func (p *JsonQueryParser) SubListOfStrings() (localctx ISubListOfStringsContext) } } { - p.SetState(104) + p.SetState(105) p.Match(JsonQueryParserT__6) if p.HasError() { // Recognition error - abort rule @@ -2151,7 +2197,7 @@ func (p *JsonQueryParser) ListDoubles() (localctx IListDoublesContext) { p.EnterRule(localctx, 12, JsonQueryParserRULE_listDoubles) p.EnterOuterAlt(localctx, 1) { - p.SetState(107) + p.SetState(108) p.Match(JsonQueryParserT__5) if p.HasError() { // Recognition error - abort rule @@ -2159,7 +2205,7 @@ func (p *JsonQueryParser) ListDoubles() (localctx IListDoublesContext) { } } { - p.SetState(108) + p.SetState(109) p.SubListOfDoubles() } @@ -2269,7 +2315,7 @@ func (s *SubListOfDoublesContext) Accept(visitor antlr.ParseTreeVisitor) interfa func (p *JsonQueryParser) SubListOfDoubles() (localctx ISubListOfDoublesContext) { localctx = NewSubListOfDoublesContext(p, p.GetParserRuleContext(), p.GetState()) p.EnterRule(localctx, 14, JsonQueryParserRULE_subListOfDoubles) - p.SetState(115) + p.SetState(116) p.GetErrorHandler().Sync(p) if p.HasError() { goto errorExit @@ -2279,7 +2325,7 @@ func (p *JsonQueryParser) SubListOfDoubles() (localctx ISubListOfDoublesContext) case 1: p.EnterOuterAlt(localctx, 1) { - p.SetState(110) + p.SetState(111) p.Match(JsonQueryParserDOUBLE) if p.HasError() { // Recognition error - abort rule @@ -2287,7 +2333,7 @@ func (p *JsonQueryParser) SubListOfDoubles() (localctx ISubListOfDoublesContext) } } { - p.SetState(111) + p.SetState(112) p.Match(JsonQueryParserCOMMA) if p.HasError() { // Recognition error - abort rule @@ -2295,14 +2341,14 @@ func (p *JsonQueryParser) SubListOfDoubles() (localctx ISubListOfDoublesContext) } } { - p.SetState(112) + p.SetState(113) p.SubListOfDoubles() } case 2: p.EnterOuterAlt(localctx, 2) { - p.SetState(113) + p.SetState(114) p.Match(JsonQueryParserDOUBLE) if p.HasError() { // Recognition error - abort rule @@ -2310,7 +2356,7 @@ func (p *JsonQueryParser) SubListOfDoubles() (localctx ISubListOfDoublesContext) } } { - p.SetState(114) + p.SetState(115) p.Match(JsonQueryParserT__6) if p.HasError() { // Recognition error - abort rule @@ -2420,7 +2466,7 @@ func (p *JsonQueryParser) ListAttrPaths() (localctx IListAttrPathsContext) { p.EnterRule(localctx, 16, JsonQueryParserRULE_listAttrPaths) p.EnterOuterAlt(localctx, 1) { - p.SetState(117) + p.SetState(118) p.SubListOfAttrPaths() } @@ -2542,7 +2588,7 @@ func (s *SubListOfAttrPathsContext) Accept(visitor antlr.ParseTreeVisitor) inter func (p *JsonQueryParser) SubListOfAttrPaths() (localctx ISubListOfAttrPathsContext) { localctx = NewSubListOfAttrPathsContext(p, p.GetParserRuleContext(), p.GetState()) p.EnterRule(localctx, 18, JsonQueryParserRULE_subListOfAttrPaths) - p.SetState(124) + p.SetState(125) p.GetErrorHandler().Sync(p) if p.HasError() { goto errorExit @@ -2552,11 +2598,11 @@ func (p *JsonQueryParser) SubListOfAttrPaths() (localctx ISubListOfAttrPathsCont case 1: p.EnterOuterAlt(localctx, 1) { - p.SetState(119) + p.SetState(120) p.AttrPath() } { - p.SetState(120) + p.SetState(121) p.Match(JsonQueryParserCOMMA) if p.HasError() { // Recognition error - abort rule @@ -2564,14 +2610,14 @@ func (p *JsonQueryParser) SubListOfAttrPaths() (localctx ISubListOfAttrPathsCont } } { - p.SetState(121) + p.SetState(122) p.SubListOfAttrPaths() } case 2: p.EnterOuterAlt(localctx, 2) { - p.SetState(123) + p.SetState(124) p.AttrPath() } @@ -2677,7 +2723,7 @@ func (p *JsonQueryParser) ListInts() (localctx IListIntsContext) { p.EnterRule(localctx, 20, JsonQueryParserRULE_listInts) p.EnterOuterAlt(localctx, 1) { - p.SetState(126) + p.SetState(127) p.Match(JsonQueryParserT__5) if p.HasError() { // Recognition error - abort rule @@ -2685,7 +2731,7 @@ func (p *JsonQueryParser) ListInts() (localctx IListIntsContext) { } } { - p.SetState(127) + p.SetState(128) p.SubListOfInts() } @@ -2795,7 +2841,7 @@ func (s *SubListOfIntsContext) Accept(visitor antlr.ParseTreeVisitor) interface{ func (p *JsonQueryParser) SubListOfInts() (localctx ISubListOfIntsContext) { localctx = NewSubListOfIntsContext(p, p.GetParserRuleContext(), p.GetState()) p.EnterRule(localctx, 22, JsonQueryParserRULE_subListOfInts) - p.SetState(134) + p.SetState(135) p.GetErrorHandler().Sync(p) if p.HasError() { goto errorExit @@ -2805,7 +2851,7 @@ func (p *JsonQueryParser) SubListOfInts() (localctx ISubListOfIntsContext) { case 1: p.EnterOuterAlt(localctx, 1) { - p.SetState(129) + p.SetState(130) p.Match(JsonQueryParserINT) if p.HasError() { // Recognition error - abort rule @@ -2813,7 +2859,7 @@ func (p *JsonQueryParser) SubListOfInts() (localctx ISubListOfIntsContext) { } } { - p.SetState(130) + p.SetState(131) p.Match(JsonQueryParserCOMMA) if p.HasError() { // Recognition error - abort rule @@ -2821,14 +2867,14 @@ func (p *JsonQueryParser) SubListOfInts() (localctx ISubListOfIntsContext) { } } { - p.SetState(131) + p.SetState(132) p.SubListOfInts() } case 2: p.EnterOuterAlt(localctx, 2) { - p.SetState(132) + p.SetState(133) p.Match(JsonQueryParserINT) if p.HasError() { // Recognition error - abort rule @@ -2836,7 +2882,7 @@ func (p *JsonQueryParser) SubListOfInts() (localctx ISubListOfIntsContext) { } } { - p.SetState(133) + p.SetState(134) p.Match(JsonQueryParserT__6) if p.HasError() { // Recognition error - abort rule diff --git a/parser/jsonquery_visitor.go b/parser/jsonquery_visitor.go index e9dbee7..9a63b7c 100644 --- a/parser/jsonquery_visitor.go +++ b/parser/jsonquery_visitor.go @@ -44,6 +44,9 @@ type JsonQueryVisitor interface { // Visit a parse tree produced by JsonQueryParser#double. VisitDouble(ctx *DoubleContext) interface{} + // Visit a parse tree produced by JsonQueryParser#datetime. + VisitDatetime(ctx *DatetimeContext) interface{} + // Visit a parse tree produced by JsonQueryParser#long. VisitLong(ctx *LongContext) interface{} diff --git a/parser/jsonquery_visitor_impl.go b/parser/jsonquery_visitor_impl.go index 737599c..4e41fbb 100644 --- a/parser/jsonquery_visitor_impl.go +++ b/parser/jsonquery_visitor_impl.go @@ -5,6 +5,7 @@ import ( "fmt" "strconv" "strings" + "time" "github.com/antlr4-go/antlr/v4" ) @@ -547,3 +548,14 @@ func (j *JsonQueryVisitorImpl) VisitSubListOfStrings(ctx *SubListOfStringsContex } return ctx.SubListOfStrings().Accept(j) } + +func (j *JsonQueryVisitorImpl) VisitDatetime(ctx *DatetimeContext) interface{} { + j.currentOperation = &DateTimeOperation{} + rightOp, err := time.Parse(timeLayout, ctx.GetText()) + if err != nil { + j.setErr(err) + return nil + } + j.rightOp = rightOp + return nil +} diff --git a/parser/parse_logical_test.go b/parser/parse_logical_test.go index 2006bee..44bd20b 100644 --- a/parser/parse_logical_test.go +++ b/parser/parse_logical_test.go @@ -246,3 +246,60 @@ func TestLogicalExpWithAndWithExtraSpaces(t *testing.T) { }) } } + +func TestLogicalExpWithDateTime(t *testing.T) { + tests := []testCase{ + { + `x < 2024-01-09T13:31 and ( z < 2)`, + obj{ + "x": "2024-01-09T13:30", + "z": 1, + }, + true, + false, + }, + { + `x < 2 and ( y > 4 or z == 2024-01-09T13:20 )`, + obj{ + "x": 1, + "y": 3, + "z": "2024-01-09T13:20", + }, + true, + false, + }, + { + `x < 2 and ( y > 4 or z == 2024-01-09T13:20 )`, + obj{ + "x": 3, + "y": 3, + "z": "2024-01-09T13:20", + }, + false, + false, + }, + { + `x < 2 and ( y == "foo" or z == 2024-01-09T13:20 )`, + obj{ + "x": 1, + "y": "foo", + "z": "2024-01-09T13:20", + }, + true, + false, + }, + } + + for _, tt := range tests { + t.Run(tt.rule, func(t *testing.T) { + result, err := eval(t, tt.rule, tt.input) + if tt.hasError { + assert.Error(t, err) + } else { + assert.NoError(t, err) + assert.Equal(t, result, tt.result, fmt.Sprintf("rule :%s, input :%v", tt.rule, tt.input)) + } + assert.Equal(t, tt.result, Evaluate(fmt.Sprintf("(%s)", tt.rule), tt.input), tt.rule) + }) + } +} diff --git a/parser/parse_simple_test.go b/parser/parse_simple_test.go index 3243447..f4b2ac6 100644 --- a/parser/parse_simple_test.go +++ b/parser/parse_simple_test.go @@ -1243,3 +1243,243 @@ func TestString(t *testing.T) { assert.Equal(t, false, Evaluate(tt.rule, obj{"x": 3}), tt.rule) } } + +func TestDateTime(t *testing.T) { + tests := []testCase{ + { + `x EQ 2024-01-09T13:31`, + obj{ + "x": "2024-01-09T13:31", + }, + true, + false, + }, + { + `x EQ 2024-01-09T13:31`, + obj{ + "x": "2024-01-09T13:32", + }, + false, + false, + }, + { + `x EQ 2024-01-09T13:31`, + obj{ + "y": "AAAA-01-09T13:31", + }, + false, + false, + }, + { + `x EQ 2024-01-09T13:31`, + obj{}, + false, + false, + }, + { + `x EQ 2024-01-09T13:31`, + obj{ + "x": "2025-01-09T13:31", + }, + false, + false, + }, + { + `x NE 2024-01-09T13:31`, + obj{ + "x": "2024-01-09T13:31", + }, + false, + false, + }, + { + `x NE 2024-01-09T13:31`, + obj{ + "x": 2.3, + }, + false, + false, + }, + { + `x NE 2024-01-09T13:31`, + obj{ + "x": "2025-01-09T13:31", + }, + true, + false, + }, + { + `x LT 2024-01-09T13:31`, + obj{ + "x": "2023-01-09T13:31", + }, + true, + false, + }, + { + `x LT 2024-01-09T13:31`, + obj{ + "x": "2024-02-09T13:31", + }, + false, + false, + }, + { + `x LT 2024-01-09T13:31`, + obj{ + "x": 1, + }, + false, + false, + }, + { + `x LE 2024-01-09T13:31`, + obj{ + "x": "2024-01-09T13:31", + }, + true, + false, + }, + { + `x LE 2024-01-09T13:31`, + obj{ + "x": "2023-01-09T13:31", + }, + true, + false, + }, + { + `x LE 2024-01-09T13:31`, + obj{ + "x": "2024-01-10T13:31", + }, + false, + false, + }, + { + `x LE 2024-01-09T13:31`, + obj{ + "x": 2, + }, + false, + false, + }, + { + `x GT 2024-01-09T13:31`, + obj{ + "x": "2024-01-09T14:31", + }, + true, + false, + }, + { + `x GT 2024-01-09T13:31`, + obj{ + "x": "2024-01-09T13:21", + }, + false, + false, + }, + { + `x GT 2024-01-09T13:31`, + obj{ + "x": 1, + }, + false, + false, + }, + { + `x GE 2024-01-09T13:31`, + obj{ + "x": "2024-02-09T13:31", + }, + true, + false, + }, + { + `x GE 2024-01-09T13:31`, + obj{ + "x": "2024-01-09T13:30", + }, + false, + false, + }, + { + `x GE 2024-01-09T13:31`, + obj{ + "x": "2024-01-09T13:31", + }, + true, + false, + }, + { + `x GE 2024-01-09T13:31`, + obj{ + "x": 1, + }, + false, + false, + }, + { + `x == 2024-01-09T13:31`, + obj{ + "x": "2024-01-09T13:31", + }, + true, + false, + }, + { + `x > 2024-01-09T13:31`, + obj{ + "x": "2024-01-09T13:32", + }, + true, + false, + }, + { + `x < 2024-01-09T13:31`, + obj{ + "x": "2024-01-09T13:30", + }, + true, + false, + }, + { + `x <= 2024-01-09T13:31`, + obj{ + "x": "2024-01-09T13:31", + }, + true, + false, + }, + { + `x >= 2024-01-09T13:31`, + obj{ + "x": "2024-01-09T13:31", + }, + true, + false, + }, + { + `x != 2024-01-09T13:31`, + obj{ + "x": "2024-01-09T13:32", + }, + true, + false, + }, + } + + for _, tt := range tests { + t.Run(tt.rule, func(t *testing.T) { + result, err := eval(t, tt.rule, tt.input) + if tt.hasError { + assert.Error(t, err) + } else { + assert.NoError(t, err) + assert.Equal(t, result, tt.result, fmt.Sprintf("rule :%s, input :%v", tt.rule, tt.input)) + } + assert.Equal(t, tt.result, Evaluate(fmt.Sprintf("(%s)", tt.rule), tt.input), tt.rule) + }) + } +} From 6914dc96c233d70274a367929e206cd1528177dd Mon Sep 17 00:00:00 2001 From: Ezequiel Rozen Date: Wed, 10 Jan 2024 10:20:52 -0300 Subject: [PATCH 2/2] fix getTime --- parser/datetime_operation.go | 53 ++++++++++++++++++------------------ 1 file changed, 26 insertions(+), 27 deletions(-) diff --git a/parser/datetime_operation.go b/parser/datetime_operation.go index c772219..465a519 100644 --- a/parser/datetime_operation.go +++ b/parser/datetime_operation.go @@ -10,33 +10,6 @@ type DateTimeOperation struct { NullOperation } -func (o *DateTimeOperation) getTime(operand Operand) (time.Time, error) { - switch opVal := operand.(type) { - case string: - return time.Parse(timeLayout, opVal) - case time.Time: - return opVal, nil - default: - return time.Time{}, newErrInvalidOperand(operand, opVal) - } -} - -func (o *DateTimeOperation) get(left Operand, right Operand) (time.Time, time.Time, error) { - if left == nil { - return time.Time{}, time.Time{}, ErrEvalOperandMissing - } - leftVal, err := o.getTime(left) - if err != nil { - return time.Time{}, time.Time{}, err - } - rightVal, err := o.getTime(right) - if err != nil { - return time.Time{}, time.Time{}, err - } - return leftVal, rightVal, nil - -} - func (o *DateTimeOperation) EQ(left Operand, right Operand) (bool, error) { l, r, err := o.get(left, right) if err != nil { @@ -84,3 +57,29 @@ func (o *DateTimeOperation) LE(left Operand, right Operand) (bool, error) { } return l.Before(r) || l.Equal(r), nil } + +func (o *DateTimeOperation) getTime(operand Operand) (time.Time, error) { + if operand == nil { + return time.Time{}, ErrEvalOperandMissing + } + switch opVal := operand.(type) { + case string: + return time.Parse(timeLayout, opVal) + case time.Time: + return opVal, nil + default: + return time.Time{}, newErrInvalidOperand(operand, opVal) + } +} + +func (o *DateTimeOperation) get(left Operand, right Operand) (time.Time, time.Time, error) { + leftVal, err := o.getTime(left) + if err != nil { + return time.Time{}, time.Time{}, err + } + rightVal, err := o.getTime(right) + if err != nil { + return time.Time{}, time.Time{}, err + } + return leftVal, rightVal, nil +}