From 32e85fd2d94625dba4606ea92b53edfd5d0beb3d Mon Sep 17 00:00:00 2001 From: Marios Trivyzas Date: Thu, 17 Sep 2020 15:40:20 +0300 Subject: [PATCH 1/8] EQL: Replace ?"..." with """...""" for unescaped strings Use triple doulbe quotes enclosing a string literal to interpret it as unescaped, in order to use `?` for marking query params and avoid user confusion. Relates to #61659 --- .../resources/additional_test_queries.toml | 10 +- .../src/main/resources/test_queries.toml | 10 +- .../resources/test_queries_unsupported.toml | 10 +- x-pack/plugin/eql/src/main/antlr/EqlBase.g4 | 1 + .../xpack/eql/parser/AbstractBuilder.java | 12 +- .../xpack/eql/parser/EqlBaseLexer.java | 156 +++++++++--------- .../xpack/eql/parser/ExpressionTests.java | 31 ++-- .../src/test/resources/queries-supported.eql | 10 +- 8 files changed, 132 insertions(+), 108 deletions(-) diff --git a/x-pack/plugin/eql/qa/common/src/main/resources/additional_test_queries.toml b/x-pack/plugin/eql/qa/common/src/main/resources/additional_test_queries.toml index 1588d1b2d08f1..8454491ce461d 100644 --- a/x-pack/plugin/eql/qa/common/src/main/resources/additional_test_queries.toml +++ b/x-pack/plugin/eql/qa/common/src/main/resources/additional_test_queries.toml @@ -138,15 +138,15 @@ expected_event_ids = [98] notes = "regexp doesn't support character classes" query = ''' // -// ?".*?net1\s+localgroup.*?") -process where match(command_line, ?".*?net1[ ]+localgroup.*?") +// """.*?net1\s+localgroup.*?""") +process where match(command_line, """.*?net1[ ]+localgroup.*?""") ''' [[queries]] name = "matchLiteAdditional" expected_event_ids = [98] query = ''' -process where matchLite(command_line, ?".*?net1.*?") +process where matchLite(command_line, """.*?net1.*?""") ''' [[queries]] @@ -154,8 +154,8 @@ name = "matchWithCharacterClasses2" expected_event_ids = [98] notes = "regexp doesn't support predefined character classes (like \\s)" query = ''' -// ?".*?net1\s+\w{4,15}\s+.*?" -process where match(command_line, ?".*?net1[ ]+[a-z]{4,15}[ ]+.*?") +// """.*?net1\s+\w{4,15}\s+.*?""" +process where match(command_line, """.*?net1[ ]+[a-z]{4,15}[ ]+.*?""") ''' diff --git a/x-pack/plugin/eql/qa/common/src/main/resources/test_queries.toml b/x-pack/plugin/eql/qa/common/src/main/resources/test_queries.toml index e9b2df6baedf9..cfc0e602ebdc7 100644 --- a/x-pack/plugin/eql/qa/common/src/main/resources/test_queries.toml +++ b/x-pack/plugin/eql/qa/common/src/main/resources/test_queries.toml @@ -1399,21 +1399,21 @@ registry where bytes_written_string_list[1] == "en" [[queries]] name = "matchLite1" query = ''' -process where matchLite(command_line, ?".*?net1\s+localgroup\s+.*?") +process where matchLite(command_line, """.*?net1\s+localgroup\s+.*?""") ''' expected_event_ids = [98] [[queries]] name = "matchLite2" query = ''' -process where matchLite(command_line, ?".*?net1\s+\w+\s+.*?") +process where matchLite(command_line, """.*?net1\s+\w+\s+.*?""") ''' expected_event_ids = [98] [[queries]] name = "matchLite3" query = ''' -process where matchLite(command_line, ?".*?net1\s+\w{4,15}\s+.*?") +process where matchLite(command_line, """.*?net1\s+\w{4,15}\s+.*?""") ''' expected_event_ids = [98] @@ -1421,13 +1421,13 @@ expected_event_ids = [98] name = "match1" expected_event_ids = [98] query = ''' -process where match(command_line, ?".*?net1\s+\w{4,15}\s+.*?") +process where match(command_line, """.*?net1\s+\w{4,15}\s+.*?""") ''' [[queries]] name = "matchLite4" query = ''' -process where matchLite(command_line, ?".*?net1\s+[localgrup]{4,15}\s+.*?") +process where matchLite(command_line, """.*?net1\s+[localgrup]{4,15}\s+.*?""") ''' expected_event_ids = [98] diff --git a/x-pack/plugin/eql/qa/common/src/main/resources/test_queries_unsupported.toml b/x-pack/plugin/eql/qa/common/src/main/resources/test_queries_unsupported.toml index bcfa2a9549b16..24fc331833b17 100644 --- a/x-pack/plugin/eql/qa/common/src/main/resources/test_queries_unsupported.toml +++ b/x-pack/plugin/eql/qa/common/src/main/resources/test_queries_unsupported.toml @@ -797,21 +797,21 @@ registry where bytes_written_string_list[1] == "en" [[queries]] name = "matchLite1" query = ''' -process where matchLite(command_line, ?".*?net1\s+localgroup\s+.*?") +process where matchLite(command_line, """.*?net1\s+localgroup\s+.*?""") ''' expected_event_ids = [98] [[queries]] name = "matchLite2" query = ''' -process where matchLite(command_line, ?".*?net1\s+\w+\s+.*?") +process where matchLite(command_line, """.*?net1\s+\w+\s+.*?""") ''' expected_event_ids = [98] [[queries]] name = "matchLite3" query = ''' -process where matchLite(command_line, ?".*?net1\s+\w{4,15}\s+.*?") +process where matchLite(command_line, """.*?net1\s+\w{4,15}\s+.*?""") ''' expected_event_ids = [98] @@ -819,13 +819,13 @@ expected_event_ids = [98] name = "match1" expected_event_ids = [98] query = ''' -process where match(command_line, ?".*?net1\s+\w{4,15}\s+.*?") +process where match(command_line, """.*?net1\s+\w{4,15}\s+.*?""") ''' [[queries]] name = "matchLite4" query = ''' -process where matchLite(command_line, ?".*?net1\s+[localgrup]{4,15}\s+.*?") +process where matchLite(command_line, """.*?net1\s+[localgrup]{4,15}\s+.*?""") ''' expected_event_ids = [98] diff --git a/x-pack/plugin/eql/src/main/antlr/EqlBase.g4 b/x-pack/plugin/eql/src/main/antlr/EqlBase.g4 index aaf0c56519fe9..9f2a781b4392a 100644 --- a/x-pack/plugin/eql/src/main/antlr/EqlBase.g4 +++ b/x-pack/plugin/eql/src/main/antlr/EqlBase.g4 @@ -195,6 +195,7 @@ STRING | '"' ('\\' [btnfr"'\\] | ~[\r\n"\\])* '"' | '?"' ('\\"' |~["\r\n])* '"' | '?\'' ('\\\'' |~['\r\n])* '\'' + | '"""' ('\\\'' |~['\r\n])* '"""' ; INTEGER_VALUE diff --git a/x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/parser/AbstractBuilder.java b/x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/parser/AbstractBuilder.java index 56d687584d166..865e298d2caa2 100644 --- a/x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/parser/AbstractBuilder.java +++ b/x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/parser/AbstractBuilder.java @@ -122,10 +122,18 @@ public static String unquoteString(Source source) { return null; } - // unescaped strings can be interpreted directly + // catch old method of ?" and ?' to define unescaped strings if (text.startsWith("?")) { checkForSingleQuotedString(source, text, 1); - return text.substring(2, text.length() - 1); + if (text.charAt(1) == '"') { + throw new ParsingException(source, + "Use triple double quotes [\"\"\"] to define unescaped string literals, not [?\"]"); + } + } + + // unescaped strings can be interpreted directly + if (text.startsWith("\"\"\"")) { + return text.substring(3, text.length() - 3); } checkForSingleQuotedString(source, text, 0); diff --git a/x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/parser/EqlBaseLexer.java b/x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/parser/EqlBaseLexer.java index c030e7480e239..247488026a95e 100644 --- a/x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/parser/EqlBaseLexer.java +++ b/x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/parser/EqlBaseLexer.java @@ -106,7 +106,7 @@ public EqlBaseLexer(CharStream input) { public ATN getATN() { return _ATN; } public static final String _serializedATN = - "\3\u0430\ud6d1\u8206\uad2d\u4417\uaef1\u8d80\uaadd\2-\u0185\b\1\4\2\t"+ + "\3\u0430\ud6d1\u8206\uad2d\u4417\uaef1\u8d80\uaadd\2-\u0194\b\1\4\2\t"+ "\2\4\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7\t\7\4\b\t\b\4\t\t\t\4\n\t\n\4\13"+ "\t\13\4\f\t\f\4\r\t\r\4\16\t\16\4\17\t\17\4\20\t\20\4\21\t\21\4\22\t\22"+ "\4\23\t\23\4\24\t\24\4\25\t\25\4\26\t\26\4\27\t\27\4\30\t\30\4\31\t\31"+ @@ -123,37 +123,38 @@ public EqlBaseLexer(CharStream input) { "\3 \3 \3!\3!\3\"\3\"\3#\3#\3$\3$\3%\3%\7%\u00e0\n%\f%\16%\u00e3\13%\3"+ "%\3%\3&\3&\3&\3&\7&\u00eb\n&\f&\16&\u00ee\13&\3&\3&\3&\3&\3&\7&\u00f5"+ "\n&\f&\16&\u00f8\13&\3&\3&\3&\3&\3&\3&\3&\7&\u0101\n&\f&\16&\u0104\13"+ - "&\3&\3&\3&\3&\3&\3&\3&\7&\u010d\n&\f&\16&\u0110\13&\3&\5&\u0113\n&\3\'"+ - "\6\'\u0116\n\'\r\'\16\'\u0117\3(\6(\u011b\n(\r(\16(\u011c\3(\3(\7(\u0121"+ - "\n(\f(\16(\u0124\13(\3(\3(\6(\u0128\n(\r(\16(\u0129\3(\6(\u012d\n(\r("+ - "\16(\u012e\3(\3(\7(\u0133\n(\f(\16(\u0136\13(\5(\u0138\n(\3(\3(\3(\3("+ - "\6(\u013e\n(\r(\16(\u013f\3(\3(\5(\u0144\n(\3)\3)\5)\u0148\n)\3)\3)\3"+ - ")\7)\u014d\n)\f)\16)\u0150\13)\3*\3*\5*\u0154\n*\3*\6*\u0157\n*\r*\16"+ - "*\u0158\3+\3+\3,\3,\3-\3-\3-\3-\7-\u0163\n-\f-\16-\u0166\13-\3-\5-\u0169"+ - "\n-\3-\5-\u016c\n-\3-\3-\3.\3.\3.\3.\3.\7.\u0175\n.\f.\16.\u0178\13.\3"+ - ".\3.\3.\3.\3.\3/\6/\u0180\n/\r/\16/\u0181\3/\3/\3\u0176\2\60\3\3\5\4\7"+ - "\5\t\6\13\7\r\b\17\t\21\n\23\13\25\f\27\r\31\16\33\17\35\20\37\21!\22"+ - "#\23%\24\'\25)\26+\27-\30/\31\61\32\63\33\65\34\67\359\36;\37= ?!A\"C"+ - "#E$G%I&K\'M(O)Q*S\2U\2W\2Y+[,]-\3\2\17\3\2bb\n\2$$))^^ddhhppttvv\6\2\f"+ - "\f\17\17))^^\6\2\f\f\17\17$$^^\5\2\f\f\17\17$$\5\2\f\f\17\17))\4\2BBa"+ - "a\4\2GGgg\4\2--//\3\2\62;\4\2C\\c|\4\2\f\f\17\17\5\2\13\f\17\17\"\"\u01a5"+ - "\2\3\3\2\2\2\2\5\3\2\2\2\2\7\3\2\2\2\2\t\3\2\2\2\2\13\3\2\2\2\2\r\3\2"+ - "\2\2\2\17\3\2\2\2\2\21\3\2\2\2\2\23\3\2\2\2\2\25\3\2\2\2\2\27\3\2\2\2"+ - "\2\31\3\2\2\2\2\33\3\2\2\2\2\35\3\2\2\2\2\37\3\2\2\2\2!\3\2\2\2\2#\3\2"+ - "\2\2\2%\3\2\2\2\2\'\3\2\2\2\2)\3\2\2\2\2+\3\2\2\2\2-\3\2\2\2\2/\3\2\2"+ - "\2\2\61\3\2\2\2\2\63\3\2\2\2\2\65\3\2\2\2\2\67\3\2\2\2\29\3\2\2\2\2;\3"+ - "\2\2\2\2=\3\2\2\2\2?\3\2\2\2\2A\3\2\2\2\2C\3\2\2\2\2E\3\2\2\2\2G\3\2\2"+ - "\2\2I\3\2\2\2\2K\3\2\2\2\2M\3\2\2\2\2O\3\2\2\2\2Q\3\2\2\2\2Y\3\2\2\2\2"+ - "[\3\2\2\2\2]\3\2\2\2\3_\3\2\2\2\5c\3\2\2\2\7g\3\2\2\2\tj\3\2\2\2\13p\3"+ - "\2\2\2\ru\3\2\2\2\17x\3\2\2\2\21}\3\2\2\2\23\u0085\3\2\2\2\25\u0089\3"+ - "\2\2\2\27\u008e\3\2\2\2\31\u0091\3\2\2\2\33\u0094\3\2\2\2\35\u009d\3\2"+ - "\2\2\37\u00a2\3\2\2\2!\u00a8\3\2\2\2#\u00ae\3\2\2\2%\u00b6\3\2\2\2\'\u00b8"+ + "&\3&\3&\3&\3&\3&\3&\3&\7&\u010d\n&\f&\16&\u0110\13&\3&\3&\3&\3&\3&\3&"+ + "\3&\3&\7&\u011a\n&\f&\16&\u011d\13&\3&\3&\3&\5&\u0122\n&\3\'\6\'\u0125"+ + "\n\'\r\'\16\'\u0126\3(\6(\u012a\n(\r(\16(\u012b\3(\3(\7(\u0130\n(\f(\16"+ + "(\u0133\13(\3(\3(\6(\u0137\n(\r(\16(\u0138\3(\6(\u013c\n(\r(\16(\u013d"+ + "\3(\3(\7(\u0142\n(\f(\16(\u0145\13(\5(\u0147\n(\3(\3(\3(\3(\6(\u014d\n"+ + "(\r(\16(\u014e\3(\3(\5(\u0153\n(\3)\3)\5)\u0157\n)\3)\3)\3)\7)\u015c\n"+ + ")\f)\16)\u015f\13)\3*\3*\5*\u0163\n*\3*\6*\u0166\n*\r*\16*\u0167\3+\3"+ + "+\3,\3,\3-\3-\3-\3-\7-\u0172\n-\f-\16-\u0175\13-\3-\5-\u0178\n-\3-\5-"+ + "\u017b\n-\3-\3-\3.\3.\3.\3.\3.\7.\u0184\n.\f.\16.\u0187\13.\3.\3.\3.\3"+ + ".\3.\3/\6/\u018f\n/\r/\16/\u0190\3/\3/\3\u0185\2\60\3\3\5\4\7\5\t\6\13"+ + "\7\r\b\17\t\21\n\23\13\25\f\27\r\31\16\33\17\35\20\37\21!\22#\23%\24\'"+ + "\25)\26+\27-\30/\31\61\32\63\33\65\34\67\359\36;\37= ?!A\"C#E$G%I&K\'"+ + "M(O)Q*S\2U\2W\2Y+[,]-\3\2\17\3\2bb\n\2$$))^^ddhhppttvv\6\2\f\f\17\17)"+ + ")^^\6\2\f\f\17\17$$^^\5\2\f\f\17\17$$\5\2\f\f\17\17))\4\2BBaa\4\2GGgg"+ + "\4\2--//\3\2\62;\4\2C\\c|\4\2\f\f\17\17\5\2\13\f\17\17\"\"\u01b7\2\3\3"+ + "\2\2\2\2\5\3\2\2\2\2\7\3\2\2\2\2\t\3\2\2\2\2\13\3\2\2\2\2\r\3\2\2\2\2"+ + "\17\3\2\2\2\2\21\3\2\2\2\2\23\3\2\2\2\2\25\3\2\2\2\2\27\3\2\2\2\2\31\3"+ + "\2\2\2\2\33\3\2\2\2\2\35\3\2\2\2\2\37\3\2\2\2\2!\3\2\2\2\2#\3\2\2\2\2"+ + "%\3\2\2\2\2\'\3\2\2\2\2)\3\2\2\2\2+\3\2\2\2\2-\3\2\2\2\2/\3\2\2\2\2\61"+ + "\3\2\2\2\2\63\3\2\2\2\2\65\3\2\2\2\2\67\3\2\2\2\29\3\2\2\2\2;\3\2\2\2"+ + "\2=\3\2\2\2\2?\3\2\2\2\2A\3\2\2\2\2C\3\2\2\2\2E\3\2\2\2\2G\3\2\2\2\2I"+ + "\3\2\2\2\2K\3\2\2\2\2M\3\2\2\2\2O\3\2\2\2\2Q\3\2\2\2\2Y\3\2\2\2\2[\3\2"+ + "\2\2\2]\3\2\2\2\3_\3\2\2\2\5c\3\2\2\2\7g\3\2\2\2\tj\3\2\2\2\13p\3\2\2"+ + "\2\ru\3\2\2\2\17x\3\2\2\2\21}\3\2\2\2\23\u0085\3\2\2\2\25\u0089\3\2\2"+ + "\2\27\u008e\3\2\2\2\31\u0091\3\2\2\2\33\u0094\3\2\2\2\35\u009d\3\2\2\2"+ + "\37\u00a2\3\2\2\2!\u00a8\3\2\2\2#\u00ae\3\2\2\2%\u00b6\3\2\2\2\'\u00b8"+ "\3\2\2\2)\u00bb\3\2\2\2+\u00bd\3\2\2\2-\u00c0\3\2\2\2/\u00c2\3\2\2\2\61"+ "\u00c5\3\2\2\2\63\u00c7\3\2\2\2\65\u00c9\3\2\2\2\67\u00cb\3\2\2\29\u00cd"+ "\3\2\2\2;\u00cf\3\2\2\2=\u00d1\3\2\2\2?\u00d3\3\2\2\2A\u00d5\3\2\2\2C"+ - "\u00d7\3\2\2\2E\u00d9\3\2\2\2G\u00db\3\2\2\2I\u00dd\3\2\2\2K\u0112\3\2"+ - "\2\2M\u0115\3\2\2\2O\u0143\3\2\2\2Q\u0147\3\2\2\2S\u0151\3\2\2\2U\u015a"+ - "\3\2\2\2W\u015c\3\2\2\2Y\u015e\3\2\2\2[\u016f\3\2\2\2]\u017f\3\2\2\2_"+ + "\u00d7\3\2\2\2E\u00d9\3\2\2\2G\u00db\3\2\2\2I\u00dd\3\2\2\2K\u0121\3\2"+ + "\2\2M\u0124\3\2\2\2O\u0152\3\2\2\2Q\u0156\3\2\2\2S\u0160\3\2\2\2U\u0169"+ + "\3\2\2\2W\u016b\3\2\2\2Y\u016d\3\2\2\2[\u017e\3\2\2\2]\u018e\3\2\2\2_"+ "`\7c\2\2`a\7p\2\2ab\7f\2\2b\4\3\2\2\2cd\7c\2\2de\7p\2\2ef\7{\2\2f\6\3"+ "\2\2\2gh\7d\2\2hi\7{\2\2i\b\3\2\2\2jk\7h\2\2kl\7c\2\2lm\7n\2\2mn\7u\2"+ "\2no\7g\2\2o\n\3\2\2\2pq\7h\2\2qr\7q\2\2rs\7t\2\2st\7m\2\2t\f\3\2\2\2"+ @@ -188,60 +189,65 @@ public EqlBaseLexer(CharStream input) { "\u00e5\7b\2\2\u00e5J\3\2\2\2\u00e6\u00ec\7)\2\2\u00e7\u00e8\7^\2\2\u00e8"+ "\u00eb\t\3\2\2\u00e9\u00eb\n\4\2\2\u00ea\u00e7\3\2\2\2\u00ea\u00e9\3\2"+ "\2\2\u00eb\u00ee\3\2\2\2\u00ec\u00ea\3\2\2\2\u00ec\u00ed\3\2\2\2\u00ed"+ - "\u00ef\3\2\2\2\u00ee\u00ec\3\2\2\2\u00ef\u0113\7)\2\2\u00f0\u00f6\7$\2"+ + "\u00ef\3\2\2\2\u00ee\u00ec\3\2\2\2\u00ef\u0122\7)\2\2\u00f0\u00f6\7$\2"+ "\2\u00f1\u00f2\7^\2\2\u00f2\u00f5\t\3\2\2\u00f3\u00f5\n\5\2\2\u00f4\u00f1"+ "\3\2\2\2\u00f4\u00f3\3\2\2\2\u00f5\u00f8\3\2\2\2\u00f6\u00f4\3\2\2\2\u00f6"+ - "\u00f7\3\2\2\2\u00f7\u00f9\3\2\2\2\u00f8\u00f6\3\2\2\2\u00f9\u0113\7$"+ + "\u00f7\3\2\2\2\u00f7\u00f9\3\2\2\2\u00f8\u00f6\3\2\2\2\u00f9\u0122\7$"+ "\2\2\u00fa\u00fb\7A\2\2\u00fb\u00fc\7$\2\2\u00fc\u0102\3\2\2\2\u00fd\u00fe"+ "\7^\2\2\u00fe\u0101\7$\2\2\u00ff\u0101\n\6\2\2\u0100\u00fd\3\2\2\2\u0100"+ "\u00ff\3\2\2\2\u0101\u0104\3\2\2\2\u0102\u0100\3\2\2\2\u0102\u0103\3\2"+ - "\2\2\u0103\u0105\3\2\2\2\u0104\u0102\3\2\2\2\u0105\u0113\7$\2\2\u0106"+ + "\2\2\u0103\u0105\3\2\2\2\u0104\u0102\3\2\2\2\u0105\u0122\7$\2\2\u0106"+ "\u0107\7A\2\2\u0107\u0108\7)\2\2\u0108\u010e\3\2\2\2\u0109\u010a\7^\2"+ "\2\u010a\u010d\7)\2\2\u010b\u010d\n\7\2\2\u010c\u0109\3\2\2\2\u010c\u010b"+ "\3\2\2\2\u010d\u0110\3\2\2\2\u010e\u010c\3\2\2\2\u010e\u010f\3\2\2\2\u010f"+ - "\u0111\3\2\2\2\u0110\u010e\3\2\2\2\u0111\u0113\7)\2\2\u0112\u00e6\3\2"+ - "\2\2\u0112\u00f0\3\2\2\2\u0112\u00fa\3\2\2\2\u0112\u0106\3\2\2\2\u0113"+ - "L\3\2\2\2\u0114\u0116\5U+\2\u0115\u0114\3\2\2\2\u0116\u0117\3\2\2\2\u0117"+ - "\u0115\3\2\2\2\u0117\u0118\3\2\2\2\u0118N\3\2\2\2\u0119\u011b\5U+\2\u011a"+ - "\u0119\3\2\2\2\u011b\u011c\3\2\2\2\u011c\u011a\3\2\2\2\u011c\u011d\3\2"+ - "\2\2\u011d\u011e\3\2\2\2\u011e\u0122\5;\36\2\u011f\u0121\5U+\2\u0120\u011f"+ - "\3\2\2\2\u0121\u0124\3\2\2\2\u0122\u0120\3\2\2\2\u0122\u0123\3\2\2\2\u0123"+ - "\u0144\3\2\2\2\u0124\u0122\3\2\2\2\u0125\u0127\5;\36\2\u0126\u0128\5U"+ - "+\2\u0127\u0126\3\2\2\2\u0128\u0129\3\2\2\2\u0129\u0127\3\2\2\2\u0129"+ - "\u012a\3\2\2\2\u012a\u0144\3\2\2\2\u012b\u012d\5U+\2\u012c\u012b\3\2\2"+ - "\2\u012d\u012e\3\2\2\2\u012e\u012c\3\2\2\2\u012e\u012f\3\2\2\2\u012f\u0137"+ - "\3\2\2\2\u0130\u0134\5;\36\2\u0131\u0133\5U+\2\u0132\u0131\3\2\2\2\u0133"+ - "\u0136\3\2\2\2\u0134\u0132\3\2\2\2\u0134\u0135\3\2\2\2\u0135\u0138\3\2"+ - "\2\2\u0136\u0134\3\2\2\2\u0137\u0130\3\2\2\2\u0137\u0138\3\2\2\2\u0138"+ - "\u0139\3\2\2\2\u0139\u013a\5S*\2\u013a\u0144\3\2\2\2\u013b\u013d\5;\36"+ - "\2\u013c\u013e\5U+\2\u013d\u013c\3\2\2\2\u013e\u013f\3\2\2\2\u013f\u013d"+ - "\3\2\2\2\u013f\u0140\3\2\2\2\u0140\u0141\3\2\2\2\u0141\u0142\5S*\2\u0142"+ - "\u0144\3\2\2\2\u0143\u011a\3\2\2\2\u0143\u0125\3\2\2\2\u0143\u012c\3\2"+ - "\2\2\u0143\u013b\3\2\2\2\u0144P\3\2\2\2\u0145\u0148\5W,\2\u0146\u0148"+ - "\t\b\2\2\u0147\u0145\3\2\2\2\u0147\u0146\3\2\2\2\u0148\u014e\3\2\2\2\u0149"+ - "\u014d\5W,\2\u014a\u014d\5U+\2\u014b\u014d\7a\2\2\u014c\u0149\3\2\2\2"+ - "\u014c\u014a\3\2\2\2\u014c\u014b\3\2\2\2\u014d\u0150\3\2\2\2\u014e\u014c"+ - "\3\2\2\2\u014e\u014f\3\2\2\2\u014fR\3\2\2\2\u0150\u014e\3\2\2\2\u0151"+ - "\u0153\t\t\2\2\u0152\u0154\t\n\2\2\u0153\u0152\3\2\2\2\u0153\u0154\3\2"+ - "\2\2\u0154\u0156\3\2\2\2\u0155\u0157\5U+\2\u0156\u0155\3\2\2\2\u0157\u0158"+ - "\3\2\2\2\u0158\u0156\3\2\2\2\u0158\u0159\3\2\2\2\u0159T\3\2\2\2\u015a"+ - "\u015b\t\13\2\2\u015bV\3\2\2\2\u015c\u015d\t\f\2\2\u015dX\3\2\2\2\u015e"+ - "\u015f\7\61\2\2\u015f\u0160\7\61\2\2\u0160\u0164\3\2\2\2\u0161\u0163\n"+ - "\r\2\2\u0162\u0161\3\2\2\2\u0163\u0166\3\2\2\2\u0164\u0162\3\2\2\2\u0164"+ - "\u0165\3\2\2\2\u0165\u0168\3\2\2\2\u0166\u0164\3\2\2\2\u0167\u0169\7\17"+ - "\2\2\u0168\u0167\3\2\2\2\u0168\u0169\3\2\2\2\u0169\u016b\3\2\2\2\u016a"+ - "\u016c\7\f\2\2\u016b\u016a\3\2\2\2\u016b\u016c\3\2\2\2\u016c\u016d\3\2"+ - "\2\2\u016d\u016e\b-\2\2\u016eZ\3\2\2\2\u016f\u0170\7\61\2\2\u0170\u0171"+ - "\7,\2\2\u0171\u0176\3\2\2\2\u0172\u0175\5[.\2\u0173\u0175\13\2\2\2\u0174"+ - "\u0172\3\2\2\2\u0174\u0173\3\2\2\2\u0175\u0178\3\2\2\2\u0176\u0177\3\2"+ - "\2\2\u0176\u0174\3\2\2\2\u0177\u0179\3\2\2\2\u0178\u0176\3\2\2\2\u0179"+ - "\u017a\7,\2\2\u017a\u017b\7\61\2\2\u017b\u017c\3\2\2\2\u017c\u017d\b."+ - "\2\2\u017d\\\3\2\2\2\u017e\u0180\t\16\2\2\u017f\u017e\3\2\2\2\u0180\u0181"+ - "\3\2\2\2\u0181\u017f\3\2\2\2\u0181\u0182\3\2\2\2\u0182\u0183\3\2\2\2\u0183"+ - "\u0184\b/\2\2\u0184^\3\2\2\2\"\2\u00b6\u00e1\u00ea\u00ec\u00f4\u00f6\u0100"+ - "\u0102\u010c\u010e\u0112\u0117\u011c\u0122\u0129\u012e\u0134\u0137\u013f"+ - "\u0143\u0147\u014c\u014e\u0153\u0158\u0164\u0168\u016b\u0174\u0176\u0181"+ - "\3\2\3\2"; + "\u0111\3\2\2\2\u0110\u010e\3\2\2\2\u0111\u0122\7)\2\2\u0112\u0113\7$\2"+ + "\2\u0113\u0114\7$\2\2\u0114\u0115\7$\2\2\u0115\u011b\3\2\2\2\u0116\u0117"+ + "\7^\2\2\u0117\u011a\7)\2\2\u0118\u011a\n\7\2\2\u0119\u0116\3\2\2\2\u0119"+ + "\u0118\3\2\2\2\u011a\u011d\3\2\2\2\u011b\u0119\3\2\2\2\u011b\u011c\3\2"+ + "\2\2\u011c\u011e\3\2\2\2\u011d\u011b\3\2\2\2\u011e\u011f\7$\2\2\u011f"+ + "\u0120\7$\2\2\u0120\u0122\7$\2\2\u0121\u00e6\3\2\2\2\u0121\u00f0\3\2\2"+ + "\2\u0121\u00fa\3\2\2\2\u0121\u0106\3\2\2\2\u0121\u0112\3\2\2\2\u0122L"+ + "\3\2\2\2\u0123\u0125\5U+\2\u0124\u0123\3\2\2\2\u0125\u0126\3\2\2\2\u0126"+ + "\u0124\3\2\2\2\u0126\u0127\3\2\2\2\u0127N\3\2\2\2\u0128\u012a\5U+\2\u0129"+ + "\u0128\3\2\2\2\u012a\u012b\3\2\2\2\u012b\u0129\3\2\2\2\u012b\u012c\3\2"+ + "\2\2\u012c\u012d\3\2\2\2\u012d\u0131\5;\36\2\u012e\u0130\5U+\2\u012f\u012e"+ + "\3\2\2\2\u0130\u0133\3\2\2\2\u0131\u012f\3\2\2\2\u0131\u0132\3\2\2\2\u0132"+ + "\u0153\3\2\2\2\u0133\u0131\3\2\2\2\u0134\u0136\5;\36\2\u0135\u0137\5U"+ + "+\2\u0136\u0135\3\2\2\2\u0137\u0138\3\2\2\2\u0138\u0136\3\2\2\2\u0138"+ + "\u0139\3\2\2\2\u0139\u0153\3\2\2\2\u013a\u013c\5U+\2\u013b\u013a\3\2\2"+ + "\2\u013c\u013d\3\2\2\2\u013d\u013b\3\2\2\2\u013d\u013e\3\2\2\2\u013e\u0146"+ + "\3\2\2\2\u013f\u0143\5;\36\2\u0140\u0142\5U+\2\u0141\u0140\3\2\2\2\u0142"+ + "\u0145\3\2\2\2\u0143\u0141\3\2\2\2\u0143\u0144\3\2\2\2\u0144\u0147\3\2"+ + "\2\2\u0145\u0143\3\2\2\2\u0146\u013f\3\2\2\2\u0146\u0147\3\2\2\2\u0147"+ + "\u0148\3\2\2\2\u0148\u0149\5S*\2\u0149\u0153\3\2\2\2\u014a\u014c\5;\36"+ + "\2\u014b\u014d\5U+\2\u014c\u014b\3\2\2\2\u014d\u014e\3\2\2\2\u014e\u014c"+ + "\3\2\2\2\u014e\u014f\3\2\2\2\u014f\u0150\3\2\2\2\u0150\u0151\5S*\2\u0151"+ + "\u0153\3\2\2\2\u0152\u0129\3\2\2\2\u0152\u0134\3\2\2\2\u0152\u013b\3\2"+ + "\2\2\u0152\u014a\3\2\2\2\u0153P\3\2\2\2\u0154\u0157\5W,\2\u0155\u0157"+ + "\t\b\2\2\u0156\u0154\3\2\2\2\u0156\u0155\3\2\2\2\u0157\u015d\3\2\2\2\u0158"+ + "\u015c\5W,\2\u0159\u015c\5U+\2\u015a\u015c\7a\2\2\u015b\u0158\3\2\2\2"+ + "\u015b\u0159\3\2\2\2\u015b\u015a\3\2\2\2\u015c\u015f\3\2\2\2\u015d\u015b"+ + "\3\2\2\2\u015d\u015e\3\2\2\2\u015eR\3\2\2\2\u015f\u015d\3\2\2\2\u0160"+ + "\u0162\t\t\2\2\u0161\u0163\t\n\2\2\u0162\u0161\3\2\2\2\u0162\u0163\3\2"+ + "\2\2\u0163\u0165\3\2\2\2\u0164\u0166\5U+\2\u0165\u0164\3\2\2\2\u0166\u0167"+ + "\3\2\2\2\u0167\u0165\3\2\2\2\u0167\u0168\3\2\2\2\u0168T\3\2\2\2\u0169"+ + "\u016a\t\13\2\2\u016aV\3\2\2\2\u016b\u016c\t\f\2\2\u016cX\3\2\2\2\u016d"+ + "\u016e\7\61\2\2\u016e\u016f\7\61\2\2\u016f\u0173\3\2\2\2\u0170\u0172\n"+ + "\r\2\2\u0171\u0170\3\2\2\2\u0172\u0175\3\2\2\2\u0173\u0171\3\2\2\2\u0173"+ + "\u0174\3\2\2\2\u0174\u0177\3\2\2\2\u0175\u0173\3\2\2\2\u0176\u0178\7\17"+ + "\2\2\u0177\u0176\3\2\2\2\u0177\u0178\3\2\2\2\u0178\u017a\3\2\2\2\u0179"+ + "\u017b\7\f\2\2\u017a\u0179\3\2\2\2\u017a\u017b\3\2\2\2\u017b\u017c\3\2"+ + "\2\2\u017c\u017d\b-\2\2\u017dZ\3\2\2\2\u017e\u017f\7\61\2\2\u017f\u0180"+ + "\7,\2\2\u0180\u0185\3\2\2\2\u0181\u0184\5[.\2\u0182\u0184\13\2\2\2\u0183"+ + "\u0181\3\2\2\2\u0183\u0182\3\2\2\2\u0184\u0187\3\2\2\2\u0185\u0186\3\2"+ + "\2\2\u0185\u0183\3\2\2\2\u0186\u0188\3\2\2\2\u0187\u0185\3\2\2\2\u0188"+ + "\u0189\7,\2\2\u0189\u018a\7\61\2\2\u018a\u018b\3\2\2\2\u018b\u018c\b."+ + "\2\2\u018c\\\3\2\2\2\u018d\u018f\t\16\2\2\u018e\u018d\3\2\2\2\u018f\u0190"+ + "\3\2\2\2\u0190\u018e\3\2\2\2\u0190\u0191\3\2\2\2\u0191\u0192\3\2\2\2\u0192"+ + "\u0193\b/\2\2\u0193^\3\2\2\2$\2\u00b6\u00e1\u00ea\u00ec\u00f4\u00f6\u0100"+ + "\u0102\u010c\u010e\u0119\u011b\u0121\u0126\u012b\u0131\u0138\u013d\u0143"+ + "\u0146\u014e\u0152\u0156\u015b\u015d\u0162\u0167\u0173\u0177\u017a\u0183"+ + "\u0185\u0190\3\2\3\2"; public static final ATN _ATN = new ATNDeserializer().deserialize(_serializedATN.toCharArray()); static { diff --git a/x-pack/plugin/eql/src/test/java/org/elasticsearch/xpack/eql/parser/ExpressionTests.java b/x-pack/plugin/eql/src/test/java/org/elasticsearch/xpack/eql/parser/ExpressionTests.java index b69f12563be69..e358584033f29 100644 --- a/x-pack/plugin/eql/src/test/java/org/elasticsearch/xpack/eql/parser/ExpressionTests.java +++ b/x-pack/plugin/eql/src/test/java/org/elasticsearch/xpack/eql/parser/ExpressionTests.java @@ -64,14 +64,14 @@ public void testStrings() { assertEquals("hello\\\nworld", unquoteString(source("\"hello\\\\\\nworld\""))); assertEquals("hello\\\"world", unquoteString(source("\"hello\\\\\\\"world\""))); - // test for unescaped strings: ?"...." - assertEquals("hello\"world", unquoteString(source("?\"hello\"world\""))); - assertEquals("hello\\\"world", unquoteString(source("?\"hello\\\"world\""))); - assertEquals("hello'world", unquoteString(source("?\"hello'world\""))); - assertEquals("hello\\nworld", unquoteString(source("?\"hello\\nworld\""))); - assertEquals("hello\\\\nworld", unquoteString(source("?\"hello\\\\nworld\""))); - assertEquals("hello\\\\\\nworld", unquoteString(source("?\"hello\\\\\\nworld\""))); - assertEquals("hello\\\\\\\"world", unquoteString(source("?\"hello\\\\\\\"world\""))); + // test for unescaped strings: """....""" + assertEquals("hello\"world", unquoteString(source("\"\"\"hello\"world\"\"\""))); + assertEquals("hello\\\"world", unquoteString(source("\"\"\"hello\\\"world\"\"\""))); + assertEquals("hello'world", unquoteString(source("\"\"\"hello'world\"\"\""))); + assertEquals("hello\\nworld", unquoteString(source("\"\"\"hello\\nworld\"\"\""))); + assertEquals("hello\\\\nworld", unquoteString(source("\"\"\"hello\\\\nworld\"\"\""))); + assertEquals("hello\\\\\\nworld", unquoteString(source("\"\"\"hello\\\\\\nworld\"\"\""))); + assertEquals("hello\\\\\\\"world", unquoteString(source("\"\"\"hello\\\\\\\"world\"\"\""))); } public void testLiterals() { @@ -105,9 +105,18 @@ public void testSingleQuotedUnescapedStringForbidden() { e.getMessage()); } - public void testDoubleQuotedUnescapedString() { - // "hello \" world" - Expression parsed = expr("?\"hello \\\" world!\""); + public void testDoubleQuotedUnescapedStringForbidden() { + ParsingException e = expectThrows(ParsingException.class, () -> expr("?\"hello world\"")); + assertEquals("line 1:2: Use triple double quotes [\"\"\"] to define unescaped string literals, not [?\"]", + e.getMessage()); + e = expectThrows(ParsingException.class, () -> parser.createStatement("process where name=?\"hello world\"")); + assertEquals("line 1:21: Use triple double quotes [\"\"\"] to define unescaped string literals, not [?\"]", + e.getMessage()); + } + + public void testTripleDoubleQuotedUnescapedString() { + // """hello \" world""" + Expression parsed = expr("\"\"\"hello \\\" world!\"\"\""); Expression expected = new Literal(null, "hello \\\" world!", DataTypes.KEYWORD); assertEquals(expected, parsed); } diff --git a/x-pack/plugin/eql/src/test/resources/queries-supported.eql b/x-pack/plugin/eql/src/test/resources/queries-supported.eql index 02b5fb80f3aa6..11737c322d30e 100644 --- a/x-pack/plugin/eql/src/test/resources/queries-supported.eql +++ b/x-pack/plugin/eql/src/test/resources/queries-supported.eql @@ -178,19 +178,19 @@ process where command_line == "*%*%*" ; process where command_line == "%*%*" ; -process where match(?".*?net1\s+localgroup\s+.*?", command_line) +process where match(""".*?net1\s+localgroup\s+.*?""", command_line) ; -process where match(?".*?net1\s+\w+\s+.*?", command_line) +process where match(""".*?net1\s+\w+\s+.*?""", command_line) ; -process where match(?".*?net1\s+\w{4,15}\s+.*?", command_line) +process where match(""".*?net1\s+\w{4,15}\s+.*?""", command_line) ; -process where match(?".*?net1\s+\w{4,15}\s+.*?", command_line) +process where match(""".*?net1\s+\w{4,15}\s+.*?""", command_line) ; -process where match(?".*?net1\s+[localgrup]{4,15}\s+.*?", command_line) +process where match(""".*?net1\s+[localgrup]{4,15}\s+.*?""", command_line) ; file where opcode=0 and startsWith(file_name, "exploRER.") From 480aac541623a84d13ef7445a102067c381c8239 Mon Sep 17 00:00:00 2001 From: Marios Trivyzas Date: Thu, 17 Sep 2020 16:29:30 +0300 Subject: [PATCH 2/8] change error message --- .../elasticsearch/xpack/eql/parser/AbstractBuilder.java | 7 ++----- .../elasticsearch/xpack/eql/parser/ExpressionTests.java | 6 ++++-- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/parser/AbstractBuilder.java b/x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/parser/AbstractBuilder.java index 865e298d2caa2..c8adc2d97a2a9 100644 --- a/x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/parser/AbstractBuilder.java +++ b/x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/parser/AbstractBuilder.java @@ -124,11 +124,8 @@ public static String unquoteString(Source source) { // catch old method of ?" and ?' to define unescaped strings if (text.startsWith("?")) { - checkForSingleQuotedString(source, text, 1); - if (text.charAt(1) == '"') { - throw new ParsingException(source, - "Use triple double quotes [\"\"\"] to define unescaped string literals, not [?\"]"); - } + throw new ParsingException(source, + "Use triple double quotes [\"\"\"] to define unescaped string literals, not [?{}]", text.charAt(1)); } // unescaped strings can be interpreted directly diff --git a/x-pack/plugin/eql/src/test/java/org/elasticsearch/xpack/eql/parser/ExpressionTests.java b/x-pack/plugin/eql/src/test/java/org/elasticsearch/xpack/eql/parser/ExpressionTests.java index e358584033f29..1dd938084338d 100644 --- a/x-pack/plugin/eql/src/test/java/org/elasticsearch/xpack/eql/parser/ExpressionTests.java +++ b/x-pack/plugin/eql/src/test/java/org/elasticsearch/xpack/eql/parser/ExpressionTests.java @@ -98,10 +98,10 @@ public void testDoubleQuotedString() { public void testSingleQuotedUnescapedStringForbidden() { ParsingException e = expectThrows(ParsingException.class, () -> expr("?'hello world'")); - assertEquals("line 1:2: Use double quotes [\"] to define string literals, not single quotes [']", + assertEquals("line 1:2: Use triple double quotes [\"\"\"] to define unescaped string literals, not [?']", e.getMessage()); e = expectThrows(ParsingException.class, () -> parser.createStatement("process where name=?'hello world'")); - assertEquals("line 1:21: Use double quotes [\"] to define string literals, not single quotes [']", + assertEquals("line 1:21: Use triple double quotes [\"\"\"] to define unescaped string literals, not [?']", e.getMessage()); } @@ -130,6 +130,8 @@ public void testNumbers() { Expression parsed = expr("-5.2"); Expression expected = new Neg(null, new Literal(null, 5.2, DataTypes.DOUBLE)); assertEquals(expected, parsed); + + expr("1 = 1 = 1"); } public void testBackQuotedAttribute() { From 374bc92ec5d9c2d7e62fd3bf985bce862b83df6e Mon Sep 17 00:00:00 2001 From: Marios Trivyzas Date: Fri, 18 Sep 2020 13:25:15 +0300 Subject: [PATCH 3/8] fix escaped ' --- x-pack/plugin/eql/src/main/antlr/EqlBase.g4 | 2 +- .../org/elasticsearch/xpack/eql/parser/EqlBaseLexer.java | 2 +- .../org/elasticsearch/xpack/eql/parser/ExpressionTests.java | 6 ++++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/x-pack/plugin/eql/src/main/antlr/EqlBase.g4 b/x-pack/plugin/eql/src/main/antlr/EqlBase.g4 index 7f2dbb52034cd..7caf1fc7ae11b 100644 --- a/x-pack/plugin/eql/src/main/antlr/EqlBase.g4 +++ b/x-pack/plugin/eql/src/main/antlr/EqlBase.g4 @@ -199,7 +199,7 @@ STRING | '"' ('\\' [btnfr"'\\] | ~[\r\n"\\])* '"' | '?"' ('\\"' |~["\r\n])* '"' | '?\'' ('\\\'' |~['\r\n])* '\'' - | '"""' ('\\\'' |~['\r\n])* '"""' + | '"""' ('\\"' |~['\r\n])* '"""' ; INTEGER_VALUE diff --git a/x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/parser/EqlBaseLexer.java b/x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/parser/EqlBaseLexer.java index 247488026a95e..8a54867c2b770 100644 --- a/x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/parser/EqlBaseLexer.java +++ b/x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/parser/EqlBaseLexer.java @@ -202,7 +202,7 @@ public EqlBaseLexer(CharStream input) { "\3\2\2\2\u010d\u0110\3\2\2\2\u010e\u010c\3\2\2\2\u010e\u010f\3\2\2\2\u010f"+ "\u0111\3\2\2\2\u0110\u010e\3\2\2\2\u0111\u0122\7)\2\2\u0112\u0113\7$\2"+ "\2\u0113\u0114\7$\2\2\u0114\u0115\7$\2\2\u0115\u011b\3\2\2\2\u0116\u0117"+ - "\7^\2\2\u0117\u011a\7)\2\2\u0118\u011a\n\7\2\2\u0119\u0116\3\2\2\2\u0119"+ + "\7^\2\2\u0117\u011a\7$\2\2\u0118\u011a\n\7\2\2\u0119\u0116\3\2\2\2\u0119"+ "\u0118\3\2\2\2\u011a\u011d\3\2\2\2\u011b\u0119\3\2\2\2\u011b\u011c\3\2"+ "\2\2\u011c\u011e\3\2\2\2\u011d\u011b\3\2\2\2\u011e\u011f\7$\2\2\u011f"+ "\u0120\7$\2\2\u0120\u0122\7$\2\2\u0121\u00e6\3\2\2\2\u0121\u00f0\3\2\2"+ diff --git a/x-pack/plugin/eql/src/test/java/org/elasticsearch/xpack/eql/parser/ExpressionTests.java b/x-pack/plugin/eql/src/test/java/org/elasticsearch/xpack/eql/parser/ExpressionTests.java index cb686836d768e..f18c23bd15144 100644 --- a/x-pack/plugin/eql/src/test/java/org/elasticsearch/xpack/eql/parser/ExpressionTests.java +++ b/x-pack/plugin/eql/src/test/java/org/elasticsearch/xpack/eql/parser/ExpressionTests.java @@ -68,11 +68,15 @@ public void testStrings() { // test for unescaped strings: """....""" assertEquals("hello\"world", unquoteString(source("\"\"\"hello\"world\"\"\""))); assertEquals("hello\\\"world", unquoteString(source("\"\"\"hello\\\"world\"\"\""))); + assertEquals("\"\"hello\"\\\"world\"\"\"", unquoteString(source("\"\"\"\"\"hello\"\\\"world\"\"\"\"\"\""))); assertEquals("hello'world", unquoteString(source("\"\"\"hello'world\"\"\""))); + assertEquals("hello'world", unquoteString(source("\"\"\"hello\'world\"\"\""))); assertEquals("hello\\nworld", unquoteString(source("\"\"\"hello\\nworld\"\"\""))); assertEquals("hello\\\\nworld", unquoteString(source("\"\"\"hello\\\\nworld\"\"\""))); assertEquals("hello\\\\\\nworld", unquoteString(source("\"\"\"hello\\\\\\nworld\"\"\""))); assertEquals("hello\\\\\\\"world", unquoteString(source("\"\"\"hello\\\\\\\"world\"\"\""))); + assertEquals("\"\\\"", unquoteString(source("\"\"\"\"\\\"\"\"\""))); + assertEquals("", unquoteString(source("\"\"\"\"\"\""))); } public void testLiterals() { @@ -131,8 +135,6 @@ public void testNumbers() { Expression parsed = expr("-5.2"); Expression expected = new Neg(null, new Literal(null, 5.2, DataTypes.DOUBLE)); assertEquals(expected, parsed); - - expr("1 = 1 = 1"); } public void testBackQuotedAttribute() { From ae7d4ed9d94fdf34566de04f6e5888c624a6e796 Mon Sep 17 00:00:00 2001 From: Marios Trivyzas Date: Mon, 28 Sep 2020 18:21:58 +0300 Subject: [PATCH 4/8] add more tests --- x-pack/plugin/eql/src/main/antlr/EqlBase.g4 | 2 +- .../xpack/eql/parser/EqlBaseLexer.java | 249 +++++++++--------- .../xpack/eql/parser/ExpressionTests.java | 33 ++- 3 files changed, 154 insertions(+), 130 deletions(-) diff --git a/x-pack/plugin/eql/src/main/antlr/EqlBase.g4 b/x-pack/plugin/eql/src/main/antlr/EqlBase.g4 index 7caf1fc7ae11b..907240412e9d7 100644 --- a/x-pack/plugin/eql/src/main/antlr/EqlBase.g4 +++ b/x-pack/plugin/eql/src/main/antlr/EqlBase.g4 @@ -199,7 +199,7 @@ STRING | '"' ('\\' [btnfr"'\\] | ~[\r\n"\\])* '"' | '?"' ('\\"' |~["\r\n])* '"' | '?\'' ('\\\'' |~['\r\n])* '\'' - | '"""' ('\\"' |~['\r\n])* '"""' + | '"""' (~['\r\n])* '"""' ; INTEGER_VALUE diff --git a/x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/parser/EqlBaseLexer.java b/x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/parser/EqlBaseLexer.java index 8a54867c2b770..5e3ad1915b2a9 100644 --- a/x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/parser/EqlBaseLexer.java +++ b/x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/parser/EqlBaseLexer.java @@ -106,7 +106,7 @@ public EqlBaseLexer(CharStream input) { public ATN getATN() { return _ATN; } public static final String _serializedATN = - "\3\u0430\ud6d1\u8206\uad2d\u4417\uaef1\u8d80\uaadd\2-\u0194\b\1\4\2\t"+ + "\3\u0430\ud6d1\u8206\uad2d\u4417\uaef1\u8d80\uaadd\2-\u0192\b\1\4\2\t"+ "\2\4\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7\t\7\4\b\t\b\4\t\t\t\4\n\t\n\4\13"+ "\t\13\4\f\t\f\4\r\t\r\4\16\t\16\4\17\t\17\4\20\t\20\4\21\t\21\4\22\t\22"+ "\4\23\t\23\4\24\t\24\4\25\t\25\4\26\t\26\4\27\t\27\4\30\t\30\4\31\t\31"+ @@ -124,130 +124,129 @@ public EqlBaseLexer(CharStream input) { "%\3%\3&\3&\3&\3&\7&\u00eb\n&\f&\16&\u00ee\13&\3&\3&\3&\3&\3&\7&\u00f5"+ "\n&\f&\16&\u00f8\13&\3&\3&\3&\3&\3&\3&\3&\7&\u0101\n&\f&\16&\u0104\13"+ "&\3&\3&\3&\3&\3&\3&\3&\7&\u010d\n&\f&\16&\u0110\13&\3&\3&\3&\3&\3&\3&"+ - "\3&\3&\7&\u011a\n&\f&\16&\u011d\13&\3&\3&\3&\5&\u0122\n&\3\'\6\'\u0125"+ - "\n\'\r\'\16\'\u0126\3(\6(\u012a\n(\r(\16(\u012b\3(\3(\7(\u0130\n(\f(\16"+ - "(\u0133\13(\3(\3(\6(\u0137\n(\r(\16(\u0138\3(\6(\u013c\n(\r(\16(\u013d"+ - "\3(\3(\7(\u0142\n(\f(\16(\u0145\13(\5(\u0147\n(\3(\3(\3(\3(\6(\u014d\n"+ - "(\r(\16(\u014e\3(\3(\5(\u0153\n(\3)\3)\5)\u0157\n)\3)\3)\3)\7)\u015c\n"+ - ")\f)\16)\u015f\13)\3*\3*\5*\u0163\n*\3*\6*\u0166\n*\r*\16*\u0167\3+\3"+ - "+\3,\3,\3-\3-\3-\3-\7-\u0172\n-\f-\16-\u0175\13-\3-\5-\u0178\n-\3-\5-"+ - "\u017b\n-\3-\3-\3.\3.\3.\3.\3.\7.\u0184\n.\f.\16.\u0187\13.\3.\3.\3.\3"+ - ".\3.\3/\6/\u018f\n/\r/\16/\u0190\3/\3/\3\u0185\2\60\3\3\5\4\7\5\t\6\13"+ - "\7\r\b\17\t\21\n\23\13\25\f\27\r\31\16\33\17\35\20\37\21!\22#\23%\24\'"+ - "\25)\26+\27-\30/\31\61\32\63\33\65\34\67\359\36;\37= ?!A\"C#E$G%I&K\'"+ - "M(O)Q*S\2U\2W\2Y+[,]-\3\2\17\3\2bb\n\2$$))^^ddhhppttvv\6\2\f\f\17\17)"+ - ")^^\6\2\f\f\17\17$$^^\5\2\f\f\17\17$$\5\2\f\f\17\17))\4\2BBaa\4\2GGgg"+ - "\4\2--//\3\2\62;\4\2C\\c|\4\2\f\f\17\17\5\2\13\f\17\17\"\"\u01b7\2\3\3"+ - "\2\2\2\2\5\3\2\2\2\2\7\3\2\2\2\2\t\3\2\2\2\2\13\3\2\2\2\2\r\3\2\2\2\2"+ - "\17\3\2\2\2\2\21\3\2\2\2\2\23\3\2\2\2\2\25\3\2\2\2\2\27\3\2\2\2\2\31\3"+ - "\2\2\2\2\33\3\2\2\2\2\35\3\2\2\2\2\37\3\2\2\2\2!\3\2\2\2\2#\3\2\2\2\2"+ - "%\3\2\2\2\2\'\3\2\2\2\2)\3\2\2\2\2+\3\2\2\2\2-\3\2\2\2\2/\3\2\2\2\2\61"+ - "\3\2\2\2\2\63\3\2\2\2\2\65\3\2\2\2\2\67\3\2\2\2\29\3\2\2\2\2;\3\2\2\2"+ - "\2=\3\2\2\2\2?\3\2\2\2\2A\3\2\2\2\2C\3\2\2\2\2E\3\2\2\2\2G\3\2\2\2\2I"+ - "\3\2\2\2\2K\3\2\2\2\2M\3\2\2\2\2O\3\2\2\2\2Q\3\2\2\2\2Y\3\2\2\2\2[\3\2"+ - "\2\2\2]\3\2\2\2\3_\3\2\2\2\5c\3\2\2\2\7g\3\2\2\2\tj\3\2\2\2\13p\3\2\2"+ - "\2\ru\3\2\2\2\17x\3\2\2\2\21}\3\2\2\2\23\u0085\3\2\2\2\25\u0089\3\2\2"+ - "\2\27\u008e\3\2\2\2\31\u0091\3\2\2\2\33\u0094\3\2\2\2\35\u009d\3\2\2\2"+ - "\37\u00a2\3\2\2\2!\u00a8\3\2\2\2#\u00ae\3\2\2\2%\u00b6\3\2\2\2\'\u00b8"+ - "\3\2\2\2)\u00bb\3\2\2\2+\u00bd\3\2\2\2-\u00c0\3\2\2\2/\u00c2\3\2\2\2\61"+ - "\u00c5\3\2\2\2\63\u00c7\3\2\2\2\65\u00c9\3\2\2\2\67\u00cb\3\2\2\29\u00cd"+ - "\3\2\2\2;\u00cf\3\2\2\2=\u00d1\3\2\2\2?\u00d3\3\2\2\2A\u00d5\3\2\2\2C"+ - "\u00d7\3\2\2\2E\u00d9\3\2\2\2G\u00db\3\2\2\2I\u00dd\3\2\2\2K\u0121\3\2"+ - "\2\2M\u0124\3\2\2\2O\u0152\3\2\2\2Q\u0156\3\2\2\2S\u0160\3\2\2\2U\u0169"+ - "\3\2\2\2W\u016b\3\2\2\2Y\u016d\3\2\2\2[\u017e\3\2\2\2]\u018e\3\2\2\2_"+ - "`\7c\2\2`a\7p\2\2ab\7f\2\2b\4\3\2\2\2cd\7c\2\2de\7p\2\2ef\7{\2\2f\6\3"+ - "\2\2\2gh\7d\2\2hi\7{\2\2i\b\3\2\2\2jk\7h\2\2kl\7c\2\2lm\7n\2\2mn\7u\2"+ - "\2no\7g\2\2o\n\3\2\2\2pq\7h\2\2qr\7q\2\2rs\7t\2\2st\7m\2\2t\f\3\2\2\2"+ - "uv\7k\2\2vw\7p\2\2w\16\3\2\2\2xy\7l\2\2yz\7q\2\2z{\7k\2\2{|\7p\2\2|\20"+ - "\3\2\2\2}~\7o\2\2~\177\7c\2\2\177\u0080\7z\2\2\u0080\u0081\7u\2\2\u0081"+ - "\u0082\7r\2\2\u0082\u0083\7c\2\2\u0083\u0084\7p\2\2\u0084\22\3\2\2\2\u0085"+ - "\u0086\7p\2\2\u0086\u0087\7q\2\2\u0087\u0088\7v\2\2\u0088\24\3\2\2\2\u0089"+ - "\u008a\7p\2\2\u008a\u008b\7w\2\2\u008b\u008c\7n\2\2\u008c\u008d\7n\2\2"+ - "\u008d\26\3\2\2\2\u008e\u008f\7q\2\2\u008f\u0090\7h\2\2\u0090\30\3\2\2"+ - "\2\u0091\u0092\7q\2\2\u0092\u0093\7t\2\2\u0093\32\3\2\2\2\u0094\u0095"+ - "\7u\2\2\u0095\u0096\7g\2\2\u0096\u0097\7s\2\2\u0097\u0098\7w\2\2\u0098"+ - "\u0099\7g\2\2\u0099\u009a\7p\2\2\u009a\u009b\7e\2\2\u009b\u009c\7g\2\2"+ - "\u009c\34\3\2\2\2\u009d\u009e\7v\2\2\u009e\u009f\7t\2\2\u009f\u00a0\7"+ - "w\2\2\u00a0\u00a1\7g\2\2\u00a1\36\3\2\2\2\u00a2\u00a3\7w\2\2\u00a3\u00a4"+ - "\7p\2\2\u00a4\u00a5\7v\2\2\u00a5\u00a6\7k\2\2\u00a6\u00a7\7n\2\2\u00a7"+ - " \3\2\2\2\u00a8\u00a9\7y\2\2\u00a9\u00aa\7j\2\2\u00aa\u00ab\7g\2\2\u00ab"+ - "\u00ac\7t\2\2\u00ac\u00ad\7g\2\2\u00ad\"\3\2\2\2\u00ae\u00af\7y\2\2\u00af"+ - "\u00b0\7k\2\2\u00b0\u00b1\7v\2\2\u00b1\u00b2\7j\2\2\u00b2$\3\2\2\2\u00b3"+ - "\u00b7\7?\2\2\u00b4\u00b5\7?\2\2\u00b5\u00b7\7?\2\2\u00b6\u00b3\3\2\2"+ - "\2\u00b6\u00b4\3\2\2\2\u00b7&\3\2\2\2\u00b8\u00b9\7#\2\2\u00b9\u00ba\7"+ - "?\2\2\u00ba(\3\2\2\2\u00bb\u00bc\7>\2\2\u00bc*\3\2\2\2\u00bd\u00be\7>"+ - "\2\2\u00be\u00bf\7?\2\2\u00bf,\3\2\2\2\u00c0\u00c1\7@\2\2\u00c1.\3\2\2"+ - "\2\u00c2\u00c3\7@\2\2\u00c3\u00c4\7?\2\2\u00c4\60\3\2\2\2\u00c5\u00c6"+ - "\7-\2\2\u00c6\62\3\2\2\2\u00c7\u00c8\7/\2\2\u00c8\64\3\2\2\2\u00c9\u00ca"+ - "\7,\2\2\u00ca\66\3\2\2\2\u00cb\u00cc\7\61\2\2\u00cc8\3\2\2\2\u00cd\u00ce"+ - "\7\'\2\2\u00ce:\3\2\2\2\u00cf\u00d0\7\60\2\2\u00d0<\3\2\2\2\u00d1\u00d2"+ - "\7.\2\2\u00d2>\3\2\2\2\u00d3\u00d4\7]\2\2\u00d4@\3\2\2\2\u00d5\u00d6\7"+ - "_\2\2\u00d6B\3\2\2\2\u00d7\u00d8\7*\2\2\u00d8D\3\2\2\2\u00d9\u00da\7+"+ - "\2\2\u00daF\3\2\2\2\u00db\u00dc\7~\2\2\u00dcH\3\2\2\2\u00dd\u00e1\7b\2"+ - "\2\u00de\u00e0\n\2\2\2\u00df\u00de\3\2\2\2\u00e0\u00e3\3\2\2\2\u00e1\u00df"+ - "\3\2\2\2\u00e1\u00e2\3\2\2\2\u00e2\u00e4\3\2\2\2\u00e3\u00e1\3\2\2\2\u00e4"+ - "\u00e5\7b\2\2\u00e5J\3\2\2\2\u00e6\u00ec\7)\2\2\u00e7\u00e8\7^\2\2\u00e8"+ - "\u00eb\t\3\2\2\u00e9\u00eb\n\4\2\2\u00ea\u00e7\3\2\2\2\u00ea\u00e9\3\2"+ - "\2\2\u00eb\u00ee\3\2\2\2\u00ec\u00ea\3\2\2\2\u00ec\u00ed\3\2\2\2\u00ed"+ - "\u00ef\3\2\2\2\u00ee\u00ec\3\2\2\2\u00ef\u0122\7)\2\2\u00f0\u00f6\7$\2"+ - "\2\u00f1\u00f2\7^\2\2\u00f2\u00f5\t\3\2\2\u00f3\u00f5\n\5\2\2\u00f4\u00f1"+ - "\3\2\2\2\u00f4\u00f3\3\2\2\2\u00f5\u00f8\3\2\2\2\u00f6\u00f4\3\2\2\2\u00f6"+ - "\u00f7\3\2\2\2\u00f7\u00f9\3\2\2\2\u00f8\u00f6\3\2\2\2\u00f9\u0122\7$"+ - "\2\2\u00fa\u00fb\7A\2\2\u00fb\u00fc\7$\2\2\u00fc\u0102\3\2\2\2\u00fd\u00fe"+ - "\7^\2\2\u00fe\u0101\7$\2\2\u00ff\u0101\n\6\2\2\u0100\u00fd\3\2\2\2\u0100"+ - "\u00ff\3\2\2\2\u0101\u0104\3\2\2\2\u0102\u0100\3\2\2\2\u0102\u0103\3\2"+ - "\2\2\u0103\u0105\3\2\2\2\u0104\u0102\3\2\2\2\u0105\u0122\7$\2\2\u0106"+ - "\u0107\7A\2\2\u0107\u0108\7)\2\2\u0108\u010e\3\2\2\2\u0109\u010a\7^\2"+ - "\2\u010a\u010d\7)\2\2\u010b\u010d\n\7\2\2\u010c\u0109\3\2\2\2\u010c\u010b"+ - "\3\2\2\2\u010d\u0110\3\2\2\2\u010e\u010c\3\2\2\2\u010e\u010f\3\2\2\2\u010f"+ - "\u0111\3\2\2\2\u0110\u010e\3\2\2\2\u0111\u0122\7)\2\2\u0112\u0113\7$\2"+ - "\2\u0113\u0114\7$\2\2\u0114\u0115\7$\2\2\u0115\u011b\3\2\2\2\u0116\u0117"+ - "\7^\2\2\u0117\u011a\7$\2\2\u0118\u011a\n\7\2\2\u0119\u0116\3\2\2\2\u0119"+ - "\u0118\3\2\2\2\u011a\u011d\3\2\2\2\u011b\u0119\3\2\2\2\u011b\u011c\3\2"+ - "\2\2\u011c\u011e\3\2\2\2\u011d\u011b\3\2\2\2\u011e\u011f\7$\2\2\u011f"+ - "\u0120\7$\2\2\u0120\u0122\7$\2\2\u0121\u00e6\3\2\2\2\u0121\u00f0\3\2\2"+ - "\2\u0121\u00fa\3\2\2\2\u0121\u0106\3\2\2\2\u0121\u0112\3\2\2\2\u0122L"+ - "\3\2\2\2\u0123\u0125\5U+\2\u0124\u0123\3\2\2\2\u0125\u0126\3\2\2\2\u0126"+ - "\u0124\3\2\2\2\u0126\u0127\3\2\2\2\u0127N\3\2\2\2\u0128\u012a\5U+\2\u0129"+ - "\u0128\3\2\2\2\u012a\u012b\3\2\2\2\u012b\u0129\3\2\2\2\u012b\u012c\3\2"+ - "\2\2\u012c\u012d\3\2\2\2\u012d\u0131\5;\36\2\u012e\u0130\5U+\2\u012f\u012e"+ - "\3\2\2\2\u0130\u0133\3\2\2\2\u0131\u012f\3\2\2\2\u0131\u0132\3\2\2\2\u0132"+ - "\u0153\3\2\2\2\u0133\u0131\3\2\2\2\u0134\u0136\5;\36\2\u0135\u0137\5U"+ - "+\2\u0136\u0135\3\2\2\2\u0137\u0138\3\2\2\2\u0138\u0136\3\2\2\2\u0138"+ - "\u0139\3\2\2\2\u0139\u0153\3\2\2\2\u013a\u013c\5U+\2\u013b\u013a\3\2\2"+ - "\2\u013c\u013d\3\2\2\2\u013d\u013b\3\2\2\2\u013d\u013e\3\2\2\2\u013e\u0146"+ - "\3\2\2\2\u013f\u0143\5;\36\2\u0140\u0142\5U+\2\u0141\u0140\3\2\2\2\u0142"+ - "\u0145\3\2\2\2\u0143\u0141\3\2\2\2\u0143\u0144\3\2\2\2\u0144\u0147\3\2"+ - "\2\2\u0145\u0143\3\2\2\2\u0146\u013f\3\2\2\2\u0146\u0147\3\2\2\2\u0147"+ - "\u0148\3\2\2\2\u0148\u0149\5S*\2\u0149\u0153\3\2\2\2\u014a\u014c\5;\36"+ - "\2\u014b\u014d\5U+\2\u014c\u014b\3\2\2\2\u014d\u014e\3\2\2\2\u014e\u014c"+ - "\3\2\2\2\u014e\u014f\3\2\2\2\u014f\u0150\3\2\2\2\u0150\u0151\5S*\2\u0151"+ - "\u0153\3\2\2\2\u0152\u0129\3\2\2\2\u0152\u0134\3\2\2\2\u0152\u013b\3\2"+ - "\2\2\u0152\u014a\3\2\2\2\u0153P\3\2\2\2\u0154\u0157\5W,\2\u0155\u0157"+ - "\t\b\2\2\u0156\u0154\3\2\2\2\u0156\u0155\3\2\2\2\u0157\u015d\3\2\2\2\u0158"+ - "\u015c\5W,\2\u0159\u015c\5U+\2\u015a\u015c\7a\2\2\u015b\u0158\3\2\2\2"+ - "\u015b\u0159\3\2\2\2\u015b\u015a\3\2\2\2\u015c\u015f\3\2\2\2\u015d\u015b"+ - "\3\2\2\2\u015d\u015e\3\2\2\2\u015eR\3\2\2\2\u015f\u015d\3\2\2\2\u0160"+ - "\u0162\t\t\2\2\u0161\u0163\t\n\2\2\u0162\u0161\3\2\2\2\u0162\u0163\3\2"+ - "\2\2\u0163\u0165\3\2\2\2\u0164\u0166\5U+\2\u0165\u0164\3\2\2\2\u0166\u0167"+ - "\3\2\2\2\u0167\u0165\3\2\2\2\u0167\u0168\3\2\2\2\u0168T\3\2\2\2\u0169"+ - "\u016a\t\13\2\2\u016aV\3\2\2\2\u016b\u016c\t\f\2\2\u016cX\3\2\2\2\u016d"+ - "\u016e\7\61\2\2\u016e\u016f\7\61\2\2\u016f\u0173\3\2\2\2\u0170\u0172\n"+ - "\r\2\2\u0171\u0170\3\2\2\2\u0172\u0175\3\2\2\2\u0173\u0171\3\2\2\2\u0173"+ - "\u0174\3\2\2\2\u0174\u0177\3\2\2\2\u0175\u0173\3\2\2\2\u0176\u0178\7\17"+ - "\2\2\u0177\u0176\3\2\2\2\u0177\u0178\3\2\2\2\u0178\u017a\3\2\2\2\u0179"+ - "\u017b\7\f\2\2\u017a\u0179\3\2\2\2\u017a\u017b\3\2\2\2\u017b\u017c\3\2"+ - "\2\2\u017c\u017d\b-\2\2\u017dZ\3\2\2\2\u017e\u017f\7\61\2\2\u017f\u0180"+ - "\7,\2\2\u0180\u0185\3\2\2\2\u0181\u0184\5[.\2\u0182\u0184\13\2\2\2\u0183"+ - "\u0181\3\2\2\2\u0183\u0182\3\2\2\2\u0184\u0187\3\2\2\2\u0185\u0186\3\2"+ - "\2\2\u0185\u0183\3\2\2\2\u0186\u0188\3\2\2\2\u0187\u0185\3\2\2\2\u0188"+ - "\u0189\7,\2\2\u0189\u018a\7\61\2\2\u018a\u018b\3\2\2\2\u018b\u018c\b."+ - "\2\2\u018c\\\3\2\2\2\u018d\u018f\t\16\2\2\u018e\u018d\3\2\2\2\u018f\u0190"+ - "\3\2\2\2\u0190\u018e\3\2\2\2\u0190\u0191\3\2\2\2\u0191\u0192\3\2\2\2\u0192"+ - "\u0193\b/\2\2\u0193^\3\2\2\2$\2\u00b6\u00e1\u00ea\u00ec\u00f4\u00f6\u0100"+ - "\u0102\u010c\u010e\u0119\u011b\u0121\u0126\u012b\u0131\u0138\u013d\u0143"+ - "\u0146\u014e\u0152\u0156\u015b\u015d\u0162\u0167\u0173\u0177\u017a\u0183"+ - "\u0185\u0190\3\2\3\2"; + "\7&\u0118\n&\f&\16&\u011b\13&\3&\3&\3&\5&\u0120\n&\3\'\6\'\u0123\n\'\r"+ + "\'\16\'\u0124\3(\6(\u0128\n(\r(\16(\u0129\3(\3(\7(\u012e\n(\f(\16(\u0131"+ + "\13(\3(\3(\6(\u0135\n(\r(\16(\u0136\3(\6(\u013a\n(\r(\16(\u013b\3(\3("+ + "\7(\u0140\n(\f(\16(\u0143\13(\5(\u0145\n(\3(\3(\3(\3(\6(\u014b\n(\r(\16"+ + "(\u014c\3(\3(\5(\u0151\n(\3)\3)\5)\u0155\n)\3)\3)\3)\7)\u015a\n)\f)\16"+ + ")\u015d\13)\3*\3*\5*\u0161\n*\3*\6*\u0164\n*\r*\16*\u0165\3+\3+\3,\3,"+ + "\3-\3-\3-\3-\7-\u0170\n-\f-\16-\u0173\13-\3-\5-\u0176\n-\3-\5-\u0179\n"+ + "-\3-\3-\3.\3.\3.\3.\3.\7.\u0182\n.\f.\16.\u0185\13.\3.\3.\3.\3.\3.\3/"+ + "\6/\u018d\n/\r/\16/\u018e\3/\3/\3\u0183\2\60\3\3\5\4\7\5\t\6\13\7\r\b"+ + "\17\t\21\n\23\13\25\f\27\r\31\16\33\17\35\20\37\21!\22#\23%\24\'\25)\26"+ + "+\27-\30/\31\61\32\63\33\65\34\67\359\36;\37= ?!A\"C#E$G%I&K\'M(O)Q*S"+ + "\2U\2W\2Y+[,]-\3\2\17\3\2bb\n\2$$))^^ddhhppttvv\6\2\f\f\17\17))^^\6\2"+ + "\f\f\17\17$$^^\5\2\f\f\17\17$$\5\2\f\f\17\17))\4\2BBaa\4\2GGgg\4\2--/"+ + "/\3\2\62;\4\2C\\c|\4\2\f\f\17\17\5\2\13\f\17\17\"\"\u01b4\2\3\3\2\2\2"+ + "\2\5\3\2\2\2\2\7\3\2\2\2\2\t\3\2\2\2\2\13\3\2\2\2\2\r\3\2\2\2\2\17\3\2"+ + "\2\2\2\21\3\2\2\2\2\23\3\2\2\2\2\25\3\2\2\2\2\27\3\2\2\2\2\31\3\2\2\2"+ + "\2\33\3\2\2\2\2\35\3\2\2\2\2\37\3\2\2\2\2!\3\2\2\2\2#\3\2\2\2\2%\3\2\2"+ + "\2\2\'\3\2\2\2\2)\3\2\2\2\2+\3\2\2\2\2-\3\2\2\2\2/\3\2\2\2\2\61\3\2\2"+ + "\2\2\63\3\2\2\2\2\65\3\2\2\2\2\67\3\2\2\2\29\3\2\2\2\2;\3\2\2\2\2=\3\2"+ + "\2\2\2?\3\2\2\2\2A\3\2\2\2\2C\3\2\2\2\2E\3\2\2\2\2G\3\2\2\2\2I\3\2\2\2"+ + "\2K\3\2\2\2\2M\3\2\2\2\2O\3\2\2\2\2Q\3\2\2\2\2Y\3\2\2\2\2[\3\2\2\2\2]"+ + "\3\2\2\2\3_\3\2\2\2\5c\3\2\2\2\7g\3\2\2\2\tj\3\2\2\2\13p\3\2\2\2\ru\3"+ + "\2\2\2\17x\3\2\2\2\21}\3\2\2\2\23\u0085\3\2\2\2\25\u0089\3\2\2\2\27\u008e"+ + "\3\2\2\2\31\u0091\3\2\2\2\33\u0094\3\2\2\2\35\u009d\3\2\2\2\37\u00a2\3"+ + "\2\2\2!\u00a8\3\2\2\2#\u00ae\3\2\2\2%\u00b6\3\2\2\2\'\u00b8\3\2\2\2)\u00bb"+ + "\3\2\2\2+\u00bd\3\2\2\2-\u00c0\3\2\2\2/\u00c2\3\2\2\2\61\u00c5\3\2\2\2"+ + "\63\u00c7\3\2\2\2\65\u00c9\3\2\2\2\67\u00cb\3\2\2\29\u00cd\3\2\2\2;\u00cf"+ + "\3\2\2\2=\u00d1\3\2\2\2?\u00d3\3\2\2\2A\u00d5\3\2\2\2C\u00d7\3\2\2\2E"+ + "\u00d9\3\2\2\2G\u00db\3\2\2\2I\u00dd\3\2\2\2K\u011f\3\2\2\2M\u0122\3\2"+ + "\2\2O\u0150\3\2\2\2Q\u0154\3\2\2\2S\u015e\3\2\2\2U\u0167\3\2\2\2W\u0169"+ + "\3\2\2\2Y\u016b\3\2\2\2[\u017c\3\2\2\2]\u018c\3\2\2\2_`\7c\2\2`a\7p\2"+ + "\2ab\7f\2\2b\4\3\2\2\2cd\7c\2\2de\7p\2\2ef\7{\2\2f\6\3\2\2\2gh\7d\2\2"+ + "hi\7{\2\2i\b\3\2\2\2jk\7h\2\2kl\7c\2\2lm\7n\2\2mn\7u\2\2no\7g\2\2o\n\3"+ + "\2\2\2pq\7h\2\2qr\7q\2\2rs\7t\2\2st\7m\2\2t\f\3\2\2\2uv\7k\2\2vw\7p\2"+ + "\2w\16\3\2\2\2xy\7l\2\2yz\7q\2\2z{\7k\2\2{|\7p\2\2|\20\3\2\2\2}~\7o\2"+ + "\2~\177\7c\2\2\177\u0080\7z\2\2\u0080\u0081\7u\2\2\u0081\u0082\7r\2\2"+ + "\u0082\u0083\7c\2\2\u0083\u0084\7p\2\2\u0084\22\3\2\2\2\u0085\u0086\7"+ + "p\2\2\u0086\u0087\7q\2\2\u0087\u0088\7v\2\2\u0088\24\3\2\2\2\u0089\u008a"+ + "\7p\2\2\u008a\u008b\7w\2\2\u008b\u008c\7n\2\2\u008c\u008d\7n\2\2\u008d"+ + "\26\3\2\2\2\u008e\u008f\7q\2\2\u008f\u0090\7h\2\2\u0090\30\3\2\2\2\u0091"+ + "\u0092\7q\2\2\u0092\u0093\7t\2\2\u0093\32\3\2\2\2\u0094\u0095\7u\2\2\u0095"+ + "\u0096\7g\2\2\u0096\u0097\7s\2\2\u0097\u0098\7w\2\2\u0098\u0099\7g\2\2"+ + "\u0099\u009a\7p\2\2\u009a\u009b\7e\2\2\u009b\u009c\7g\2\2\u009c\34\3\2"+ + "\2\2\u009d\u009e\7v\2\2\u009e\u009f\7t\2\2\u009f\u00a0\7w\2\2\u00a0\u00a1"+ + "\7g\2\2\u00a1\36\3\2\2\2\u00a2\u00a3\7w\2\2\u00a3\u00a4\7p\2\2\u00a4\u00a5"+ + "\7v\2\2\u00a5\u00a6\7k\2\2\u00a6\u00a7\7n\2\2\u00a7 \3\2\2\2\u00a8\u00a9"+ + "\7y\2\2\u00a9\u00aa\7j\2\2\u00aa\u00ab\7g\2\2\u00ab\u00ac\7t\2\2\u00ac"+ + "\u00ad\7g\2\2\u00ad\"\3\2\2\2\u00ae\u00af\7y\2\2\u00af\u00b0\7k\2\2\u00b0"+ + "\u00b1\7v\2\2\u00b1\u00b2\7j\2\2\u00b2$\3\2\2\2\u00b3\u00b7\7?\2\2\u00b4"+ + "\u00b5\7?\2\2\u00b5\u00b7\7?\2\2\u00b6\u00b3\3\2\2\2\u00b6\u00b4\3\2\2"+ + "\2\u00b7&\3\2\2\2\u00b8\u00b9\7#\2\2\u00b9\u00ba\7?\2\2\u00ba(\3\2\2\2"+ + "\u00bb\u00bc\7>\2\2\u00bc*\3\2\2\2\u00bd\u00be\7>\2\2\u00be\u00bf\7?\2"+ + "\2\u00bf,\3\2\2\2\u00c0\u00c1\7@\2\2\u00c1.\3\2\2\2\u00c2\u00c3\7@\2\2"+ + "\u00c3\u00c4\7?\2\2\u00c4\60\3\2\2\2\u00c5\u00c6\7-\2\2\u00c6\62\3\2\2"+ + "\2\u00c7\u00c8\7/\2\2\u00c8\64\3\2\2\2\u00c9\u00ca\7,\2\2\u00ca\66\3\2"+ + "\2\2\u00cb\u00cc\7\61\2\2\u00cc8\3\2\2\2\u00cd\u00ce\7\'\2\2\u00ce:\3"+ + "\2\2\2\u00cf\u00d0\7\60\2\2\u00d0<\3\2\2\2\u00d1\u00d2\7.\2\2\u00d2>\3"+ + "\2\2\2\u00d3\u00d4\7]\2\2\u00d4@\3\2\2\2\u00d5\u00d6\7_\2\2\u00d6B\3\2"+ + "\2\2\u00d7\u00d8\7*\2\2\u00d8D\3\2\2\2\u00d9\u00da\7+\2\2\u00daF\3\2\2"+ + "\2\u00db\u00dc\7~\2\2\u00dcH\3\2\2\2\u00dd\u00e1\7b\2\2\u00de\u00e0\n"+ + "\2\2\2\u00df\u00de\3\2\2\2\u00e0\u00e3\3\2\2\2\u00e1\u00df\3\2\2\2\u00e1"+ + "\u00e2\3\2\2\2\u00e2\u00e4\3\2\2\2\u00e3\u00e1\3\2\2\2\u00e4\u00e5\7b"+ + "\2\2\u00e5J\3\2\2\2\u00e6\u00ec\7)\2\2\u00e7\u00e8\7^\2\2\u00e8\u00eb"+ + "\t\3\2\2\u00e9\u00eb\n\4\2\2\u00ea\u00e7\3\2\2\2\u00ea\u00e9\3\2\2\2\u00eb"+ + "\u00ee\3\2\2\2\u00ec\u00ea\3\2\2\2\u00ec\u00ed\3\2\2\2\u00ed\u00ef\3\2"+ + "\2\2\u00ee\u00ec\3\2\2\2\u00ef\u0120\7)\2\2\u00f0\u00f6\7$\2\2\u00f1\u00f2"+ + "\7^\2\2\u00f2\u00f5\t\3\2\2\u00f3\u00f5\n\5\2\2\u00f4\u00f1\3\2\2\2\u00f4"+ + "\u00f3\3\2\2\2\u00f5\u00f8\3\2\2\2\u00f6\u00f4\3\2\2\2\u00f6\u00f7\3\2"+ + "\2\2\u00f7\u00f9\3\2\2\2\u00f8\u00f6\3\2\2\2\u00f9\u0120\7$\2\2\u00fa"+ + "\u00fb\7A\2\2\u00fb\u00fc\7$\2\2\u00fc\u0102\3\2\2\2\u00fd\u00fe\7^\2"+ + "\2\u00fe\u0101\7$\2\2\u00ff\u0101\n\6\2\2\u0100\u00fd\3\2\2\2\u0100\u00ff"+ + "\3\2\2\2\u0101\u0104\3\2\2\2\u0102\u0100\3\2\2\2\u0102\u0103\3\2\2\2\u0103"+ + "\u0105\3\2\2\2\u0104\u0102\3\2\2\2\u0105\u0120\7$\2\2\u0106\u0107\7A\2"+ + "\2\u0107\u0108\7)\2\2\u0108\u010e\3\2\2\2\u0109\u010a\7^\2\2\u010a\u010d"+ + "\7)\2\2\u010b\u010d\n\7\2\2\u010c\u0109\3\2\2\2\u010c\u010b\3\2\2\2\u010d"+ + "\u0110\3\2\2\2\u010e\u010c\3\2\2\2\u010e\u010f\3\2\2\2\u010f\u0111\3\2"+ + "\2\2\u0110\u010e\3\2\2\2\u0111\u0120\7)\2\2\u0112\u0113\7$\2\2\u0113\u0114"+ + "\7$\2\2\u0114\u0115\7$\2\2\u0115\u0119\3\2\2\2\u0116\u0118\n\7\2\2\u0117"+ + "\u0116\3\2\2\2\u0118\u011b\3\2\2\2\u0119\u0117\3\2\2\2\u0119\u011a\3\2"+ + "\2\2\u011a\u011c\3\2\2\2\u011b\u0119\3\2\2\2\u011c\u011d\7$\2\2\u011d"+ + "\u011e\7$\2\2\u011e\u0120\7$\2\2\u011f\u00e6\3\2\2\2\u011f\u00f0\3\2\2"+ + "\2\u011f\u00fa\3\2\2\2\u011f\u0106\3\2\2\2\u011f\u0112\3\2\2\2\u0120L"+ + "\3\2\2\2\u0121\u0123\5U+\2\u0122\u0121\3\2\2\2\u0123\u0124\3\2\2\2\u0124"+ + "\u0122\3\2\2\2\u0124\u0125\3\2\2\2\u0125N\3\2\2\2\u0126\u0128\5U+\2\u0127"+ + "\u0126\3\2\2\2\u0128\u0129\3\2\2\2\u0129\u0127\3\2\2\2\u0129\u012a\3\2"+ + "\2\2\u012a\u012b\3\2\2\2\u012b\u012f\5;\36\2\u012c\u012e\5U+\2\u012d\u012c"+ + "\3\2\2\2\u012e\u0131\3\2\2\2\u012f\u012d\3\2\2\2\u012f\u0130\3\2\2\2\u0130"+ + "\u0151\3\2\2\2\u0131\u012f\3\2\2\2\u0132\u0134\5;\36\2\u0133\u0135\5U"+ + "+\2\u0134\u0133\3\2\2\2\u0135\u0136\3\2\2\2\u0136\u0134\3\2\2\2\u0136"+ + "\u0137\3\2\2\2\u0137\u0151\3\2\2\2\u0138\u013a\5U+\2\u0139\u0138\3\2\2"+ + "\2\u013a\u013b\3\2\2\2\u013b\u0139\3\2\2\2\u013b\u013c\3\2\2\2\u013c\u0144"+ + "\3\2\2\2\u013d\u0141\5;\36\2\u013e\u0140\5U+\2\u013f\u013e\3\2\2\2\u0140"+ + "\u0143\3\2\2\2\u0141\u013f\3\2\2\2\u0141\u0142\3\2\2\2\u0142\u0145\3\2"+ + "\2\2\u0143\u0141\3\2\2\2\u0144\u013d\3\2\2\2\u0144\u0145\3\2\2\2\u0145"+ + "\u0146\3\2\2\2\u0146\u0147\5S*\2\u0147\u0151\3\2\2\2\u0148\u014a\5;\36"+ + "\2\u0149\u014b\5U+\2\u014a\u0149\3\2\2\2\u014b\u014c\3\2\2\2\u014c\u014a"+ + "\3\2\2\2\u014c\u014d\3\2\2\2\u014d\u014e\3\2\2\2\u014e\u014f\5S*\2\u014f"+ + "\u0151\3\2\2\2\u0150\u0127\3\2\2\2\u0150\u0132\3\2\2\2\u0150\u0139\3\2"+ + "\2\2\u0150\u0148\3\2\2\2\u0151P\3\2\2\2\u0152\u0155\5W,\2\u0153\u0155"+ + "\t\b\2\2\u0154\u0152\3\2\2\2\u0154\u0153\3\2\2\2\u0155\u015b\3\2\2\2\u0156"+ + "\u015a\5W,\2\u0157\u015a\5U+\2\u0158\u015a\7a\2\2\u0159\u0156\3\2\2\2"+ + "\u0159\u0157\3\2\2\2\u0159\u0158\3\2\2\2\u015a\u015d\3\2\2\2\u015b\u0159"+ + "\3\2\2\2\u015b\u015c\3\2\2\2\u015cR\3\2\2\2\u015d\u015b\3\2\2\2\u015e"+ + "\u0160\t\t\2\2\u015f\u0161\t\n\2\2\u0160\u015f\3\2\2\2\u0160\u0161\3\2"+ + "\2\2\u0161\u0163\3\2\2\2\u0162\u0164\5U+\2\u0163\u0162\3\2\2\2\u0164\u0165"+ + "\3\2\2\2\u0165\u0163\3\2\2\2\u0165\u0166\3\2\2\2\u0166T\3\2\2\2\u0167"+ + "\u0168\t\13\2\2\u0168V\3\2\2\2\u0169\u016a\t\f\2\2\u016aX\3\2\2\2\u016b"+ + "\u016c\7\61\2\2\u016c\u016d\7\61\2\2\u016d\u0171\3\2\2\2\u016e\u0170\n"+ + "\r\2\2\u016f\u016e\3\2\2\2\u0170\u0173\3\2\2\2\u0171\u016f\3\2\2\2\u0171"+ + "\u0172\3\2\2\2\u0172\u0175\3\2\2\2\u0173\u0171\3\2\2\2\u0174\u0176\7\17"+ + "\2\2\u0175\u0174\3\2\2\2\u0175\u0176\3\2\2\2\u0176\u0178\3\2\2\2\u0177"+ + "\u0179\7\f\2\2\u0178\u0177\3\2\2\2\u0178\u0179\3\2\2\2\u0179\u017a\3\2"+ + "\2\2\u017a\u017b\b-\2\2\u017bZ\3\2\2\2\u017c\u017d\7\61\2\2\u017d\u017e"+ + "\7,\2\2\u017e\u0183\3\2\2\2\u017f\u0182\5[.\2\u0180\u0182\13\2\2\2\u0181"+ + "\u017f\3\2\2\2\u0181\u0180\3\2\2\2\u0182\u0185\3\2\2\2\u0183\u0184\3\2"+ + "\2\2\u0183\u0181\3\2\2\2\u0184\u0186\3\2\2\2\u0185\u0183\3\2\2\2\u0186"+ + "\u0187\7,\2\2\u0187\u0188\7\61\2\2\u0188\u0189\3\2\2\2\u0189\u018a\b."+ + "\2\2\u018a\\\3\2\2\2\u018b\u018d\t\16\2\2\u018c\u018b\3\2\2\2\u018d\u018e"+ + "\3\2\2\2\u018e\u018c\3\2\2\2\u018e\u018f\3\2\2\2\u018f\u0190\3\2\2\2\u0190"+ + "\u0191\b/\2\2\u0191^\3\2\2\2#\2\u00b6\u00e1\u00ea\u00ec\u00f4\u00f6\u0100"+ + "\u0102\u010c\u010e\u0119\u011f\u0124\u0129\u012f\u0136\u013b\u0141\u0144"+ + "\u014c\u0150\u0154\u0159\u015b\u0160\u0165\u0171\u0175\u0178\u0181\u0183"+ + "\u018e\3\2\3\2"; public static final ATN _ATN = new ATNDeserializer().deserialize(_serializedATN.toCharArray()); static { diff --git a/x-pack/plugin/eql/src/test/java/org/elasticsearch/xpack/eql/parser/ExpressionTests.java b/x-pack/plugin/eql/src/test/java/org/elasticsearch/xpack/eql/parser/ExpressionTests.java index f18c23bd15144..771cb39f3515c 100644 --- a/x-pack/plugin/eql/src/test/java/org/elasticsearch/xpack/eql/parser/ExpressionTests.java +++ b/x-pack/plugin/eql/src/test/java/org/elasticsearch/xpack/eql/parser/ExpressionTests.java @@ -120,10 +120,35 @@ public void testDoubleQuotedUnescapedStringForbidden() { } public void testTripleDoubleQuotedUnescapedString() { - // """hello \" world""" - Expression parsed = expr("\"\"\"hello \\\" world!\"\"\""); - Expression expected = new Literal(null, "hello \\\" world!", DataTypes.KEYWORD); - assertEquals(expected, parsed); + // """hello " world!""" => hello " world! + String str = "\"\"\"hello \" world!\"\"\" = foo"; + String expectedStr = "hello \" world!"; + Expression parsed = expr(str); + assertEquals(Equals.class, parsed.getClass()); + Equals eq = (Equals) parsed; + assertEquals(UnresolvedAttribute.class, eq.right().getClass()); + assertEquals(Literal.class, eq.left().getClass()); + assertEquals(expectedStr, ((Literal) eq.left()).value()); + + // """hello \" world!""" => hello \" world! + str = "\"\"\"hello \\\" world!\"\"\" = foo"; + expectedStr = "hello \\\" world!"; + parsed = expr(str); + assertEquals(Equals.class, parsed.getClass()); + eq = (Equals) parsed; + assertEquals(UnresolvedAttribute.class, eq.right().getClass()); + assertEquals(Literal.class, eq.left().getClass()); + assertEquals(expectedStr, ((Literal) eq.left()).value()); + + // """""hello """ world!"""" => ""hello """ world!" + str = "\"\"\"\"\"hello \"\"\" world!\"\"\"\" = foo"; + expectedStr = "\"\"hello \"\"\" world!\""; + parsed = expr(str); + assertEquals(Equals.class, parsed.getClass()); + eq = (Equals) parsed; + assertEquals(UnresolvedAttribute.class, eq.right().getClass()); + assertEquals(Literal.class, eq.left().getClass()); + assertEquals(expectedStr, ((Literal) eq.left()).value()); } public void testNumbers() { From fec23cef7afd30d79a66b206ab841976c38c8a14 Mon Sep 17 00:00:00 2001 From: Marios Trivyzas Date: Mon, 28 Sep 2020 18:40:16 +0300 Subject: [PATCH 5/8] fix tests --- .../xpack/eql/parser/ExpressionTests.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/x-pack/plugin/eql/src/test/java/org/elasticsearch/xpack/eql/parser/ExpressionTests.java b/x-pack/plugin/eql/src/test/java/org/elasticsearch/xpack/eql/parser/ExpressionTests.java index 8a4ec09d07028..524c437a5b41f 100644 --- a/x-pack/plugin/eql/src/test/java/org/elasticsearch/xpack/eql/parser/ExpressionTests.java +++ b/x-pack/plugin/eql/src/test/java/org/elasticsearch/xpack/eql/parser/ExpressionTests.java @@ -105,8 +105,8 @@ public void testSingleQuotedUnescapedStringDisallowed() { ParsingException e = expectThrows(ParsingException.class, () -> expr("?'hello world'")); assertEquals("line 1:2: Use triple double quotes [\"\"\"] to define unescaped string literals, not [?']", e.getMessage()); - e = expectThrows(ParsingException.class, () -> parser.createStatement("process where name=?'hello world'")); - assertEquals("line 1:21: Use triple double quotes [\"\"\"] to define unescaped string literals, not [?']", + e = expectThrows(ParsingException.class, () -> parser.createStatement("process where name == ?'hello world'")); + assertEquals("line 1:24: Use triple double quotes [\"\"\"] to define unescaped string literals, not [?']", e.getMessage()); } @@ -114,14 +114,14 @@ public void testDoubleQuotedUnescapedStringForbidden() { ParsingException e = expectThrows(ParsingException.class, () -> expr("?\"hello world\"")); assertEquals("line 1:2: Use triple double quotes [\"\"\"] to define unescaped string literals, not [?\"]", e.getMessage()); - e = expectThrows(ParsingException.class, () -> parser.createStatement("process where name=?\"hello world\"")); - assertEquals("line 1:21: Use triple double quotes [\"\"\"] to define unescaped string literals, not [?\"]", + e = expectThrows(ParsingException.class, () -> parser.createStatement("process where name == ?\"hello world\"")); + assertEquals("line 1:24: Use triple double quotes [\"\"\"] to define unescaped string literals, not [?\"]", e.getMessage()); } public void testTripleDoubleQuotedUnescapedString() { // """hello " world!""" => hello " world! - String str = "\"\"\"hello \" world!\"\"\" = foo"; + String str = "\"\"\"hello \" world!\"\"\" == foo"; String expectedStr = "hello \" world!"; Expression parsed = expr(str); assertEquals(Equals.class, parsed.getClass()); @@ -131,7 +131,7 @@ public void testTripleDoubleQuotedUnescapedString() { assertEquals(expectedStr, ((Literal) eq.left()).value()); // """hello \" world!""" => hello \" world! - str = "\"\"\"hello \\\" world!\"\"\" = foo"; + str = "\"\"\"hello \\\" world!\"\"\" == foo"; expectedStr = "hello \\\" world!"; parsed = expr(str); assertEquals(Equals.class, parsed.getClass()); @@ -141,7 +141,7 @@ public void testTripleDoubleQuotedUnescapedString() { assertEquals(expectedStr, ((Literal) eq.left()).value()); // """""hello """ world!"""" => ""hello """ world!" - str = "\"\"\"\"\"hello \"\"\" world!\"\"\"\" = foo"; + str = "\"\"\"\"\"hello \"\"\" world!\"\"\"\" == foo"; expectedStr = "\"\"hello \"\"\" world!\""; parsed = expr(str); assertEquals(Equals.class, parsed.getClass()); From af8ca3dd4d6206187c2f80bce3714dfd1a4d941c Mon Sep 17 00:00:00 2001 From: Marios Trivyzas Date: Tue, 29 Sep 2020 19:47:47 +0300 Subject: [PATCH 6/8] Try to allow """ with one escapedwq --- x-pack/plugin/eql/src/main/antlr/EqlBase.g4 | 2 +- .../xpack/eql/parser/AbstractBuilder.java | 6 +- .../xpack/eql/parser/EqlBaseLexer.java | 258 +++++++++--------- .../xpack/eql/parser/ExpressionTests.java | 41 ++- 4 files changed, 159 insertions(+), 148 deletions(-) diff --git a/x-pack/plugin/eql/src/main/antlr/EqlBase.g4 b/x-pack/plugin/eql/src/main/antlr/EqlBase.g4 index cc893e65bb145..9a0f0f5748422 100644 --- a/x-pack/plugin/eql/src/main/antlr/EqlBase.g4 +++ b/x-pack/plugin/eql/src/main/antlr/EqlBase.g4 @@ -200,7 +200,7 @@ STRING | '"' ('\\' [btnfr"'\\] | ~[\r\n"\\])* '"' | '?"' ('\\"' |~["\r\n])* '"' | '?\'' ('\\\'' |~['\r\n])* '\'' - | '"""' (~['\r\n])* '"""' + | '"""' (('\\"""' | '"\\""' | '""\\"' | '\\"\\"\\"') | ~[\r\n])*? '"""' ; INTEGER_VALUE diff --git a/x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/parser/AbstractBuilder.java b/x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/parser/AbstractBuilder.java index c8adc2d97a2a9..52f5c165b4017 100644 --- a/x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/parser/AbstractBuilder.java +++ b/x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/parser/AbstractBuilder.java @@ -130,7 +130,11 @@ public static String unquoteString(Source source) { // unescaped strings can be interpreted directly if (text.startsWith("\"\"\"")) { - return text.substring(3, text.length() - 3); + String str = text.substring(3, text.length() - 3); + return str.replace("\\\"\\\"\\\"", "\"\"\"") + .replace("\\\"\"\"", "\"\"\"") + .replace("\"\\\"\"", "\"\"\"") + .replace("\"\"\\\"", "\"\"\""); } checkForSingleQuotedString(source, text, 0); diff --git a/x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/parser/EqlBaseLexer.java b/x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/parser/EqlBaseLexer.java index b58d2f81a02e6..fa2caa64f12d3 100644 --- a/x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/parser/EqlBaseLexer.java +++ b/x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/parser/EqlBaseLexer.java @@ -106,7 +106,7 @@ public EqlBaseLexer(CharStream input) { public ATN getATN() { return _ATN; } public static final String _serializedATN = - "\3\u0430\ud6d1\u8206\uad2d\u4417\uaef1\u8d80\uaadd\2.\u0194\b\1\4\2\t"+ + "\3\u0430\ud6d1\u8206\uad2d\u4417\uaef1\u8d80\uaadd\2.\u01a8\b\1\4\2\t"+ "\2\4\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7\t\7\4\b\t\b\4\t\t\t\4\n\t\n\4\13"+ "\t\13\4\f\t\f\4\r\t\r\4\16\t\16\4\17\t\17\4\20\t\20\4\21\t\21\4\22\t\22"+ "\4\23\t\23\4\24\t\24\4\25\t\25\4\26\t\26\4\27\t\27\4\30\t\30\4\31\t\31"+ @@ -124,130 +124,138 @@ public EqlBaseLexer(CharStream input) { "&\3&\3\'\3\'\3\'\3\'\7\'\u00ed\n\'\f\'\16\'\u00f0\13\'\3\'\3\'\3\'\3\'"+ "\3\'\7\'\u00f7\n\'\f\'\16\'\u00fa\13\'\3\'\3\'\3\'\3\'\3\'\3\'\3\'\7\'"+ "\u0103\n\'\f\'\16\'\u0106\13\'\3\'\3\'\3\'\3\'\3\'\3\'\3\'\7\'\u010f\n"+ - "\'\f\'\16\'\u0112\13\'\3\'\3\'\3\'\3\'\3\'\3\'\7\'\u011a\n\'\f\'\16\'"+ - "\u011d\13\'\3\'\3\'\3\'\5\'\u0122\n\'\3(\6(\u0125\n(\r(\16(\u0126\3)\6"+ - ")\u012a\n)\r)\16)\u012b\3)\3)\7)\u0130\n)\f)\16)\u0133\13)\3)\3)\6)\u0137"+ - "\n)\r)\16)\u0138\3)\6)\u013c\n)\r)\16)\u013d\3)\3)\7)\u0142\n)\f)\16)"+ - "\u0145\13)\5)\u0147\n)\3)\3)\3)\3)\6)\u014d\n)\r)\16)\u014e\3)\3)\5)\u0153"+ - "\n)\3*\3*\5*\u0157\n*\3*\3*\3*\7*\u015c\n*\f*\16*\u015f\13*\3+\3+\5+\u0163"+ - "\n+\3+\6+\u0166\n+\r+\16+\u0167\3,\3,\3-\3-\3.\3.\3.\3.\7.\u0172\n.\f"+ - ".\16.\u0175\13.\3.\5.\u0178\n.\3.\5.\u017b\n.\3.\3.\3/\3/\3/\3/\3/\7/"+ - "\u0184\n/\f/\16/\u0187\13/\3/\3/\3/\3/\3/\3\60\6\60\u018f\n\60\r\60\16"+ - "\60\u0190\3\60\3\60\3\u0185\2\61\3\3\5\4\7\5\t\6\13\7\r\b\17\t\21\n\23"+ - "\13\25\f\27\r\31\16\33\17\35\20\37\21!\22#\23%\24\'\25)\26+\27-\30/\31"+ - "\61\32\63\33\65\34\67\359\36;\37= ?!A\"C#E$G%I&K\'M(O)Q*S+U\2W\2Y\2[,"+ - "]-_.\3\2\17\3\2bb\n\2$$))^^ddhhppttvv\6\2\f\f\17\17))^^\6\2\f\f\17\17"+ - "$$^^\5\2\f\f\17\17$$\5\2\f\f\17\17))\4\2BBaa\4\2GGgg\4\2--//\3\2\62;\4"+ - "\2C\\c|\4\2\f\f\17\17\5\2\13\f\17\17\"\"\u01b5\2\3\3\2\2\2\2\5\3\2\2\2"+ - "\2\7\3\2\2\2\2\t\3\2\2\2\2\13\3\2\2\2\2\r\3\2\2\2\2\17\3\2\2\2\2\21\3"+ - "\2\2\2\2\23\3\2\2\2\2\25\3\2\2\2\2\27\3\2\2\2\2\31\3\2\2\2\2\33\3\2\2"+ - "\2\2\35\3\2\2\2\2\37\3\2\2\2\2!\3\2\2\2\2#\3\2\2\2\2%\3\2\2\2\2\'\3\2"+ - "\2\2\2)\3\2\2\2\2+\3\2\2\2\2-\3\2\2\2\2/\3\2\2\2\2\61\3\2\2\2\2\63\3\2"+ - "\2\2\2\65\3\2\2\2\2\67\3\2\2\2\29\3\2\2\2\2;\3\2\2\2\2=\3\2\2\2\2?\3\2"+ - "\2\2\2A\3\2\2\2\2C\3\2\2\2\2E\3\2\2\2\2G\3\2\2\2\2I\3\2\2\2\2K\3\2\2\2"+ - "\2M\3\2\2\2\2O\3\2\2\2\2Q\3\2\2\2\2S\3\2\2\2\2[\3\2\2\2\2]\3\2\2\2\2_"+ - "\3\2\2\2\3a\3\2\2\2\5e\3\2\2\2\7i\3\2\2\2\tl\3\2\2\2\13r\3\2\2\2\rw\3"+ - "\2\2\2\17z\3\2\2\2\21\177\3\2\2\2\23\u0087\3\2\2\2\25\u008b\3\2\2\2\27"+ - "\u0090\3\2\2\2\31\u0093\3\2\2\2\33\u0096\3\2\2\2\35\u009f\3\2\2\2\37\u00a4"+ - "\3\2\2\2!\u00aa\3\2\2\2#\u00b0\3\2\2\2%\u00b5\3\2\2\2\'\u00b7\3\2\2\2"+ - ")\u00ba\3\2\2\2+\u00bd\3\2\2\2-\u00bf\3\2\2\2/\u00c2\3\2\2\2\61\u00c4"+ - "\3\2\2\2\63\u00c7\3\2\2\2\65\u00c9\3\2\2\2\67\u00cb\3\2\2\29\u00cd\3\2"+ - "\2\2;\u00cf\3\2\2\2=\u00d1\3\2\2\2?\u00d3\3\2\2\2A\u00d5\3\2\2\2C\u00d7"+ - "\3\2\2\2E\u00d9\3\2\2\2G\u00db\3\2\2\2I\u00dd\3\2\2\2K\u00df\3\2\2\2M"+ - "\u0121\3\2\2\2O\u0124\3\2\2\2Q\u0152\3\2\2\2S\u0156\3\2\2\2U\u0160\3\2"+ - "\2\2W\u0169\3\2\2\2Y\u016b\3\2\2\2[\u016d\3\2\2\2]\u017e\3\2\2\2_\u018e"+ - "\3\2\2\2ab\7c\2\2bc\7p\2\2cd\7f\2\2d\4\3\2\2\2ef\7c\2\2fg\7p\2\2gh\7{"+ - "\2\2h\6\3\2\2\2ij\7d\2\2jk\7{\2\2k\b\3\2\2\2lm\7h\2\2mn\7c\2\2no\7n\2"+ - "\2op\7u\2\2pq\7g\2\2q\n\3\2\2\2rs\7h\2\2st\7q\2\2tu\7t\2\2uv\7m\2\2v\f"+ - "\3\2\2\2wx\7k\2\2xy\7p\2\2y\16\3\2\2\2z{\7l\2\2{|\7q\2\2|}\7k\2\2}~\7"+ - "p\2\2~\20\3\2\2\2\177\u0080\7o\2\2\u0080\u0081\7c\2\2\u0081\u0082\7z\2"+ - "\2\u0082\u0083\7u\2\2\u0083\u0084\7r\2\2\u0084\u0085\7c\2\2\u0085\u0086"+ - "\7p\2\2\u0086\22\3\2\2\2\u0087\u0088\7p\2\2\u0088\u0089\7q\2\2\u0089\u008a"+ - "\7v\2\2\u008a\24\3\2\2\2\u008b\u008c\7p\2\2\u008c\u008d\7w\2\2\u008d\u008e"+ - "\7n\2\2\u008e\u008f\7n\2\2\u008f\26\3\2\2\2\u0090\u0091\7q\2\2\u0091\u0092"+ - "\7h\2\2\u0092\30\3\2\2\2\u0093\u0094\7q\2\2\u0094\u0095\7t\2\2\u0095\32"+ - "\3\2\2\2\u0096\u0097\7u\2\2\u0097\u0098\7g\2\2\u0098\u0099\7s\2\2\u0099"+ - "\u009a\7w\2\2\u009a\u009b\7g\2\2\u009b\u009c\7p\2\2\u009c\u009d\7e\2\2"+ - "\u009d\u009e\7g\2\2\u009e\34\3\2\2\2\u009f\u00a0\7v\2\2\u00a0\u00a1\7"+ - "t\2\2\u00a1\u00a2\7w\2\2\u00a2\u00a3\7g\2\2\u00a3\36\3\2\2\2\u00a4\u00a5"+ - "\7w\2\2\u00a5\u00a6\7p\2\2\u00a6\u00a7\7v\2\2\u00a7\u00a8\7k\2\2\u00a8"+ - "\u00a9\7n\2\2\u00a9 \3\2\2\2\u00aa\u00ab\7y\2\2\u00ab\u00ac\7j\2\2\u00ac"+ - "\u00ad\7g\2\2\u00ad\u00ae\7t\2\2\u00ae\u00af\7g\2\2\u00af\"\3\2\2\2\u00b0"+ - "\u00b1\7y\2\2\u00b1\u00b2\7k\2\2\u00b2\u00b3\7v\2\2\u00b3\u00b4\7j\2\2"+ - "\u00b4$\3\2\2\2\u00b5\u00b6\7?\2\2\u00b6&\3\2\2\2\u00b7\u00b8\7?\2\2\u00b8"+ - "\u00b9\7?\2\2\u00b9(\3\2\2\2\u00ba\u00bb\7#\2\2\u00bb\u00bc\7?\2\2\u00bc"+ - "*\3\2\2\2\u00bd\u00be\7>\2\2\u00be,\3\2\2\2\u00bf\u00c0\7>\2\2\u00c0\u00c1"+ - "\7?\2\2\u00c1.\3\2\2\2\u00c2\u00c3\7@\2\2\u00c3\60\3\2\2\2\u00c4\u00c5"+ - "\7@\2\2\u00c5\u00c6\7?\2\2\u00c6\62\3\2\2\2\u00c7\u00c8\7-\2\2\u00c8\64"+ - "\3\2\2\2\u00c9\u00ca\7/\2\2\u00ca\66\3\2\2\2\u00cb\u00cc\7,\2\2\u00cc"+ - "8\3\2\2\2\u00cd\u00ce\7\61\2\2\u00ce:\3\2\2\2\u00cf\u00d0\7\'\2\2\u00d0"+ - "<\3\2\2\2\u00d1\u00d2\7\60\2\2\u00d2>\3\2\2\2\u00d3\u00d4\7.\2\2\u00d4"+ - "@\3\2\2\2\u00d5\u00d6\7]\2\2\u00d6B\3\2\2\2\u00d7\u00d8\7_\2\2\u00d8D"+ - "\3\2\2\2\u00d9\u00da\7*\2\2\u00daF\3\2\2\2\u00db\u00dc\7+\2\2\u00dcH\3"+ - "\2\2\2\u00dd\u00de\7~\2\2\u00deJ\3\2\2\2\u00df\u00e3\7b\2\2\u00e0\u00e2"+ - "\n\2\2\2\u00e1\u00e0\3\2\2\2\u00e2\u00e5\3\2\2\2\u00e3\u00e1\3\2\2\2\u00e3"+ - "\u00e4\3\2\2\2\u00e4\u00e6\3\2\2\2\u00e5\u00e3\3\2\2\2\u00e6\u00e7\7b"+ - "\2\2\u00e7L\3\2\2\2\u00e8\u00ee\7)\2\2\u00e9\u00ea\7^\2\2\u00ea\u00ed"+ - "\t\3\2\2\u00eb\u00ed\n\4\2\2\u00ec\u00e9\3\2\2\2\u00ec\u00eb\3\2\2\2\u00ed"+ - "\u00f0\3\2\2\2\u00ee\u00ec\3\2\2\2\u00ee\u00ef\3\2\2\2\u00ef\u00f1\3\2"+ - "\2\2\u00f0\u00ee\3\2\2\2\u00f1\u0122\7)\2\2\u00f2\u00f8\7$\2\2\u00f3\u00f4"+ - "\7^\2\2\u00f4\u00f7\t\3\2\2\u00f5\u00f7\n\5\2\2\u00f6\u00f3\3\2\2\2\u00f6"+ - "\u00f5\3\2\2\2\u00f7\u00fa\3\2\2\2\u00f8\u00f6\3\2\2\2\u00f8\u00f9\3\2"+ - "\2\2\u00f9\u00fb\3\2\2\2\u00fa\u00f8\3\2\2\2\u00fb\u0122\7$\2\2\u00fc"+ - "\u00fd\7A\2\2\u00fd\u00fe\7$\2\2\u00fe\u0104\3\2\2\2\u00ff\u0100\7^\2"+ - "\2\u0100\u0103\7$\2\2\u0101\u0103\n\6\2\2\u0102\u00ff\3\2\2\2\u0102\u0101"+ - "\3\2\2\2\u0103\u0106\3\2\2\2\u0104\u0102\3\2\2\2\u0104\u0105\3\2\2\2\u0105"+ - "\u0107\3\2\2\2\u0106\u0104\3\2\2\2\u0107\u0122\7$\2\2\u0108\u0109\7A\2"+ - "\2\u0109\u010a\7)\2\2\u010a\u0110\3\2\2\2\u010b\u010c\7^\2\2\u010c\u010f"+ - "\7)\2\2\u010d\u010f\n\7\2\2\u010e\u010b\3\2\2\2\u010e\u010d\3\2\2\2\u010f"+ - "\u0112\3\2\2\2\u0110\u010e\3\2\2\2\u0110\u0111\3\2\2\2\u0111\u0113\3\2"+ - "\2\2\u0112\u0110\3\2\2\2\u0113\u0122\7)\2\2\u0114\u0115\7$\2\2\u0115\u0116"+ - "\7$\2\2\u0116\u0117\7$\2\2\u0117\u011b\3\2\2\2\u0118\u011a\n\7\2\2\u0119"+ - "\u0118\3\2\2\2\u011a\u011d\3\2\2\2\u011b\u0119\3\2\2\2\u011b\u011c\3\2"+ - "\2\2\u011c\u011e\3\2\2\2\u011d\u011b\3\2\2\2\u011e\u011f\7$\2\2\u011f"+ - "\u0120\7$\2\2\u0120\u0122\7$\2\2\u0121\u00e8\3\2\2\2\u0121\u00f2\3\2\2"+ - "\2\u0121\u00fc\3\2\2\2\u0121\u0108\3\2\2\2\u0121\u0114\3\2\2\2\u0122N"+ - "\3\2\2\2\u0123\u0125\5W,\2\u0124\u0123\3\2\2\2\u0125\u0126\3\2\2\2\u0126"+ - "\u0124\3\2\2\2\u0126\u0127\3\2\2\2\u0127P\3\2\2\2\u0128\u012a\5W,\2\u0129"+ - "\u0128\3\2\2\2\u012a\u012b\3\2\2\2\u012b\u0129\3\2\2\2\u012b\u012c\3\2"+ - "\2\2\u012c\u012d\3\2\2\2\u012d\u0131\5=\37\2\u012e\u0130\5W,\2\u012f\u012e"+ - "\3\2\2\2\u0130\u0133\3\2\2\2\u0131\u012f\3\2\2\2\u0131\u0132\3\2\2\2\u0132"+ - "\u0153\3\2\2\2\u0133\u0131\3\2\2\2\u0134\u0136\5=\37\2\u0135\u0137\5W"+ - ",\2\u0136\u0135\3\2\2\2\u0137\u0138\3\2\2\2\u0138\u0136\3\2\2\2\u0138"+ - "\u0139\3\2\2\2\u0139\u0153\3\2\2\2\u013a\u013c\5W,\2\u013b\u013a\3\2\2"+ - "\2\u013c\u013d\3\2\2\2\u013d\u013b\3\2\2\2\u013d\u013e\3\2\2\2\u013e\u0146"+ - "\3\2\2\2\u013f\u0143\5=\37\2\u0140\u0142\5W,\2\u0141\u0140\3\2\2\2\u0142"+ - "\u0145\3\2\2\2\u0143\u0141\3\2\2\2\u0143\u0144\3\2\2\2\u0144\u0147\3\2"+ - "\2\2\u0145\u0143\3\2\2\2\u0146\u013f\3\2\2\2\u0146\u0147\3\2\2\2\u0147"+ - "\u0148\3\2\2\2\u0148\u0149\5U+\2\u0149\u0153\3\2\2\2\u014a\u014c\5=\37"+ - "\2\u014b\u014d\5W,\2\u014c\u014b\3\2\2\2\u014d\u014e\3\2\2\2\u014e\u014c"+ - "\3\2\2\2\u014e\u014f\3\2\2\2\u014f\u0150\3\2\2\2\u0150\u0151\5U+\2\u0151"+ - "\u0153\3\2\2\2\u0152\u0129\3\2\2\2\u0152\u0134\3\2\2\2\u0152\u013b\3\2"+ - "\2\2\u0152\u014a\3\2\2\2\u0153R\3\2\2\2\u0154\u0157\5Y-\2\u0155\u0157"+ - "\t\b\2\2\u0156\u0154\3\2\2\2\u0156\u0155\3\2\2\2\u0157\u015d\3\2\2\2\u0158"+ - "\u015c\5Y-\2\u0159\u015c\5W,\2\u015a\u015c\7a\2\2\u015b\u0158\3\2\2\2"+ - "\u015b\u0159\3\2\2\2\u015b\u015a\3\2\2\2\u015c\u015f\3\2\2\2\u015d\u015b"+ - "\3\2\2\2\u015d\u015e\3\2\2\2\u015eT\3\2\2\2\u015f\u015d\3\2\2\2\u0160"+ - "\u0162\t\t\2\2\u0161\u0163\t\n\2\2\u0162\u0161\3\2\2\2\u0162\u0163\3\2"+ - "\2\2\u0163\u0165\3\2\2\2\u0164\u0166\5W,\2\u0165\u0164\3\2\2\2\u0166\u0167"+ - "\3\2\2\2\u0167\u0165\3\2\2\2\u0167\u0168\3\2\2\2\u0168V\3\2\2\2\u0169"+ - "\u016a\t\13\2\2\u016aX\3\2\2\2\u016b\u016c\t\f\2\2\u016cZ\3\2\2\2\u016d"+ - "\u016e\7\61\2\2\u016e\u016f\7\61\2\2\u016f\u0173\3\2\2\2\u0170\u0172\n"+ - "\r\2\2\u0171\u0170\3\2\2\2\u0172\u0175\3\2\2\2\u0173\u0171\3\2\2\2\u0173"+ - "\u0174\3\2\2\2\u0174\u0177\3\2\2\2\u0175\u0173\3\2\2\2\u0176\u0178\7\17"+ - "\2\2\u0177\u0176\3\2\2\2\u0177\u0178\3\2\2\2\u0178\u017a\3\2\2\2\u0179"+ - "\u017b\7\f\2\2\u017a\u0179\3\2\2\2\u017a\u017b\3\2\2\2\u017b\u017c\3\2"+ - "\2\2\u017c\u017d\b.\2\2\u017d\\\3\2\2\2\u017e\u017f\7\61\2\2\u017f\u0180"+ - "\7,\2\2\u0180\u0185\3\2\2\2\u0181\u0184\5]/\2\u0182\u0184\13\2\2\2\u0183"+ - "\u0181\3\2\2\2\u0183\u0182\3\2\2\2\u0184\u0187\3\2\2\2\u0185\u0186\3\2"+ - "\2\2\u0185\u0183\3\2\2\2\u0186\u0188\3\2\2\2\u0187\u0185\3\2\2\2\u0188"+ - "\u0189\7,\2\2\u0189\u018a\7\61\2\2\u018a\u018b\3\2\2\2\u018b\u018c\b/"+ - "\2\2\u018c^\3\2\2\2\u018d\u018f\t\16\2\2\u018e\u018d\3\2\2\2\u018f\u0190"+ - "\3\2\2\2\u0190\u018e\3\2\2\2\u0190\u0191\3\2\2\2\u0191\u0192\3\2\2\2\u0192"+ - "\u0193\b\60\2\2\u0193`\3\2\2\2\"\2\u00e3\u00ec\u00ee\u00f6\u00f8\u0102"+ - "\u0104\u010e\u0110\u011b\u0121\u0126\u012b\u0131\u0138\u013d\u0143\u0146"+ - "\u014e\u0152\u0156\u015b\u015d\u0162\u0167\u0173\u0177\u017a\u0183\u0185"+ - "\u0190\3\2\3\2"; + "\'\f\'\16\'\u0112\13\'\3\'\3\'\3\'\3\'\3\'\3\'\3\'\3\'\3\'\3\'\3\'\3\'"+ + "\3\'\3\'\3\'\3\'\3\'\3\'\3\'\3\'\3\'\3\'\3\'\5\'\u012b\n\'\3\'\7\'\u012e"+ + "\n\'\f\'\16\'\u0131\13\'\3\'\3\'\3\'\5\'\u0136\n\'\3(\6(\u0139\n(\r(\16"+ + "(\u013a\3)\6)\u013e\n)\r)\16)\u013f\3)\3)\7)\u0144\n)\f)\16)\u0147\13"+ + ")\3)\3)\6)\u014b\n)\r)\16)\u014c\3)\6)\u0150\n)\r)\16)\u0151\3)\3)\7)"+ + "\u0156\n)\f)\16)\u0159\13)\5)\u015b\n)\3)\3)\3)\3)\6)\u0161\n)\r)\16)"+ + "\u0162\3)\3)\5)\u0167\n)\3*\3*\5*\u016b\n*\3*\3*\3*\7*\u0170\n*\f*\16"+ + "*\u0173\13*\3+\3+\5+\u0177\n+\3+\6+\u017a\n+\r+\16+\u017b\3,\3,\3-\3-"+ + "\3.\3.\3.\3.\7.\u0186\n.\f.\16.\u0189\13.\3.\5.\u018c\n.\3.\5.\u018f\n"+ + ".\3.\3.\3/\3/\3/\3/\3/\7/\u0198\n/\f/\16/\u019b\13/\3/\3/\3/\3/\3/\3\60"+ + "\6\60\u01a3\n\60\r\60\16\60\u01a4\3\60\3\60\4\u012f\u0199\2\61\3\3\5\4"+ + "\7\5\t\6\13\7\r\b\17\t\21\n\23\13\25\f\27\r\31\16\33\17\35\20\37\21!\22"+ + "#\23%\24\'\25)\26+\27-\30/\31\61\32\63\33\65\34\67\359\36;\37= ?!A\"C"+ + "#E$G%I&K\'M(O)Q*S+U\2W\2Y\2[,]-_.\3\2\17\3\2bb\n\2$$))^^ddhhppttvv\6\2"+ + "\f\f\17\17))^^\6\2\f\f\17\17$$^^\5\2\f\f\17\17$$\5\2\f\f\17\17))\4\2\f"+ + "\f\17\17\4\2BBaa\4\2GGgg\4\2--//\3\2\62;\4\2C\\c|\5\2\13\f\17\17\"\"\u01cd"+ + "\2\3\3\2\2\2\2\5\3\2\2\2\2\7\3\2\2\2\2\t\3\2\2\2\2\13\3\2\2\2\2\r\3\2"+ + "\2\2\2\17\3\2\2\2\2\21\3\2\2\2\2\23\3\2\2\2\2\25\3\2\2\2\2\27\3\2\2\2"+ + "\2\31\3\2\2\2\2\33\3\2\2\2\2\35\3\2\2\2\2\37\3\2\2\2\2!\3\2\2\2\2#\3\2"+ + "\2\2\2%\3\2\2\2\2\'\3\2\2\2\2)\3\2\2\2\2+\3\2\2\2\2-\3\2\2\2\2/\3\2\2"+ + "\2\2\61\3\2\2\2\2\63\3\2\2\2\2\65\3\2\2\2\2\67\3\2\2\2\29\3\2\2\2\2;\3"+ + "\2\2\2\2=\3\2\2\2\2?\3\2\2\2\2A\3\2\2\2\2C\3\2\2\2\2E\3\2\2\2\2G\3\2\2"+ + "\2\2I\3\2\2\2\2K\3\2\2\2\2M\3\2\2\2\2O\3\2\2\2\2Q\3\2\2\2\2S\3\2\2\2\2"+ + "[\3\2\2\2\2]\3\2\2\2\2_\3\2\2\2\3a\3\2\2\2\5e\3\2\2\2\7i\3\2\2\2\tl\3"+ + "\2\2\2\13r\3\2\2\2\rw\3\2\2\2\17z\3\2\2\2\21\177\3\2\2\2\23\u0087\3\2"+ + "\2\2\25\u008b\3\2\2\2\27\u0090\3\2\2\2\31\u0093\3\2\2\2\33\u0096\3\2\2"+ + "\2\35\u009f\3\2\2\2\37\u00a4\3\2\2\2!\u00aa\3\2\2\2#\u00b0\3\2\2\2%\u00b5"+ + "\3\2\2\2\'\u00b7\3\2\2\2)\u00ba\3\2\2\2+\u00bd\3\2\2\2-\u00bf\3\2\2\2"+ + "/\u00c2\3\2\2\2\61\u00c4\3\2\2\2\63\u00c7\3\2\2\2\65\u00c9\3\2\2\2\67"+ + "\u00cb\3\2\2\29\u00cd\3\2\2\2;\u00cf\3\2\2\2=\u00d1\3\2\2\2?\u00d3\3\2"+ + "\2\2A\u00d5\3\2\2\2C\u00d7\3\2\2\2E\u00d9\3\2\2\2G\u00db\3\2\2\2I\u00dd"+ + "\3\2\2\2K\u00df\3\2\2\2M\u0135\3\2\2\2O\u0138\3\2\2\2Q\u0166\3\2\2\2S"+ + "\u016a\3\2\2\2U\u0174\3\2\2\2W\u017d\3\2\2\2Y\u017f\3\2\2\2[\u0181\3\2"+ + "\2\2]\u0192\3\2\2\2_\u01a2\3\2\2\2ab\7c\2\2bc\7p\2\2cd\7f\2\2d\4\3\2\2"+ + "\2ef\7c\2\2fg\7p\2\2gh\7{\2\2h\6\3\2\2\2ij\7d\2\2jk\7{\2\2k\b\3\2\2\2"+ + "lm\7h\2\2mn\7c\2\2no\7n\2\2op\7u\2\2pq\7g\2\2q\n\3\2\2\2rs\7h\2\2st\7"+ + "q\2\2tu\7t\2\2uv\7m\2\2v\f\3\2\2\2wx\7k\2\2xy\7p\2\2y\16\3\2\2\2z{\7l"+ + "\2\2{|\7q\2\2|}\7k\2\2}~\7p\2\2~\20\3\2\2\2\177\u0080\7o\2\2\u0080\u0081"+ + "\7c\2\2\u0081\u0082\7z\2\2\u0082\u0083\7u\2\2\u0083\u0084\7r\2\2\u0084"+ + "\u0085\7c\2\2\u0085\u0086\7p\2\2\u0086\22\3\2\2\2\u0087\u0088\7p\2\2\u0088"+ + "\u0089\7q\2\2\u0089\u008a\7v\2\2\u008a\24\3\2\2\2\u008b\u008c\7p\2\2\u008c"+ + "\u008d\7w\2\2\u008d\u008e\7n\2\2\u008e\u008f\7n\2\2\u008f\26\3\2\2\2\u0090"+ + "\u0091\7q\2\2\u0091\u0092\7h\2\2\u0092\30\3\2\2\2\u0093\u0094\7q\2\2\u0094"+ + "\u0095\7t\2\2\u0095\32\3\2\2\2\u0096\u0097\7u\2\2\u0097\u0098\7g\2\2\u0098"+ + "\u0099\7s\2\2\u0099\u009a\7w\2\2\u009a\u009b\7g\2\2\u009b\u009c\7p\2\2"+ + "\u009c\u009d\7e\2\2\u009d\u009e\7g\2\2\u009e\34\3\2\2\2\u009f\u00a0\7"+ + "v\2\2\u00a0\u00a1\7t\2\2\u00a1\u00a2\7w\2\2\u00a2\u00a3\7g\2\2\u00a3\36"+ + "\3\2\2\2\u00a4\u00a5\7w\2\2\u00a5\u00a6\7p\2\2\u00a6\u00a7\7v\2\2\u00a7"+ + "\u00a8\7k\2\2\u00a8\u00a9\7n\2\2\u00a9 \3\2\2\2\u00aa\u00ab\7y\2\2\u00ab"+ + "\u00ac\7j\2\2\u00ac\u00ad\7g\2\2\u00ad\u00ae\7t\2\2\u00ae\u00af\7g\2\2"+ + "\u00af\"\3\2\2\2\u00b0\u00b1\7y\2\2\u00b1\u00b2\7k\2\2\u00b2\u00b3\7v"+ + "\2\2\u00b3\u00b4\7j\2\2\u00b4$\3\2\2\2\u00b5\u00b6\7?\2\2\u00b6&\3\2\2"+ + "\2\u00b7\u00b8\7?\2\2\u00b8\u00b9\7?\2\2\u00b9(\3\2\2\2\u00ba\u00bb\7"+ + "#\2\2\u00bb\u00bc\7?\2\2\u00bc*\3\2\2\2\u00bd\u00be\7>\2\2\u00be,\3\2"+ + "\2\2\u00bf\u00c0\7>\2\2\u00c0\u00c1\7?\2\2\u00c1.\3\2\2\2\u00c2\u00c3"+ + "\7@\2\2\u00c3\60\3\2\2\2\u00c4\u00c5\7@\2\2\u00c5\u00c6\7?\2\2\u00c6\62"+ + "\3\2\2\2\u00c7\u00c8\7-\2\2\u00c8\64\3\2\2\2\u00c9\u00ca\7/\2\2\u00ca"+ + "\66\3\2\2\2\u00cb\u00cc\7,\2\2\u00cc8\3\2\2\2\u00cd\u00ce\7\61\2\2\u00ce"+ + ":\3\2\2\2\u00cf\u00d0\7\'\2\2\u00d0<\3\2\2\2\u00d1\u00d2\7\60\2\2\u00d2"+ + ">\3\2\2\2\u00d3\u00d4\7.\2\2\u00d4@\3\2\2\2\u00d5\u00d6\7]\2\2\u00d6B"+ + "\3\2\2\2\u00d7\u00d8\7_\2\2\u00d8D\3\2\2\2\u00d9\u00da\7*\2\2\u00daF\3"+ + "\2\2\2\u00db\u00dc\7+\2\2\u00dcH\3\2\2\2\u00dd\u00de\7~\2\2\u00deJ\3\2"+ + "\2\2\u00df\u00e3\7b\2\2\u00e0\u00e2\n\2\2\2\u00e1\u00e0\3\2\2\2\u00e2"+ + "\u00e5\3\2\2\2\u00e3\u00e1\3\2\2\2\u00e3\u00e4\3\2\2\2\u00e4\u00e6\3\2"+ + "\2\2\u00e5\u00e3\3\2\2\2\u00e6\u00e7\7b\2\2\u00e7L\3\2\2\2\u00e8\u00ee"+ + "\7)\2\2\u00e9\u00ea\7^\2\2\u00ea\u00ed\t\3\2\2\u00eb\u00ed\n\4\2\2\u00ec"+ + "\u00e9\3\2\2\2\u00ec\u00eb\3\2\2\2\u00ed\u00f0\3\2\2\2\u00ee\u00ec\3\2"+ + "\2\2\u00ee\u00ef\3\2\2\2\u00ef\u00f1\3\2\2\2\u00f0\u00ee\3\2\2\2\u00f1"+ + "\u0136\7)\2\2\u00f2\u00f8\7$\2\2\u00f3\u00f4\7^\2\2\u00f4\u00f7\t\3\2"+ + "\2\u00f5\u00f7\n\5\2\2\u00f6\u00f3\3\2\2\2\u00f6\u00f5\3\2\2\2\u00f7\u00fa"+ + "\3\2\2\2\u00f8\u00f6\3\2\2\2\u00f8\u00f9\3\2\2\2\u00f9\u00fb\3\2\2\2\u00fa"+ + "\u00f8\3\2\2\2\u00fb\u0136\7$\2\2\u00fc\u00fd\7A\2\2\u00fd\u00fe\7$\2"+ + "\2\u00fe\u0104\3\2\2\2\u00ff\u0100\7^\2\2\u0100\u0103\7$\2\2\u0101\u0103"+ + "\n\6\2\2\u0102\u00ff\3\2\2\2\u0102\u0101\3\2\2\2\u0103\u0106\3\2\2\2\u0104"+ + "\u0102\3\2\2\2\u0104\u0105\3\2\2\2\u0105\u0107\3\2\2\2\u0106\u0104\3\2"+ + "\2\2\u0107\u0136\7$\2\2\u0108\u0109\7A\2\2\u0109\u010a\7)\2\2\u010a\u0110"+ + "\3\2\2\2\u010b\u010c\7^\2\2\u010c\u010f\7)\2\2\u010d\u010f\n\7\2\2\u010e"+ + "\u010b\3\2\2\2\u010e\u010d\3\2\2\2\u010f\u0112\3\2\2\2\u0110\u010e\3\2"+ + "\2\2\u0110\u0111\3\2\2\2\u0111\u0113\3\2\2\2\u0112\u0110\3\2\2\2\u0113"+ + "\u0136\7)\2\2\u0114\u0115\7$\2\2\u0115\u0116\7$\2\2\u0116\u0117\7$\2\2"+ + "\u0117\u012f\3\2\2\2\u0118\u0119\7^\2\2\u0119\u011a\7$\2\2\u011a\u011b"+ + "\7$\2\2\u011b\u012b\7$\2\2\u011c\u011d\7$\2\2\u011d\u011e\7^\2\2\u011e"+ + "\u011f\7$\2\2\u011f\u012b\7$\2\2\u0120\u0121\7$\2\2\u0121\u0122\7$\2\2"+ + "\u0122\u0123\7^\2\2\u0123\u012b\7$\2\2\u0124\u0125\7^\2\2\u0125\u0126"+ + "\7$\2\2\u0126\u0127\7^\2\2\u0127\u0128\7$\2\2\u0128\u0129\7^\2\2\u0129"+ + "\u012b\7$\2\2\u012a\u0118\3\2\2\2\u012a\u011c\3\2\2\2\u012a\u0120\3\2"+ + "\2\2\u012a\u0124\3\2\2\2\u012b\u012e\3\2\2\2\u012c\u012e\n\b\2\2\u012d"+ + "\u012a\3\2\2\2\u012d\u012c\3\2\2\2\u012e\u0131\3\2\2\2\u012f\u0130\3\2"+ + "\2\2\u012f\u012d\3\2\2\2\u0130\u0132\3\2\2\2\u0131\u012f\3\2\2\2\u0132"+ + "\u0133\7$\2\2\u0133\u0134\7$\2\2\u0134\u0136\7$\2\2\u0135\u00e8\3\2\2"+ + "\2\u0135\u00f2\3\2\2\2\u0135\u00fc\3\2\2\2\u0135\u0108\3\2\2\2\u0135\u0114"+ + "\3\2\2\2\u0136N\3\2\2\2\u0137\u0139\5W,\2\u0138\u0137\3\2\2\2\u0139\u013a"+ + "\3\2\2\2\u013a\u0138\3\2\2\2\u013a\u013b\3\2\2\2\u013bP\3\2\2\2\u013c"+ + "\u013e\5W,\2\u013d\u013c\3\2\2\2\u013e\u013f\3\2\2\2\u013f\u013d\3\2\2"+ + "\2\u013f\u0140\3\2\2\2\u0140\u0141\3\2\2\2\u0141\u0145\5=\37\2\u0142\u0144"+ + "\5W,\2\u0143\u0142\3\2\2\2\u0144\u0147\3\2\2\2\u0145\u0143\3\2\2\2\u0145"+ + "\u0146\3\2\2\2\u0146\u0167\3\2\2\2\u0147\u0145\3\2\2\2\u0148\u014a\5="+ + "\37\2\u0149\u014b\5W,\2\u014a\u0149\3\2\2\2\u014b\u014c\3\2\2\2\u014c"+ + "\u014a\3\2\2\2\u014c\u014d\3\2\2\2\u014d\u0167\3\2\2\2\u014e\u0150\5W"+ + ",\2\u014f\u014e\3\2\2\2\u0150\u0151\3\2\2\2\u0151\u014f\3\2\2\2\u0151"+ + "\u0152\3\2\2\2\u0152\u015a\3\2\2\2\u0153\u0157\5=\37\2\u0154\u0156\5W"+ + ",\2\u0155\u0154\3\2\2\2\u0156\u0159\3\2\2\2\u0157\u0155\3\2\2\2\u0157"+ + "\u0158\3\2\2\2\u0158\u015b\3\2\2\2\u0159\u0157\3\2\2\2\u015a\u0153\3\2"+ + "\2\2\u015a\u015b\3\2\2\2\u015b\u015c\3\2\2\2\u015c\u015d\5U+\2\u015d\u0167"+ + "\3\2\2\2\u015e\u0160\5=\37\2\u015f\u0161\5W,\2\u0160\u015f\3\2\2\2\u0161"+ + "\u0162\3\2\2\2\u0162\u0160\3\2\2\2\u0162\u0163\3\2\2\2\u0163\u0164\3\2"+ + "\2\2\u0164\u0165\5U+\2\u0165\u0167\3\2\2\2\u0166\u013d\3\2\2\2\u0166\u0148"+ + "\3\2\2\2\u0166\u014f\3\2\2\2\u0166\u015e\3\2\2\2\u0167R\3\2\2\2\u0168"+ + "\u016b\5Y-\2\u0169\u016b\t\t\2\2\u016a\u0168\3\2\2\2\u016a\u0169\3\2\2"+ + "\2\u016b\u0171\3\2\2\2\u016c\u0170\5Y-\2\u016d\u0170\5W,\2\u016e\u0170"+ + "\7a\2\2\u016f\u016c\3\2\2\2\u016f\u016d\3\2\2\2\u016f\u016e\3\2\2\2\u0170"+ + "\u0173\3\2\2\2\u0171\u016f\3\2\2\2\u0171\u0172\3\2\2\2\u0172T\3\2\2\2"+ + "\u0173\u0171\3\2\2\2\u0174\u0176\t\n\2\2\u0175\u0177\t\13\2\2\u0176\u0175"+ + "\3\2\2\2\u0176\u0177\3\2\2\2\u0177\u0179\3\2\2\2\u0178\u017a\5W,\2\u0179"+ + "\u0178\3\2\2\2\u017a\u017b\3\2\2\2\u017b\u0179\3\2\2\2\u017b\u017c\3\2"+ + "\2\2\u017cV\3\2\2\2\u017d\u017e\t\f\2\2\u017eX\3\2\2\2\u017f\u0180\t\r"+ + "\2\2\u0180Z\3\2\2\2\u0181\u0182\7\61\2\2\u0182\u0183\7\61\2\2\u0183\u0187"+ + "\3\2\2\2\u0184\u0186\n\b\2\2\u0185\u0184\3\2\2\2\u0186\u0189\3\2\2\2\u0187"+ + "\u0185\3\2\2\2\u0187\u0188\3\2\2\2\u0188\u018b\3\2\2\2\u0189\u0187\3\2"+ + "\2\2\u018a\u018c\7\17\2\2\u018b\u018a\3\2\2\2\u018b\u018c\3\2\2\2\u018c"+ + "\u018e\3\2\2\2\u018d\u018f\7\f\2\2\u018e\u018d\3\2\2\2\u018e\u018f\3\2"+ + "\2\2\u018f\u0190\3\2\2\2\u0190\u0191\b.\2\2\u0191\\\3\2\2\2\u0192\u0193"+ + "\7\61\2\2\u0193\u0194\7,\2\2\u0194\u0199\3\2\2\2\u0195\u0198\5]/\2\u0196"+ + "\u0198\13\2\2\2\u0197\u0195\3\2\2\2\u0197\u0196\3\2\2\2\u0198\u019b\3"+ + "\2\2\2\u0199\u019a\3\2\2\2\u0199\u0197\3\2\2\2\u019a\u019c\3\2\2\2\u019b"+ + "\u0199\3\2\2\2\u019c\u019d\7,\2\2\u019d\u019e\7\61\2\2\u019e\u019f\3\2"+ + "\2\2\u019f\u01a0\b/\2\2\u01a0^\3\2\2\2\u01a1\u01a3\t\16\2\2\u01a2\u01a1"+ + "\3\2\2\2\u01a3\u01a4\3\2\2\2\u01a4\u01a2\3\2\2\2\u01a4\u01a5\3\2\2\2\u01a5"+ + "\u01a6\3\2\2\2\u01a6\u01a7\b\60\2\2\u01a7`\3\2\2\2$\2\u00e3\u00ec\u00ee"+ + "\u00f6\u00f8\u0102\u0104\u010e\u0110\u012a\u012d\u012f\u0135\u013a\u013f"+ + "\u0145\u014c\u0151\u0157\u015a\u0162\u0166\u016a\u016f\u0171\u0176\u017b"+ + "\u0187\u018b\u018e\u0197\u0199\u01a4\3\2\3\2"; public static final ATN _ATN = new ATNDeserializer().deserialize(_serializedATN.toCharArray()); static { diff --git a/x-pack/plugin/eql/src/test/java/org/elasticsearch/xpack/eql/parser/ExpressionTests.java b/x-pack/plugin/eql/src/test/java/org/elasticsearch/xpack/eql/parser/ExpressionTests.java index 524c437a5b41f..0da1228a9ce48 100644 --- a/x-pack/plugin/eql/src/test/java/org/elasticsearch/xpack/eql/parser/ExpressionTests.java +++ b/x-pack/plugin/eql/src/test/java/org/elasticsearch/xpack/eql/parser/ExpressionTests.java @@ -76,6 +76,11 @@ public void testStrings() { assertEquals("hello\\\\\\nworld", unquoteString(source("\"\"\"hello\\\\\\nworld\"\"\""))); assertEquals("hello\\\\\\\"world", unquoteString(source("\"\"\"hello\\\\\\\"world\"\"\""))); assertEquals("\"\\\"", unquoteString(source("\"\"\"\"\\\"\"\"\""))); + assertEquals("\"\"\"", unquoteString(source("\"\"\"\\\"\"\"\"\"\""))); + assertEquals("\"\"\"", unquoteString(source("\"\"\"\"\\\"\"\"\"\""))); + assertEquals("\"\"\"", unquoteString(source("\"\"\"\"\"\\\"\"\"\""))); + assertEquals("\"\"", unquoteString(source("\"\"\"\"\"\"\"\""))); + assertEquals("\"\" \"\"", unquoteString(source("\"\"\"\"\" \"\"\"\"\""))); assertEquals("", unquoteString(source("\"\"\"\"\"\""))); } @@ -120,35 +125,29 @@ public void testDoubleQuotedUnescapedStringForbidden() { } public void testTripleDoubleQuotedUnescapedString() { - // """hello " world!""" => hello " world! - String str = "\"\"\"hello \" world!\"\"\" == foo"; - String expectedStr = "hello \" world!"; + // """hello world!"""" == """foobar""" => hello world! = foobar + String str = "\"\"\"hello world!\"\"\" == \"\"\"foobar\"\"\""; + String expectedStrLeft = "hello world!"; + String expectedStrRight = "foobar"; Expression parsed = expr(str); assertEquals(Equals.class, parsed.getClass()); Equals eq = (Equals) parsed; - assertEquals(UnresolvedAttribute.class, eq.right().getClass()); assertEquals(Literal.class, eq.left().getClass()); - assertEquals(expectedStr, ((Literal) eq.left()).value()); - - // """hello \" world!""" => hello \" world! - str = "\"\"\"hello \\\" world!\"\"\" == foo"; - expectedStr = "hello \\\" world!"; - parsed = expr(str); - assertEquals(Equals.class, parsed.getClass()); - eq = (Equals) parsed; - assertEquals(UnresolvedAttribute.class, eq.right().getClass()); - assertEquals(Literal.class, eq.left().getClass()); - assertEquals(expectedStr, ((Literal) eq.left()).value()); - - // """""hello """ world!"""" => ""hello """ world!" - str = "\"\"\"\"\"hello \"\"\" world!\"\"\"\" == foo"; - expectedStr = "\"\"hello \"\"\" world!\""; + assertEquals(expectedStrLeft, ((Literal) eq.left()).value()); + assertEquals(Literal.class, eq.right().getClass()); + assertEquals(expectedStrRight, ((Literal) eq.right()).value()); + + // """""hello\"""world!""""" == """"foo"\""bar"""" => ""hello"""world!"" = "foo"""bar" + str = "\"\"\"\"\"hello\\\"\"\"world!\"\"\"\"\" == \"\"\"\"foo\"\\\"\"bar\"\"\"\""; + expectedStrLeft = "\"\"hello\"\"\"world!"; + expectedStrRight = "\"foo\"\"\"bar\""; parsed = expr(str); assertEquals(Equals.class, parsed.getClass()); eq = (Equals) parsed; - assertEquals(UnresolvedAttribute.class, eq.right().getClass()); assertEquals(Literal.class, eq.left().getClass()); - assertEquals(expectedStr, ((Literal) eq.left()).value()); + assertEquals(expectedStrLeft, ((Literal) eq.left()).value()); + assertEquals(Literal.class, eq.right().getClass()); + assertEquals(expectedStrRight, ((Literal) eq.right()).value()); } public void testNumbers() { From a8f4cbb9c9645573f945e3c9ddac7f89d489a48f Mon Sep 17 00:00:00 2001 From: Marios Trivyzas Date: Thu, 1 Oct 2020 19:44:27 +0300 Subject: [PATCH 7/8] Use Python approach --- x-pack/plugin/eql/src/main/antlr/EqlBase.g4 | 2 +- .../xpack/eql/parser/AbstractBuilder.java | 6 +- .../xpack/eql/parser/EqlBaseLexer.java | 261 +++++++++--------- .../xpack/eql/parser/ExpressionTests.java | 51 +++- 4 files changed, 172 insertions(+), 148 deletions(-) diff --git a/x-pack/plugin/eql/src/main/antlr/EqlBase.g4 b/x-pack/plugin/eql/src/main/antlr/EqlBase.g4 index eb1a903b87d6a..818fe6304e742 100644 --- a/x-pack/plugin/eql/src/main/antlr/EqlBase.g4 +++ b/x-pack/plugin/eql/src/main/antlr/EqlBase.g4 @@ -200,7 +200,7 @@ STRING | '"' ('\\' [btnfr"'\\] | ~[\r\n"\\])* '"' | '?"' ('\\"' |~["\r\n])* '"' | '?\'' ('\\\'' |~['\r\n])* '\'' - | '"""' (('\\"""' | '"\\""' | '""\\"' | '\\"\\"\\"') | ~[\r\n])*? '"""' + | '"""' ('\\"' |~[\r\n])*? '"""' ; INTEGER_VALUE diff --git a/x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/parser/AbstractBuilder.java b/x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/parser/AbstractBuilder.java index 52f5c165b4017..f5a5cc65c42aa 100644 --- a/x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/parser/AbstractBuilder.java +++ b/x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/parser/AbstractBuilder.java @@ -130,11 +130,7 @@ public static String unquoteString(Source source) { // unescaped strings can be interpreted directly if (text.startsWith("\"\"\"")) { - String str = text.substring(3, text.length() - 3); - return str.replace("\\\"\\\"\\\"", "\"\"\"") - .replace("\\\"\"\"", "\"\"\"") - .replace("\"\\\"\"", "\"\"\"") - .replace("\"\"\\\"", "\"\"\""); + return text.substring(3, text.length() - 3).replace("\\\"", "\""); } checkForSingleQuotedString(source, text, 0); diff --git a/x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/parser/EqlBaseLexer.java b/x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/parser/EqlBaseLexer.java index 647bd2fe445cb..51f1e19e1ef89 100644 --- a/x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/parser/EqlBaseLexer.java +++ b/x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/parser/EqlBaseLexer.java @@ -106,7 +106,7 @@ public EqlBaseLexer(CharStream input) { public ATN getATN() { return _ATN; } public static final String _serializedATN = - "\3\u0430\ud6d1\u8206\uad2d\u4417\uaef1\u8d80\uaadd\2.\u01aa\b\1\4\2\t"+ + "\3\u0430\ud6d1\u8206\uad2d\u4417\uaef1\u8d80\uaadd\2.\u0198\b\1\4\2\t"+ "\2\4\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7\t\7\4\b\t\b\4\t\t\t\4\n\t\n\4\13"+ "\t\13\4\f\t\f\4\r\t\r\4\16\t\16\4\17\t\17\4\20\t\20\4\21\t\21\4\22\t\22"+ "\4\23\t\23\4\24\t\24\4\25\t\25\4\26\t\26\4\27\t\27\4\30\t\30\4\31\t\31"+ @@ -124,139 +124,132 @@ public EqlBaseLexer(CharStream input) { "\13&\3&\3&\3\'\3\'\3\'\3\'\7\'\u00ef\n\'\f\'\16\'\u00f2\13\'\3\'\3\'\3"+ "\'\3\'\3\'\7\'\u00f9\n\'\f\'\16\'\u00fc\13\'\3\'\3\'\3\'\3\'\3\'\3\'\3"+ "\'\7\'\u0105\n\'\f\'\16\'\u0108\13\'\3\'\3\'\3\'\3\'\3\'\3\'\3\'\7\'\u0111"+ - "\n\'\f\'\16\'\u0114\13\'\3\'\3\'\3\'\3\'\3\'\3\'\3\'\3\'\3\'\3\'\3\'\3"+ - "\'\3\'\3\'\3\'\3\'\3\'\3\'\3\'\3\'\3\'\3\'\3\'\5\'\u012d\n\'\3\'\7\'\u0130"+ - "\n\'\f\'\16\'\u0133\13\'\3\'\3\'\3\'\5\'\u0138\n\'\3(\6(\u013b\n(\r(\16"+ - "(\u013c\3)\6)\u0140\n)\r)\16)\u0141\3)\3)\7)\u0146\n)\f)\16)\u0149\13"+ - ")\3)\3)\6)\u014d\n)\r)\16)\u014e\3)\6)\u0152\n)\r)\16)\u0153\3)\3)\7)"+ - "\u0158\n)\f)\16)\u015b\13)\5)\u015d\n)\3)\3)\3)\3)\6)\u0163\n)\r)\16)"+ - "\u0164\3)\3)\5)\u0169\n)\3*\3*\5*\u016d\n*\3*\3*\3*\7*\u0172\n*\f*\16"+ - "*\u0175\13*\3+\3+\5+\u0179\n+\3+\6+\u017c\n+\r+\16+\u017d\3,\3,\3-\3-"+ - "\3.\3.\3.\3.\7.\u0188\n.\f.\16.\u018b\13.\3.\5.\u018e\n.\3.\5.\u0191\n"+ - ".\3.\3.\3/\3/\3/\3/\3/\7/\u019a\n/\f/\16/\u019d\13/\3/\3/\3/\3/\3/\3\60"+ - "\6\60\u01a5\n\60\r\60\16\60\u01a6\3\60\3\60\4\u0131\u019b\2\61\3\3\5\4"+ - "\7\5\t\6\13\7\r\b\17\t\21\n\23\13\25\f\27\r\31\16\33\17\35\20\37\21!\22"+ - "#\23%\24\'\25)\26+\27-\30/\31\61\32\63\33\65\34\67\359\36;\37= ?!A\"C"+ - "#E$G%I&K\'M(O)Q*S+U\2W\2Y\2[,]-_.\3\2\17\3\2bb\n\2$$))^^ddhhppttvv\6\2"+ - "\f\f\17\17))^^\6\2\f\f\17\17$$^^\5\2\f\f\17\17$$\5\2\f\f\17\17))\4\2\f"+ - "\f\17\17\4\2BBaa\4\2GGgg\4\2--//\3\2\62;\4\2C\\c|\5\2\13\f\17\17\"\"\u01d0"+ - "\2\3\3\2\2\2\2\5\3\2\2\2\2\7\3\2\2\2\2\t\3\2\2\2\2\13\3\2\2\2\2\r\3\2"+ - "\2\2\2\17\3\2\2\2\2\21\3\2\2\2\2\23\3\2\2\2\2\25\3\2\2\2\2\27\3\2\2\2"+ - "\2\31\3\2\2\2\2\33\3\2\2\2\2\35\3\2\2\2\2\37\3\2\2\2\2!\3\2\2\2\2#\3\2"+ - "\2\2\2%\3\2\2\2\2\'\3\2\2\2\2)\3\2\2\2\2+\3\2\2\2\2-\3\2\2\2\2/\3\2\2"+ - "\2\2\61\3\2\2\2\2\63\3\2\2\2\2\65\3\2\2\2\2\67\3\2\2\2\29\3\2\2\2\2;\3"+ - "\2\2\2\2=\3\2\2\2\2?\3\2\2\2\2A\3\2\2\2\2C\3\2\2\2\2E\3\2\2\2\2G\3\2\2"+ - "\2\2I\3\2\2\2\2K\3\2\2\2\2M\3\2\2\2\2O\3\2\2\2\2Q\3\2\2\2\2S\3\2\2\2\2"+ - "[\3\2\2\2\2]\3\2\2\2\2_\3\2\2\2\3a\3\2\2\2\5e\3\2\2\2\7i\3\2\2\2\tl\3"+ - "\2\2\2\13r\3\2\2\2\rw\3\2\2\2\17z\3\2\2\2\21\177\3\2\2\2\23\u0087\3\2"+ - "\2\2\25\u008b\3\2\2\2\27\u0090\3\2\2\2\31\u0093\3\2\2\2\33\u0096\3\2\2"+ - "\2\35\u009f\3\2\2\2\37\u00a4\3\2\2\2!\u00aa\3\2\2\2#\u00b0\3\2\2\2%\u00b5"+ - "\3\2\2\2\'\u00b7\3\2\2\2)\u00ba\3\2\2\2+\u00bd\3\2\2\2-\u00bf\3\2\2\2"+ - "/\u00c2\3\2\2\2\61\u00c4\3\2\2\2\63\u00c7\3\2\2\2\65\u00c9\3\2\2\2\67"+ - "\u00cb\3\2\2\29\u00cd\3\2\2\2;\u00cf\3\2\2\2=\u00d1\3\2\2\2?\u00d3\3\2"+ - "\2\2A\u00d5\3\2\2\2C\u00d7\3\2\2\2E\u00d9\3\2\2\2G\u00db\3\2\2\2I\u00dd"+ - "\3\2\2\2K\u00df\3\2\2\2M\u0137\3\2\2\2O\u013a\3\2\2\2Q\u0168\3\2\2\2S"+ - "\u016c\3\2\2\2U\u0176\3\2\2\2W\u017f\3\2\2\2Y\u0181\3\2\2\2[\u0183\3\2"+ - "\2\2]\u0194\3\2\2\2_\u01a4\3\2\2\2ab\7c\2\2bc\7p\2\2cd\7f\2\2d\4\3\2\2"+ - "\2ef\7c\2\2fg\7p\2\2gh\7{\2\2h\6\3\2\2\2ij\7d\2\2jk\7{\2\2k\b\3\2\2\2"+ - "lm\7h\2\2mn\7c\2\2no\7n\2\2op\7u\2\2pq\7g\2\2q\n\3\2\2\2rs\7h\2\2st\7"+ - "q\2\2tu\7t\2\2uv\7m\2\2v\f\3\2\2\2wx\7k\2\2xy\7p\2\2y\16\3\2\2\2z{\7l"+ - "\2\2{|\7q\2\2|}\7k\2\2}~\7p\2\2~\20\3\2\2\2\177\u0080\7o\2\2\u0080\u0081"+ - "\7c\2\2\u0081\u0082\7z\2\2\u0082\u0083\7u\2\2\u0083\u0084\7r\2\2\u0084"+ - "\u0085\7c\2\2\u0085\u0086\7p\2\2\u0086\22\3\2\2\2\u0087\u0088\7p\2\2\u0088"+ - "\u0089\7q\2\2\u0089\u008a\7v\2\2\u008a\24\3\2\2\2\u008b\u008c\7p\2\2\u008c"+ - "\u008d\7w\2\2\u008d\u008e\7n\2\2\u008e\u008f\7n\2\2\u008f\26\3\2\2\2\u0090"+ - "\u0091\7q\2\2\u0091\u0092\7h\2\2\u0092\30\3\2\2\2\u0093\u0094\7q\2\2\u0094"+ - "\u0095\7t\2\2\u0095\32\3\2\2\2\u0096\u0097\7u\2\2\u0097\u0098\7g\2\2\u0098"+ - "\u0099\7s\2\2\u0099\u009a\7w\2\2\u009a\u009b\7g\2\2\u009b\u009c\7p\2\2"+ - "\u009c\u009d\7e\2\2\u009d\u009e\7g\2\2\u009e\34\3\2\2\2\u009f\u00a0\7"+ - "v\2\2\u00a0\u00a1\7t\2\2\u00a1\u00a2\7w\2\2\u00a2\u00a3\7g\2\2\u00a3\36"+ - "\3\2\2\2\u00a4\u00a5\7w\2\2\u00a5\u00a6\7p\2\2\u00a6\u00a7\7v\2\2\u00a7"+ - "\u00a8\7k\2\2\u00a8\u00a9\7n\2\2\u00a9 \3\2\2\2\u00aa\u00ab\7y\2\2\u00ab"+ - "\u00ac\7j\2\2\u00ac\u00ad\7g\2\2\u00ad\u00ae\7t\2\2\u00ae\u00af\7g\2\2"+ - "\u00af\"\3\2\2\2\u00b0\u00b1\7y\2\2\u00b1\u00b2\7k\2\2\u00b2\u00b3\7v"+ - "\2\2\u00b3\u00b4\7j\2\2\u00b4$\3\2\2\2\u00b5\u00b6\7?\2\2\u00b6&\3\2\2"+ - "\2\u00b7\u00b8\7?\2\2\u00b8\u00b9\7?\2\2\u00b9(\3\2\2\2\u00ba\u00bb\7"+ - "#\2\2\u00bb\u00bc\7?\2\2\u00bc*\3\2\2\2\u00bd\u00be\7>\2\2\u00be,\3\2"+ - "\2\2\u00bf\u00c0\7>\2\2\u00c0\u00c1\7?\2\2\u00c1.\3\2\2\2\u00c2\u00c3"+ - "\7@\2\2\u00c3\60\3\2\2\2\u00c4\u00c5\7@\2\2\u00c5\u00c6\7?\2\2\u00c6\62"+ - "\3\2\2\2\u00c7\u00c8\7-\2\2\u00c8\64\3\2\2\2\u00c9\u00ca\7/\2\2\u00ca"+ - "\66\3\2\2\2\u00cb\u00cc\7,\2\2\u00cc8\3\2\2\2\u00cd\u00ce\7\61\2\2\u00ce"+ - ":\3\2\2\2\u00cf\u00d0\7\'\2\2\u00d0<\3\2\2\2\u00d1\u00d2\7\60\2\2\u00d2"+ - ">\3\2\2\2\u00d3\u00d4\7.\2\2\u00d4@\3\2\2\2\u00d5\u00d6\7]\2\2\u00d6B"+ - "\3\2\2\2\u00d7\u00d8\7_\2\2\u00d8D\3\2\2\2\u00d9\u00da\7*\2\2\u00daF\3"+ - "\2\2\2\u00db\u00dc\7+\2\2\u00dcH\3\2\2\2\u00dd\u00de\7~\2\2\u00deJ\3\2"+ - "\2\2\u00df\u00e5\7b\2\2\u00e0\u00e4\n\2\2\2\u00e1\u00e2\7b\2\2\u00e2\u00e4"+ - "\7b\2\2\u00e3\u00e0\3\2\2\2\u00e3\u00e1\3\2\2\2\u00e4\u00e7\3\2\2\2\u00e5"+ - "\u00e3\3\2\2\2\u00e5\u00e6\3\2\2\2\u00e6\u00e8\3\2\2\2\u00e7\u00e5\3\2"+ - "\2\2\u00e8\u00e9\7b\2\2\u00e9L\3\2\2\2\u00ea\u00f0\7)\2\2\u00eb\u00ec"+ - "\7^\2\2\u00ec\u00ef\t\3\2\2\u00ed\u00ef\n\4\2\2\u00ee\u00eb\3\2\2\2\u00ee"+ - "\u00ed\3\2\2\2\u00ef\u00f2\3\2\2\2\u00f0\u00ee\3\2\2\2\u00f0\u00f1\3\2"+ - "\2\2\u00f1\u00f3\3\2\2\2\u00f2\u00f0\3\2\2\2\u00f3\u0138\7)\2\2\u00f4"+ - "\u00fa\7$\2\2\u00f5\u00f6\7^\2\2\u00f6\u00f9\t\3\2\2\u00f7\u00f9\n\5\2"+ - "\2\u00f8\u00f5\3\2\2\2\u00f8\u00f7\3\2\2\2\u00f9\u00fc\3\2\2\2\u00fa\u00f8"+ - "\3\2\2\2\u00fa\u00fb\3\2\2\2\u00fb\u00fd\3\2\2\2\u00fc\u00fa\3\2\2\2\u00fd"+ - "\u0138\7$\2\2\u00fe\u00ff\7A\2\2\u00ff\u0100\7$\2\2\u0100\u0106\3\2\2"+ - "\2\u0101\u0102\7^\2\2\u0102\u0105\7$\2\2\u0103\u0105\n\6\2\2\u0104\u0101"+ - "\3\2\2\2\u0104\u0103\3\2\2\2\u0105\u0108\3\2\2\2\u0106\u0104\3\2\2\2\u0106"+ - "\u0107\3\2\2\2\u0107\u0109\3\2\2\2\u0108\u0106\3\2\2\2\u0109\u0138\7$"+ - "\2\2\u010a\u010b\7A\2\2\u010b\u010c\7)\2\2\u010c\u0112\3\2\2\2\u010d\u010e"+ - "\7^\2\2\u010e\u0111\7)\2\2\u010f\u0111\n\7\2\2\u0110\u010d\3\2\2\2\u0110"+ - "\u010f\3\2\2\2\u0111\u0114\3\2\2\2\u0112\u0110\3\2\2\2\u0112\u0113\3\2"+ - "\2\2\u0113\u0115\3\2\2\2\u0114\u0112\3\2\2\2\u0115\u0138\7)\2\2\u0116"+ - "\u0117\7$\2\2\u0117\u0118\7$\2\2\u0118\u0119\7$\2\2\u0119\u0131\3\2\2"+ - "\2\u011a\u011b\7^\2\2\u011b\u011c\7$\2\2\u011c\u011d\7$\2\2\u011d\u012d"+ - "\7$\2\2\u011e\u011f\7$\2\2\u011f\u0120\7^\2\2\u0120\u0121\7$\2\2\u0121"+ - "\u012d\7$\2\2\u0122\u0123\7$\2\2\u0123\u0124\7$\2\2\u0124\u0125\7^\2\2"+ - "\u0125\u012d\7$\2\2\u0126\u0127\7^\2\2\u0127\u0128\7$\2\2\u0128\u0129"+ - "\7^\2\2\u0129\u012a\7$\2\2\u012a\u012b\7^\2\2\u012b\u012d\7$\2\2\u012c"+ - "\u011a\3\2\2\2\u012c\u011e\3\2\2\2\u012c\u0122\3\2\2\2\u012c\u0126\3\2"+ - "\2\2\u012d\u0130\3\2\2\2\u012e\u0130\n\b\2\2\u012f\u012c\3\2\2\2\u012f"+ - "\u012e\3\2\2\2\u0130\u0133\3\2\2\2\u0131\u0132\3\2\2\2\u0131\u012f\3\2"+ - "\2\2\u0132\u0134\3\2\2\2\u0133\u0131\3\2\2\2\u0134\u0135\7$\2\2\u0135"+ - "\u0136\7$\2\2\u0136\u0138\7$\2\2\u0137\u00ea\3\2\2\2\u0137\u00f4\3\2\2"+ - "\2\u0137\u00fe\3\2\2\2\u0137\u010a\3\2\2\2\u0137\u0116\3\2\2\2\u0138N"+ - "\3\2\2\2\u0139\u013b\5W,\2\u013a\u0139\3\2\2\2\u013b\u013c\3\2\2\2\u013c"+ - "\u013a\3\2\2\2\u013c\u013d\3\2\2\2\u013dP\3\2\2\2\u013e\u0140\5W,\2\u013f"+ - "\u013e\3\2\2\2\u0140\u0141\3\2\2\2\u0141\u013f\3\2\2\2\u0141\u0142\3\2"+ - "\2\2\u0142\u0143\3\2\2\2\u0143\u0147\5=\37\2\u0144\u0146\5W,\2\u0145\u0144"+ - "\3\2\2\2\u0146\u0149\3\2\2\2\u0147\u0145\3\2\2\2\u0147\u0148\3\2\2\2\u0148"+ - "\u0169\3\2\2\2\u0149\u0147\3\2\2\2\u014a\u014c\5=\37\2\u014b\u014d\5W"+ - ",\2\u014c\u014b\3\2\2\2\u014d\u014e\3\2\2\2\u014e\u014c\3\2\2\2\u014e"+ - "\u014f\3\2\2\2\u014f\u0169\3\2\2\2\u0150\u0152\5W,\2\u0151\u0150\3\2\2"+ - "\2\u0152\u0153\3\2\2\2\u0153\u0151\3\2\2\2\u0153\u0154\3\2\2\2\u0154\u015c"+ - "\3\2\2\2\u0155\u0159\5=\37\2\u0156\u0158\5W,\2\u0157\u0156\3\2\2\2\u0158"+ - "\u015b\3\2\2\2\u0159\u0157\3\2\2\2\u0159\u015a\3\2\2\2\u015a\u015d\3\2"+ - "\2\2\u015b\u0159\3\2\2\2\u015c\u0155\3\2\2\2\u015c\u015d\3\2\2\2\u015d"+ - "\u015e\3\2\2\2\u015e\u015f\5U+\2\u015f\u0169\3\2\2\2\u0160\u0162\5=\37"+ - "\2\u0161\u0163\5W,\2\u0162\u0161\3\2\2\2\u0163\u0164\3\2\2\2\u0164\u0162"+ - "\3\2\2\2\u0164\u0165\3\2\2\2\u0165\u0166\3\2\2\2\u0166\u0167\5U+\2\u0167"+ - "\u0169\3\2\2\2\u0168\u013f\3\2\2\2\u0168\u014a\3\2\2\2\u0168\u0151\3\2"+ - "\2\2\u0168\u0160\3\2\2\2\u0169R\3\2\2\2\u016a\u016d\5Y-\2\u016b\u016d"+ - "\t\t\2\2\u016c\u016a\3\2\2\2\u016c\u016b\3\2\2\2\u016d\u0173\3\2\2\2\u016e"+ - "\u0172\5Y-\2\u016f\u0172\5W,\2\u0170\u0172\7a\2\2\u0171\u016e\3\2\2\2"+ - "\u0171\u016f\3\2\2\2\u0171\u0170\3\2\2\2\u0172\u0175\3\2\2\2\u0173\u0171"+ - "\3\2\2\2\u0173\u0174\3\2\2\2\u0174T\3\2\2\2\u0175\u0173\3\2\2\2\u0176"+ - "\u0178\t\n\2\2\u0177\u0179\t\13\2\2\u0178\u0177\3\2\2\2\u0178\u0179\3"+ - "\2\2\2\u0179\u017b\3\2\2\2\u017a\u017c\5W,\2\u017b\u017a\3\2\2\2\u017c"+ - "\u017d\3\2\2\2\u017d\u017b\3\2\2\2\u017d\u017e\3\2\2\2\u017eV\3\2\2\2"+ - "\u017f\u0180\t\f\2\2\u0180X\3\2\2\2\u0181\u0182\t\r\2\2\u0182Z\3\2\2\2"+ - "\u0183\u0184\7\61\2\2\u0184\u0185\7\61\2\2\u0185\u0189\3\2\2\2\u0186\u0188"+ - "\n\b\2\2\u0187\u0186\3\2\2\2\u0188\u018b\3\2\2\2\u0189\u0187\3\2\2\2\u0189"+ - "\u018a\3\2\2\2\u018a\u018d\3\2\2\2\u018b\u0189\3\2\2\2\u018c\u018e\7\17"+ - "\2\2\u018d\u018c\3\2\2\2\u018d\u018e\3\2\2\2\u018e\u0190\3\2\2\2\u018f"+ - "\u0191\7\f\2\2\u0190\u018f\3\2\2\2\u0190\u0191\3\2\2\2\u0191\u0192\3\2"+ - "\2\2\u0192\u0193\b.\2\2\u0193\\\3\2\2\2\u0194\u0195\7\61\2\2\u0195\u0196"+ - "\7,\2\2\u0196\u019b\3\2\2\2\u0197\u019a\5]/\2\u0198\u019a\13\2\2\2\u0199"+ - "\u0197\3\2\2\2\u0199\u0198\3\2\2\2\u019a\u019d\3\2\2\2\u019b\u019c\3\2"+ - "\2\2\u019b\u0199\3\2\2\2\u019c\u019e\3\2\2\2\u019d\u019b\3\2\2\2\u019e"+ - "\u019f\7,\2\2\u019f\u01a0\7\61\2\2\u01a0\u01a1\3\2\2\2\u01a1\u01a2\b/"+ - "\2\2\u01a2^\3\2\2\2\u01a3\u01a5\t\16\2\2\u01a4\u01a3\3\2\2\2\u01a5\u01a6"+ - "\3\2\2\2\u01a6\u01a4\3\2\2\2\u01a6\u01a7\3\2\2\2\u01a7\u01a8\3\2\2\2\u01a8"+ - "\u01a9\b\60\2\2\u01a9`\3\2\2\2%\2\u00e3\u00e5\u00ee\u00f0\u00f8\u00fa"+ - "\u0104\u0106\u0110\u0112\u012c\u012f\u0131\u0137\u013c\u0141\u0147\u014e"+ - "\u0153\u0159\u015c\u0164\u0168\u016c\u0171\u0173\u0178\u017d\u0189\u018d"+ - "\u0190\u0199\u019b\u01a6\3\2\3\2"; + "\n\'\f\'\16\'\u0114\13\'\3\'\3\'\3\'\3\'\3\'\3\'\3\'\3\'\7\'\u011e\n\'"+ + "\f\'\16\'\u0121\13\'\3\'\3\'\3\'\5\'\u0126\n\'\3(\6(\u0129\n(\r(\16(\u012a"+ + "\3)\6)\u012e\n)\r)\16)\u012f\3)\3)\7)\u0134\n)\f)\16)\u0137\13)\3)\3)"+ + "\6)\u013b\n)\r)\16)\u013c\3)\6)\u0140\n)\r)\16)\u0141\3)\3)\7)\u0146\n"+ + ")\f)\16)\u0149\13)\5)\u014b\n)\3)\3)\3)\3)\6)\u0151\n)\r)\16)\u0152\3"+ + ")\3)\5)\u0157\n)\3*\3*\5*\u015b\n*\3*\3*\3*\7*\u0160\n*\f*\16*\u0163\13"+ + "*\3+\3+\5+\u0167\n+\3+\6+\u016a\n+\r+\16+\u016b\3,\3,\3-\3-\3.\3.\3.\3"+ + ".\7.\u0176\n.\f.\16.\u0179\13.\3.\5.\u017c\n.\3.\5.\u017f\n.\3.\3.\3/"+ + "\3/\3/\3/\3/\7/\u0188\n/\f/\16/\u018b\13/\3/\3/\3/\3/\3/\3\60\6\60\u0193"+ + "\n\60\r\60\16\60\u0194\3\60\3\60\4\u011f\u0189\2\61\3\3\5\4\7\5\t\6\13"+ + "\7\r\b\17\t\21\n\23\13\25\f\27\r\31\16\33\17\35\20\37\21!\22#\23%\24\'"+ + "\25)\26+\27-\30/\31\61\32\63\33\65\34\67\359\36;\37= ?!A\"C#E$G%I&K\'"+ + "M(O)Q*S+U\2W\2Y\2[,]-_.\3\2\17\3\2bb\n\2$$))^^ddhhppttvv\6\2\f\f\17\17"+ + "))^^\6\2\f\f\17\17$$^^\5\2\f\f\17\17$$\5\2\f\f\17\17))\4\2\f\f\17\17\4"+ + "\2BBaa\4\2GGgg\4\2--//\3\2\62;\4\2C\\c|\5\2\13\f\17\17\"\"\u01bb\2\3\3"+ + "\2\2\2\2\5\3\2\2\2\2\7\3\2\2\2\2\t\3\2\2\2\2\13\3\2\2\2\2\r\3\2\2\2\2"+ + "\17\3\2\2\2\2\21\3\2\2\2\2\23\3\2\2\2\2\25\3\2\2\2\2\27\3\2\2\2\2\31\3"+ + "\2\2\2\2\33\3\2\2\2\2\35\3\2\2\2\2\37\3\2\2\2\2!\3\2\2\2\2#\3\2\2\2\2"+ + "%\3\2\2\2\2\'\3\2\2\2\2)\3\2\2\2\2+\3\2\2\2\2-\3\2\2\2\2/\3\2\2\2\2\61"+ + "\3\2\2\2\2\63\3\2\2\2\2\65\3\2\2\2\2\67\3\2\2\2\29\3\2\2\2\2;\3\2\2\2"+ + "\2=\3\2\2\2\2?\3\2\2\2\2A\3\2\2\2\2C\3\2\2\2\2E\3\2\2\2\2G\3\2\2\2\2I"+ + "\3\2\2\2\2K\3\2\2\2\2M\3\2\2\2\2O\3\2\2\2\2Q\3\2\2\2\2S\3\2\2\2\2[\3\2"+ + "\2\2\2]\3\2\2\2\2_\3\2\2\2\3a\3\2\2\2\5e\3\2\2\2\7i\3\2\2\2\tl\3\2\2\2"+ + "\13r\3\2\2\2\rw\3\2\2\2\17z\3\2\2\2\21\177\3\2\2\2\23\u0087\3\2\2\2\25"+ + "\u008b\3\2\2\2\27\u0090\3\2\2\2\31\u0093\3\2\2\2\33\u0096\3\2\2\2\35\u009f"+ + "\3\2\2\2\37\u00a4\3\2\2\2!\u00aa\3\2\2\2#\u00b0\3\2\2\2%\u00b5\3\2\2\2"+ + "\'\u00b7\3\2\2\2)\u00ba\3\2\2\2+\u00bd\3\2\2\2-\u00bf\3\2\2\2/\u00c2\3"+ + "\2\2\2\61\u00c4\3\2\2\2\63\u00c7\3\2\2\2\65\u00c9\3\2\2\2\67\u00cb\3\2"+ + "\2\29\u00cd\3\2\2\2;\u00cf\3\2\2\2=\u00d1\3\2\2\2?\u00d3\3\2\2\2A\u00d5"+ + "\3\2\2\2C\u00d7\3\2\2\2E\u00d9\3\2\2\2G\u00db\3\2\2\2I\u00dd\3\2\2\2K"+ + "\u00df\3\2\2\2M\u0125\3\2\2\2O\u0128\3\2\2\2Q\u0156\3\2\2\2S\u015a\3\2"+ + "\2\2U\u0164\3\2\2\2W\u016d\3\2\2\2Y\u016f\3\2\2\2[\u0171\3\2\2\2]\u0182"+ + "\3\2\2\2_\u0192\3\2\2\2ab\7c\2\2bc\7p\2\2cd\7f\2\2d\4\3\2\2\2ef\7c\2\2"+ + "fg\7p\2\2gh\7{\2\2h\6\3\2\2\2ij\7d\2\2jk\7{\2\2k\b\3\2\2\2lm\7h\2\2mn"+ + "\7c\2\2no\7n\2\2op\7u\2\2pq\7g\2\2q\n\3\2\2\2rs\7h\2\2st\7q\2\2tu\7t\2"+ + "\2uv\7m\2\2v\f\3\2\2\2wx\7k\2\2xy\7p\2\2y\16\3\2\2\2z{\7l\2\2{|\7q\2\2"+ + "|}\7k\2\2}~\7p\2\2~\20\3\2\2\2\177\u0080\7o\2\2\u0080\u0081\7c\2\2\u0081"+ + "\u0082\7z\2\2\u0082\u0083\7u\2\2\u0083\u0084\7r\2\2\u0084\u0085\7c\2\2"+ + "\u0085\u0086\7p\2\2\u0086\22\3\2\2\2\u0087\u0088\7p\2\2\u0088\u0089\7"+ + "q\2\2\u0089\u008a\7v\2\2\u008a\24\3\2\2\2\u008b\u008c\7p\2\2\u008c\u008d"+ + "\7w\2\2\u008d\u008e\7n\2\2\u008e\u008f\7n\2\2\u008f\26\3\2\2\2\u0090\u0091"+ + "\7q\2\2\u0091\u0092\7h\2\2\u0092\30\3\2\2\2\u0093\u0094\7q\2\2\u0094\u0095"+ + "\7t\2\2\u0095\32\3\2\2\2\u0096\u0097\7u\2\2\u0097\u0098\7g\2\2\u0098\u0099"+ + "\7s\2\2\u0099\u009a\7w\2\2\u009a\u009b\7g\2\2\u009b\u009c\7p\2\2\u009c"+ + "\u009d\7e\2\2\u009d\u009e\7g\2\2\u009e\34\3\2\2\2\u009f\u00a0\7v\2\2\u00a0"+ + "\u00a1\7t\2\2\u00a1\u00a2\7w\2\2\u00a2\u00a3\7g\2\2\u00a3\36\3\2\2\2\u00a4"+ + "\u00a5\7w\2\2\u00a5\u00a6\7p\2\2\u00a6\u00a7\7v\2\2\u00a7\u00a8\7k\2\2"+ + "\u00a8\u00a9\7n\2\2\u00a9 \3\2\2\2\u00aa\u00ab\7y\2\2\u00ab\u00ac\7j\2"+ + "\2\u00ac\u00ad\7g\2\2\u00ad\u00ae\7t\2\2\u00ae\u00af\7g\2\2\u00af\"\3"+ + "\2\2\2\u00b0\u00b1\7y\2\2\u00b1\u00b2\7k\2\2\u00b2\u00b3\7v\2\2\u00b3"+ + "\u00b4\7j\2\2\u00b4$\3\2\2\2\u00b5\u00b6\7?\2\2\u00b6&\3\2\2\2\u00b7\u00b8"+ + "\7?\2\2\u00b8\u00b9\7?\2\2\u00b9(\3\2\2\2\u00ba\u00bb\7#\2\2\u00bb\u00bc"+ + "\7?\2\2\u00bc*\3\2\2\2\u00bd\u00be\7>\2\2\u00be,\3\2\2\2\u00bf\u00c0\7"+ + ">\2\2\u00c0\u00c1\7?\2\2\u00c1.\3\2\2\2\u00c2\u00c3\7@\2\2\u00c3\60\3"+ + "\2\2\2\u00c4\u00c5\7@\2\2\u00c5\u00c6\7?\2\2\u00c6\62\3\2\2\2\u00c7\u00c8"+ + "\7-\2\2\u00c8\64\3\2\2\2\u00c9\u00ca\7/\2\2\u00ca\66\3\2\2\2\u00cb\u00cc"+ + "\7,\2\2\u00cc8\3\2\2\2\u00cd\u00ce\7\61\2\2\u00ce:\3\2\2\2\u00cf\u00d0"+ + "\7\'\2\2\u00d0<\3\2\2\2\u00d1\u00d2\7\60\2\2\u00d2>\3\2\2\2\u00d3\u00d4"+ + "\7.\2\2\u00d4@\3\2\2\2\u00d5\u00d6\7]\2\2\u00d6B\3\2\2\2\u00d7\u00d8\7"+ + "_\2\2\u00d8D\3\2\2\2\u00d9\u00da\7*\2\2\u00daF\3\2\2\2\u00db\u00dc\7+"+ + "\2\2\u00dcH\3\2\2\2\u00dd\u00de\7~\2\2\u00deJ\3\2\2\2\u00df\u00e5\7b\2"+ + "\2\u00e0\u00e4\n\2\2\2\u00e1\u00e2\7b\2\2\u00e2\u00e4\7b\2\2\u00e3\u00e0"+ + "\3\2\2\2\u00e3\u00e1\3\2\2\2\u00e4\u00e7\3\2\2\2\u00e5\u00e3\3\2\2\2\u00e5"+ + "\u00e6\3\2\2\2\u00e6\u00e8\3\2\2\2\u00e7\u00e5\3\2\2\2\u00e8\u00e9\7b"+ + "\2\2\u00e9L\3\2\2\2\u00ea\u00f0\7)\2\2\u00eb\u00ec\7^\2\2\u00ec\u00ef"+ + "\t\3\2\2\u00ed\u00ef\n\4\2\2\u00ee\u00eb\3\2\2\2\u00ee\u00ed\3\2\2\2\u00ef"+ + "\u00f2\3\2\2\2\u00f0\u00ee\3\2\2\2\u00f0\u00f1\3\2\2\2\u00f1\u00f3\3\2"+ + "\2\2\u00f2\u00f0\3\2\2\2\u00f3\u0126\7)\2\2\u00f4\u00fa\7$\2\2\u00f5\u00f6"+ + "\7^\2\2\u00f6\u00f9\t\3\2\2\u00f7\u00f9\n\5\2\2\u00f8\u00f5\3\2\2\2\u00f8"+ + "\u00f7\3\2\2\2\u00f9\u00fc\3\2\2\2\u00fa\u00f8\3\2\2\2\u00fa\u00fb\3\2"+ + "\2\2\u00fb\u00fd\3\2\2\2\u00fc\u00fa\3\2\2\2\u00fd\u0126\7$\2\2\u00fe"+ + "\u00ff\7A\2\2\u00ff\u0100\7$\2\2\u0100\u0106\3\2\2\2\u0101\u0102\7^\2"+ + "\2\u0102\u0105\7$\2\2\u0103\u0105\n\6\2\2\u0104\u0101\3\2\2\2\u0104\u0103"+ + "\3\2\2\2\u0105\u0108\3\2\2\2\u0106\u0104\3\2\2\2\u0106\u0107\3\2\2\2\u0107"+ + "\u0109\3\2\2\2\u0108\u0106\3\2\2\2\u0109\u0126\7$\2\2\u010a\u010b\7A\2"+ + "\2\u010b\u010c\7)\2\2\u010c\u0112\3\2\2\2\u010d\u010e\7^\2\2\u010e\u0111"+ + "\7)\2\2\u010f\u0111\n\7\2\2\u0110\u010d\3\2\2\2\u0110\u010f\3\2\2\2\u0111"+ + "\u0114\3\2\2\2\u0112\u0110\3\2\2\2\u0112\u0113\3\2\2\2\u0113\u0115\3\2"+ + "\2\2\u0114\u0112\3\2\2\2\u0115\u0126\7)\2\2\u0116\u0117\7$\2\2\u0117\u0118"+ + "\7$\2\2\u0118\u0119\7$\2\2\u0119\u011f\3\2\2\2\u011a\u011b\7^\2\2\u011b"+ + "\u011e\7$\2\2\u011c\u011e\n\b\2\2\u011d\u011a\3\2\2\2\u011d\u011c\3\2"+ + "\2\2\u011e\u0121\3\2\2\2\u011f\u0120\3\2\2\2\u011f\u011d\3\2\2\2\u0120"+ + "\u0122\3\2\2\2\u0121\u011f\3\2\2\2\u0122\u0123\7$\2\2\u0123\u0124\7$\2"+ + "\2\u0124\u0126\7$\2\2\u0125\u00ea\3\2\2\2\u0125\u00f4\3\2\2\2\u0125\u00fe"+ + "\3\2\2\2\u0125\u010a\3\2\2\2\u0125\u0116\3\2\2\2\u0126N\3\2\2\2\u0127"+ + "\u0129\5W,\2\u0128\u0127\3\2\2\2\u0129\u012a\3\2\2\2\u012a\u0128\3\2\2"+ + "\2\u012a\u012b\3\2\2\2\u012bP\3\2\2\2\u012c\u012e\5W,\2\u012d\u012c\3"+ + "\2\2\2\u012e\u012f\3\2\2\2\u012f\u012d\3\2\2\2\u012f\u0130\3\2\2\2\u0130"+ + "\u0131\3\2\2\2\u0131\u0135\5=\37\2\u0132\u0134\5W,\2\u0133\u0132\3\2\2"+ + "\2\u0134\u0137\3\2\2\2\u0135\u0133\3\2\2\2\u0135\u0136\3\2\2\2\u0136\u0157"+ + "\3\2\2\2\u0137\u0135\3\2\2\2\u0138\u013a\5=\37\2\u0139\u013b\5W,\2\u013a"+ + "\u0139\3\2\2\2\u013b\u013c\3\2\2\2\u013c\u013a\3\2\2\2\u013c\u013d\3\2"+ + "\2\2\u013d\u0157\3\2\2\2\u013e\u0140\5W,\2\u013f\u013e\3\2\2\2\u0140\u0141"+ + "\3\2\2\2\u0141\u013f\3\2\2\2\u0141\u0142\3\2\2\2\u0142\u014a\3\2\2\2\u0143"+ + "\u0147\5=\37\2\u0144\u0146\5W,\2\u0145\u0144\3\2\2\2\u0146\u0149\3\2\2"+ + "\2\u0147\u0145\3\2\2\2\u0147\u0148\3\2\2\2\u0148\u014b\3\2\2\2\u0149\u0147"+ + "\3\2\2\2\u014a\u0143\3\2\2\2\u014a\u014b\3\2\2\2\u014b\u014c\3\2\2\2\u014c"+ + "\u014d\5U+\2\u014d\u0157\3\2\2\2\u014e\u0150\5=\37\2\u014f\u0151\5W,\2"+ + "\u0150\u014f\3\2\2\2\u0151\u0152\3\2\2\2\u0152\u0150\3\2\2\2\u0152\u0153"+ + "\3\2\2\2\u0153\u0154\3\2\2\2\u0154\u0155\5U+\2\u0155\u0157\3\2\2\2\u0156"+ + "\u012d\3\2\2\2\u0156\u0138\3\2\2\2\u0156\u013f\3\2\2\2\u0156\u014e\3\2"+ + "\2\2\u0157R\3\2\2\2\u0158\u015b\5Y-\2\u0159\u015b\t\t\2\2\u015a\u0158"+ + "\3\2\2\2\u015a\u0159\3\2\2\2\u015b\u0161\3\2\2\2\u015c\u0160\5Y-\2\u015d"+ + "\u0160\5W,\2\u015e\u0160\7a\2\2\u015f\u015c\3\2\2\2\u015f\u015d\3\2\2"+ + "\2\u015f\u015e\3\2\2\2\u0160\u0163\3\2\2\2\u0161\u015f\3\2\2\2\u0161\u0162"+ + "\3\2\2\2\u0162T\3\2\2\2\u0163\u0161\3\2\2\2\u0164\u0166\t\n\2\2\u0165"+ + "\u0167\t\13\2\2\u0166\u0165\3\2\2\2\u0166\u0167\3\2\2\2\u0167\u0169\3"+ + "\2\2\2\u0168\u016a\5W,\2\u0169\u0168\3\2\2\2\u016a\u016b\3\2\2\2\u016b"+ + "\u0169\3\2\2\2\u016b\u016c\3\2\2\2\u016cV\3\2\2\2\u016d\u016e\t\f\2\2"+ + "\u016eX\3\2\2\2\u016f\u0170\t\r\2\2\u0170Z\3\2\2\2\u0171\u0172\7\61\2"+ + "\2\u0172\u0173\7\61\2\2\u0173\u0177\3\2\2\2\u0174\u0176\n\b\2\2\u0175"+ + "\u0174\3\2\2\2\u0176\u0179\3\2\2\2\u0177\u0175\3\2\2\2\u0177\u0178\3\2"+ + "\2\2\u0178\u017b\3\2\2\2\u0179\u0177\3\2\2\2\u017a\u017c\7\17\2\2\u017b"+ + "\u017a\3\2\2\2\u017b\u017c\3\2\2\2\u017c\u017e\3\2\2\2\u017d\u017f\7\f"+ + "\2\2\u017e\u017d\3\2\2\2\u017e\u017f\3\2\2\2\u017f\u0180\3\2\2\2\u0180"+ + "\u0181\b.\2\2\u0181\\\3\2\2\2\u0182\u0183\7\61\2\2\u0183\u0184\7,\2\2"+ + "\u0184\u0189\3\2\2\2\u0185\u0188\5]/\2\u0186\u0188\13\2\2\2\u0187\u0185"+ + "\3\2\2\2\u0187\u0186\3\2\2\2\u0188\u018b\3\2\2\2\u0189\u018a\3\2\2\2\u0189"+ + "\u0187\3\2\2\2\u018a\u018c\3\2\2\2\u018b\u0189\3\2\2\2\u018c\u018d\7,"+ + "\2\2\u018d\u018e\7\61\2\2\u018e\u018f\3\2\2\2\u018f\u0190\b/\2\2\u0190"+ + "^\3\2\2\2\u0191\u0193\t\16\2\2\u0192\u0191\3\2\2\2\u0193\u0194\3\2\2\2"+ + "\u0194\u0192\3\2\2\2\u0194\u0195\3\2\2\2\u0195\u0196\3\2\2\2\u0196\u0197"+ + "\b\60\2\2\u0197`\3\2\2\2$\2\u00e3\u00e5\u00ee\u00f0\u00f8\u00fa\u0104"+ + "\u0106\u0110\u0112\u011d\u011f\u0125\u012a\u012f\u0135\u013c\u0141\u0147"+ + "\u014a\u0152\u0156\u015a\u015f\u0161\u0166\u016b\u0177\u017b\u017e\u0187"+ + "\u0189\u0194\3\2\3\2"; public static final ATN _ATN = new ATNDeserializer().deserialize(_serializedATN.toCharArray()); static { diff --git a/x-pack/plugin/eql/src/test/java/org/elasticsearch/xpack/eql/parser/ExpressionTests.java b/x-pack/plugin/eql/src/test/java/org/elasticsearch/xpack/eql/parser/ExpressionTests.java index 52a075c90a96f..6f4a33856f585 100644 --- a/x-pack/plugin/eql/src/test/java/org/elasticsearch/xpack/eql/parser/ExpressionTests.java +++ b/x-pack/plugin/eql/src/test/java/org/elasticsearch/xpack/eql/parser/ExpressionTests.java @@ -68,15 +68,16 @@ public void testStrings() { // test for unescaped strings: """....""" assertEquals("hello\"world", unquoteString(source("\"\"\"hello\"world\"\"\""))); - assertEquals("hello\\\"world", unquoteString(source("\"\"\"hello\\\"world\"\"\""))); - assertEquals("\"\"hello\"\\\"world\"\"\"", unquoteString(source("\"\"\"\"\"hello\"\\\"world\"\"\"\"\"\""))); + assertEquals("hello\"world", unquoteString(source("\"\"\"hello\\\"world\"\"\""))); + assertEquals("\"\"hello\"\"world\"\"\"", unquoteString(source("\"\"\"\"\"hello\"\\\"world\"\"\"\"\"\""))); assertEquals("hello'world", unquoteString(source("\"\"\"hello'world\"\"\""))); assertEquals("hello'world", unquoteString(source("\"\"\"hello\'world\"\"\""))); + assertEquals("hello\\'world", unquoteString(source("\"\"\"hello\\\'world\"\"\""))); assertEquals("hello\\nworld", unquoteString(source("\"\"\"hello\\nworld\"\"\""))); assertEquals("hello\\\\nworld", unquoteString(source("\"\"\"hello\\\\nworld\"\"\""))); assertEquals("hello\\\\\\nworld", unquoteString(source("\"\"\"hello\\\\\\nworld\"\"\""))); - assertEquals("hello\\\\\\\"world", unquoteString(source("\"\"\"hello\\\\\\\"world\"\"\""))); - assertEquals("\"\\\"", unquoteString(source("\"\"\"\"\\\"\"\"\""))); + assertEquals("hello\\\\\"world", unquoteString(source("\"\"\"hello\\\\\\\"world\"\"\""))); + assertEquals("\"\"", unquoteString(source("\"\"\"\"\\\"\"\"\""))); assertEquals("\"\"\"", unquoteString(source("\"\"\"\\\"\"\"\"\"\""))); assertEquals("\"\"\"", unquoteString(source("\"\"\"\"\\\"\"\"\"\""))); assertEquals("\"\"\"", unquoteString(source("\"\"\"\"\"\\\"\"\"\""))); @@ -138,10 +139,10 @@ public void testTripleDoubleQuotedUnescapedString() { assertEquals(Literal.class, eq.right().getClass()); assertEquals(expectedStrRight, ((Literal) eq.right()).value()); - // """""hello\"""world!""""" == """"foo"\""bar"""" => ""hello"""world!"" = "foo"""bar" - str = "\"\"\"\"\"hello\\\"\"\"world!\"\"\"\"\" == \"\"\"\"foo\"\\\"\"bar\"\"\"\""; - expectedStrLeft = "\"\"hello\"\"\"world!"; - expectedStrRight = "\"foo\"\"\"bar\""; + // """""hello\"""world!\"""" == """"foo"\""bar""\"""" => ""hello"""world!" = "foo"""bar""" + str = " \"\"\"\"\"hello\\\"\"\"world!\\\"\"\"\" == \"\"\"\"foo\"\\\"\"bar\"\"\\\"\"\"\" "; + expectedStrLeft = "\"\"hello\"\"\"world!\""; + expectedStrRight = "\"foo\"\"\"bar\"\"\""; parsed = expr(str); assertEquals(Equals.class, parsed.getClass()); eq = (Equals) parsed; @@ -149,6 +150,40 @@ public void testTripleDoubleQuotedUnescapedString() { assertEquals(expectedStrLeft, ((Literal) eq.left()).value()); assertEquals(Literal.class, eq.right().getClass()); assertEquals(expectedStrRight, ((Literal) eq.right()).value()); + + // """""\"""hello\\"""\"""world!\\"""\"""" == """\\"""\"""foo\\"""\"\"""\\"bar""\\"""\"""" => + // """""hello\""""""world!\"""" == \""""""foo\"""""""\"bar""\"""" + str = "\"\"\"\"\"\\\"\"\"hello\\\\\"\"\"\\\"\"\"world!\\\\\"\"\"\\\"\"\"\" == " + + "\"\"\"\\\\\"\"\"\\\"\"\"foo\\\\\"\"\"\\\"\\\"\"\"\\\\\"bar\"\"\\\\\"\"\"\\\"\"\"\""; + expectedStrLeft = "\"\"\"\"\"hello\\\"\"\"\"\"\"world!\\\"\"\"\""; + expectedStrRight = "\\\"\"\"\"\"\"foo\\\"\"\"\"\"\"\"\\\"bar\"\"\\\"\"\"\""; + parsed = expr(str); + assertEquals(Equals.class, parsed.getClass()); + eq = (Equals) parsed; + assertEquals(Literal.class, eq.left().getClass()); + assertEquals(expectedStrLeft, ((Literal) eq.left()).value()); + assertEquals(Literal.class, eq.right().getClass()); + assertEquals(expectedStrRight, ((Literal) eq.right()).value()); + + // """"""hello world!""" == """foobar""" + ParsingException e = expectThrows(ParsingException.class, "Expected syntax error", + () -> expr("\"\"\"\"\"\"hello world!\"\"\" == \"\"\"foobar\"\"\"")); + assertThat(e.getMessage(), startsWith("line 1:7: mismatched input 'hello' expecting {,")); + + // """""\"hello world!"""" == """foobar""" + e = expectThrows(ParsingException.class, "Expected syntax error", + () -> expr("\"\"\"\"\"\\\"hello world!\"\"\"\" == \"\"\"foobar\"\"\"")); + assertThat(e.getMessage(), startsWith("line 1:23: mismatched input '\" == \"' expecting {,")); + + // """""\"hello world!""\"""" == """"""foobar""" + e = expectThrows(ParsingException.class, "Expected syntax error", + () -> expr("\"\"\"\"\"\\\"hello world!\"\"\\\"\"\"\" == \"\"\"\"\"\"foobar\"\"\"")); + assertThat(e.getMessage(), startsWith("line 1:37: mismatched input 'foobar' expecting {,")); + + // """""\"hello world!""\"""" == """""\"foobar\"\"""""" + e = expectThrows(ParsingException.class, "Expected syntax error", + () -> expr("\"\"\"\"\"\\\"hello world!\"\"\\\"\"\"\" == \"\"\"\"\"\\\"foobar\\\"\\\"\"\"\"\"\"")); + assertThat(e.getMessage(), startsWith("line 1:51: extraneous input '\"\"' expecting {,")); } public void testNumbers() { From f838bc255660064effe3c50e1e7507d8aceb4385 Mon Sep 17 00:00:00 2001 From: Marios Trivyzas Date: Fri, 2 Oct 2020 13:59:41 +0300 Subject: [PATCH 8/8] Disallow any triple double quote sequence and everything is raw --- x-pack/plugin/eql/src/main/antlr/EqlBase.g4 | 2 +- .../xpack/eql/parser/AbstractBuilder.java | 2 +- .../xpack/eql/parser/EqlBaseLexer.java | 254 +++++++++--------- .../xpack/eql/parser/ExpressionTests.java | 42 +-- 4 files changed, 151 insertions(+), 149 deletions(-) diff --git a/x-pack/plugin/eql/src/main/antlr/EqlBase.g4 b/x-pack/plugin/eql/src/main/antlr/EqlBase.g4 index cfb2c0da10b0c..7f3f92c1b9a36 100644 --- a/x-pack/plugin/eql/src/main/antlr/EqlBase.g4 +++ b/x-pack/plugin/eql/src/main/antlr/EqlBase.g4 @@ -202,7 +202,7 @@ STRING | '"' ('\\' [btnfr"'\\] | ~[\r\n"\\])* '"' | '?"' ('\\"' |~["\r\n])* '"' | '?\'' ('\\\'' |~['\r\n])* '\'' - | '"""' ('\\"' |~[\r\n])*? '"""' + | '"""' (~[\r\n])*? '"""' '"'? '"'? ; INTEGER_VALUE diff --git a/x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/parser/AbstractBuilder.java b/x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/parser/AbstractBuilder.java index f5a5cc65c42aa..c8adc2d97a2a9 100644 --- a/x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/parser/AbstractBuilder.java +++ b/x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/parser/AbstractBuilder.java @@ -130,7 +130,7 @@ public static String unquoteString(Source source) { // unescaped strings can be interpreted directly if (text.startsWith("\"\"\"")) { - return text.substring(3, text.length() - 3).replace("\\\"", "\""); + return text.substring(3, text.length() - 3); } checkForSingleQuotedString(source, text, 0); diff --git a/x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/parser/EqlBaseLexer.java b/x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/parser/EqlBaseLexer.java index b266917514a6c..943c1e5217602 100644 --- a/x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/parser/EqlBaseLexer.java +++ b/x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/parser/EqlBaseLexer.java @@ -106,7 +106,7 @@ public EqlBaseLexer(CharStream input) { public ATN getATN() { return _ATN; } public static final String _serializedATN = - "\3\u0430\ud6d1\u8206\uad2d\u4417\uaef1\u8d80\uaadd\2.\u0195\b\1\4\2\t"+ + "\3\u0430\ud6d1\u8206\uad2d\u4417\uaef1\u8d80\uaadd\2.\u019a\b\1\4\2\t"+ "\2\4\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7\t\7\4\b\t\b\4\t\t\t\4\n\t\n\4\13"+ "\t\13\4\f\t\f\4\r\t\r\4\16\t\16\4\17\t\17\4\20\t\20\4\21\t\21\4\22\t\22"+ "\4\23\t\23\4\24\t\24\4\25\t\25\4\26\t\26\4\27\t\27\4\30\t\30\4\31\t\31"+ @@ -124,131 +124,133 @@ public EqlBaseLexer(CharStream input) { "\'\3\'\7\'\u00ec\n\'\f\'\16\'\u00ef\13\'\3\'\3\'\3\'\3\'\3\'\7\'\u00f6"+ "\n\'\f\'\16\'\u00f9\13\'\3\'\3\'\3\'\3\'\3\'\3\'\3\'\7\'\u0102\n\'\f\'"+ "\16\'\u0105\13\'\3\'\3\'\3\'\3\'\3\'\3\'\3\'\7\'\u010e\n\'\f\'\16\'\u0111"+ - "\13\'\3\'\3\'\3\'\3\'\3\'\3\'\3\'\3\'\7\'\u011b\n\'\f\'\16\'\u011e\13"+ - "\'\3\'\3\'\3\'\5\'\u0123\n\'\3(\6(\u0126\n(\r(\16(\u0127\3)\6)\u012b\n"+ - ")\r)\16)\u012c\3)\3)\7)\u0131\n)\f)\16)\u0134\13)\3)\3)\6)\u0138\n)\r"+ - ")\16)\u0139\3)\6)\u013d\n)\r)\16)\u013e\3)\3)\7)\u0143\n)\f)\16)\u0146"+ - "\13)\5)\u0148\n)\3)\3)\3)\3)\6)\u014e\n)\r)\16)\u014f\3)\3)\5)\u0154\n"+ - ")\3*\3*\5*\u0158\n*\3*\3*\3*\7*\u015d\n*\f*\16*\u0160\13*\3+\3+\5+\u0164"+ - "\n+\3+\6+\u0167\n+\r+\16+\u0168\3,\3,\3-\3-\3.\3.\3.\3.\7.\u0173\n.\f"+ - ".\16.\u0176\13.\3.\5.\u0179\n.\3.\5.\u017c\n.\3.\3.\3/\3/\3/\3/\3/\7/"+ - "\u0185\n/\f/\16/\u0188\13/\3/\3/\3/\3/\3/\3\60\6\60\u0190\n\60\r\60\16"+ - "\60\u0191\3\60\3\60\4\u011c\u0186\2\61\3\3\5\4\7\5\t\6\13\7\r\b\17\t\21"+ - "\n\23\13\25\f\27\r\31\16\33\17\35\20\37\21!\22#\23%\24\'\25)\26+\27-\30"+ - "/\31\61\32\63\33\65\34\67\359\36;\37= ?!A\"C#E$G%I&K\'M(O)Q*S+U\2W\2Y"+ - "\2[,]-_.\3\2\17\3\2bb\n\2$$))^^ddhhppttvv\6\2\f\f\17\17))^^\6\2\f\f\17"+ - "\17$$^^\5\2\f\f\17\17$$\5\2\f\f\17\17))\4\2\f\f\17\17\4\2BBaa\4\2GGgg"+ - "\4\2--//\3\2\62;\4\2C\\c|\5\2\13\f\17\17\"\"\u01b8\2\3\3\2\2\2\2\5\3\2"+ - "\2\2\2\7\3\2\2\2\2\t\3\2\2\2\2\13\3\2\2\2\2\r\3\2\2\2\2\17\3\2\2\2\2\21"+ - "\3\2\2\2\2\23\3\2\2\2\2\25\3\2\2\2\2\27\3\2\2\2\2\31\3\2\2\2\2\33\3\2"+ - "\2\2\2\35\3\2\2\2\2\37\3\2\2\2\2!\3\2\2\2\2#\3\2\2\2\2%\3\2\2\2\2\'\3"+ - "\2\2\2\2)\3\2\2\2\2+\3\2\2\2\2-\3\2\2\2\2/\3\2\2\2\2\61\3\2\2\2\2\63\3"+ - "\2\2\2\2\65\3\2\2\2\2\67\3\2\2\2\29\3\2\2\2\2;\3\2\2\2\2=\3\2\2\2\2?\3"+ - "\2\2\2\2A\3\2\2\2\2C\3\2\2\2\2E\3\2\2\2\2G\3\2\2\2\2I\3\2\2\2\2K\3\2\2"+ - "\2\2M\3\2\2\2\2O\3\2\2\2\2Q\3\2\2\2\2S\3\2\2\2\2[\3\2\2\2\2]\3\2\2\2\2"+ - "_\3\2\2\2\3a\3\2\2\2\5e\3\2\2\2\7i\3\2\2\2\tl\3\2\2\2\13r\3\2\2\2\ru\3"+ - "\2\2\2\17z\3\2\2\2\21\u0082\3\2\2\2\23\u0086\3\2\2\2\25\u008b\3\2\2\2"+ - "\27\u008e\3\2\2\2\31\u0091\3\2\2\2\33\u009a\3\2\2\2\35\u009f\3\2\2\2\37"+ - "\u00a5\3\2\2\2!\u00ab\3\2\2\2#\u00b0\3\2\2\2%\u00b2\3\2\2\2\'\u00b4\3"+ - "\2\2\2)\u00b7\3\2\2\2+\u00ba\3\2\2\2-\u00bc\3\2\2\2/\u00bf\3\2\2\2\61"+ - "\u00c1\3\2\2\2\63\u00c4\3\2\2\2\65\u00c6\3\2\2\2\67\u00c8\3\2\2\29\u00ca"+ - "\3\2\2\2;\u00cc\3\2\2\2=\u00ce\3\2\2\2?\u00d0\3\2\2\2A\u00d2\3\2\2\2C"+ - "\u00d4\3\2\2\2E\u00d6\3\2\2\2G\u00d8\3\2\2\2I\u00da\3\2\2\2K\u00dc\3\2"+ - "\2\2M\u0122\3\2\2\2O\u0125\3\2\2\2Q\u0153\3\2\2\2S\u0157\3\2\2\2U\u0161"+ - "\3\2\2\2W\u016a\3\2\2\2Y\u016c\3\2\2\2[\u016e\3\2\2\2]\u017f\3\2\2\2_"+ - "\u018f\3\2\2\2ab\7c\2\2bc\7p\2\2cd\7f\2\2d\4\3\2\2\2ef\7c\2\2fg\7p\2\2"+ - "gh\7{\2\2h\6\3\2\2\2ij\7d\2\2jk\7{\2\2k\b\3\2\2\2lm\7h\2\2mn\7c\2\2no"+ - "\7n\2\2op\7u\2\2pq\7g\2\2q\n\3\2\2\2rs\7k\2\2st\7p\2\2t\f\3\2\2\2uv\7"+ - "l\2\2vw\7q\2\2wx\7k\2\2xy\7p\2\2y\16\3\2\2\2z{\7o\2\2{|\7c\2\2|}\7z\2"+ - "\2}~\7u\2\2~\177\7r\2\2\177\u0080\7c\2\2\u0080\u0081\7p\2\2\u0081\20\3"+ - "\2\2\2\u0082\u0083\7p\2\2\u0083\u0084\7q\2\2\u0084\u0085\7v\2\2\u0085"+ - "\22\3\2\2\2\u0086\u0087\7p\2\2\u0087\u0088\7w\2\2\u0088\u0089\7n\2\2\u0089"+ - "\u008a\7n\2\2\u008a\24\3\2\2\2\u008b\u008c\7q\2\2\u008c\u008d\7h\2\2\u008d"+ - "\26\3\2\2\2\u008e\u008f\7q\2\2\u008f\u0090\7t\2\2\u0090\30\3\2\2\2\u0091"+ - "\u0092\7u\2\2\u0092\u0093\7g\2\2\u0093\u0094\7s\2\2\u0094\u0095\7w\2\2"+ - "\u0095\u0096\7g\2\2\u0096\u0097\7p\2\2\u0097\u0098\7e\2\2\u0098\u0099"+ - "\7g\2\2\u0099\32\3\2\2\2\u009a\u009b\7v\2\2\u009b\u009c\7t\2\2\u009c\u009d"+ - "\7w\2\2\u009d\u009e\7g\2\2\u009e\34\3\2\2\2\u009f\u00a0\7w\2\2\u00a0\u00a1"+ - "\7p\2\2\u00a1\u00a2\7v\2\2\u00a2\u00a3\7k\2\2\u00a3\u00a4\7n\2\2\u00a4"+ - "\36\3\2\2\2\u00a5\u00a6\7y\2\2\u00a6\u00a7\7j\2\2\u00a7\u00a8\7g\2\2\u00a8"+ - "\u00a9\7t\2\2\u00a9\u00aa\7g\2\2\u00aa \3\2\2\2\u00ab\u00ac\7y\2\2\u00ac"+ - "\u00ad\7k\2\2\u00ad\u00ae\7v\2\2\u00ae\u00af\7j\2\2\u00af\"\3\2\2\2\u00b0"+ - "\u00b1\7<\2\2\u00b1$\3\2\2\2\u00b2\u00b3\7?\2\2\u00b3&\3\2\2\2\u00b4\u00b5"+ - "\7?\2\2\u00b5\u00b6\7?\2\2\u00b6(\3\2\2\2\u00b7\u00b8\7#\2\2\u00b8\u00b9"+ - "\7?\2\2\u00b9*\3\2\2\2\u00ba\u00bb\7>\2\2\u00bb,\3\2\2\2\u00bc\u00bd\7"+ - ">\2\2\u00bd\u00be\7?\2\2\u00be.\3\2\2\2\u00bf\u00c0\7@\2\2\u00c0\60\3"+ - "\2\2\2\u00c1\u00c2\7@\2\2\u00c2\u00c3\7?\2\2\u00c3\62\3\2\2\2\u00c4\u00c5"+ - "\7-\2\2\u00c5\64\3\2\2\2\u00c6\u00c7\7/\2\2\u00c7\66\3\2\2\2\u00c8\u00c9"+ - "\7,\2\2\u00c98\3\2\2\2\u00ca\u00cb\7\61\2\2\u00cb:\3\2\2\2\u00cc\u00cd"+ - "\7\'\2\2\u00cd<\3\2\2\2\u00ce\u00cf\7\60\2\2\u00cf>\3\2\2\2\u00d0\u00d1"+ - "\7.\2\2\u00d1@\3\2\2\2\u00d2\u00d3\7]\2\2\u00d3B\3\2\2\2\u00d4\u00d5\7"+ - "_\2\2\u00d5D\3\2\2\2\u00d6\u00d7\7*\2\2\u00d7F\3\2\2\2\u00d8\u00d9\7+"+ - "\2\2\u00d9H\3\2\2\2\u00da\u00db\7~\2\2\u00dbJ\3\2\2\2\u00dc\u00e2\7b\2"+ - "\2\u00dd\u00e1\n\2\2\2\u00de\u00df\7b\2\2\u00df\u00e1\7b\2\2\u00e0\u00dd"+ - "\3\2\2\2\u00e0\u00de\3\2\2\2\u00e1\u00e4\3\2\2\2\u00e2\u00e0\3\2\2\2\u00e2"+ - "\u00e3\3\2\2\2\u00e3\u00e5\3\2\2\2\u00e4\u00e2\3\2\2\2\u00e5\u00e6\7b"+ - "\2\2\u00e6L\3\2\2\2\u00e7\u00ed\7)\2\2\u00e8\u00e9\7^\2\2\u00e9\u00ec"+ - "\t\3\2\2\u00ea\u00ec\n\4\2\2\u00eb\u00e8\3\2\2\2\u00eb\u00ea\3\2\2\2\u00ec"+ - "\u00ef\3\2\2\2\u00ed\u00eb\3\2\2\2\u00ed\u00ee\3\2\2\2\u00ee\u00f0\3\2"+ - "\2\2\u00ef\u00ed\3\2\2\2\u00f0\u0123\7)\2\2\u00f1\u00f7\7$\2\2\u00f2\u00f3"+ - "\7^\2\2\u00f3\u00f6\t\3\2\2\u00f4\u00f6\n\5\2\2\u00f5\u00f2\3\2\2\2\u00f5"+ - "\u00f4\3\2\2\2\u00f6\u00f9\3\2\2\2\u00f7\u00f5\3\2\2\2\u00f7\u00f8\3\2"+ - "\2\2\u00f8\u00fa\3\2\2\2\u00f9\u00f7\3\2\2\2\u00fa\u0123\7$\2\2\u00fb"+ - "\u00fc\7A\2\2\u00fc\u00fd\7$\2\2\u00fd\u0103\3\2\2\2\u00fe\u00ff\7^\2"+ - "\2\u00ff\u0102\7$\2\2\u0100\u0102\n\6\2\2\u0101\u00fe\3\2\2\2\u0101\u0100"+ - "\3\2\2\2\u0102\u0105\3\2\2\2\u0103\u0101\3\2\2\2\u0103\u0104\3\2\2\2\u0104"+ - "\u0106\3\2\2\2\u0105\u0103\3\2\2\2\u0106\u0123\7$\2\2\u0107\u0108\7A\2"+ - "\2\u0108\u0109\7)\2\2\u0109\u010f\3\2\2\2\u010a\u010b\7^\2\2\u010b\u010e"+ - "\7)\2\2\u010c\u010e\n\7\2\2\u010d\u010a\3\2\2\2\u010d\u010c\3\2\2\2\u010e"+ - "\u0111\3\2\2\2\u010f\u010d\3\2\2\2\u010f\u0110\3\2\2\2\u0110\u0112\3\2"+ - "\2\2\u0111\u010f\3\2\2\2\u0112\u0123\7)\2\2\u0113\u0114\7$\2\2\u0114\u0115"+ - "\7$\2\2\u0115\u0116\7$\2\2\u0116\u011c\3\2\2\2\u0117\u0118\7^\2\2\u0118"+ - "\u011b\7$\2\2\u0119\u011b\n\b\2\2\u011a\u0117\3\2\2\2\u011a\u0119\3\2"+ - "\2\2\u011b\u011e\3\2\2\2\u011c\u011d\3\2\2\2\u011c\u011a\3\2\2\2\u011d"+ - "\u011f\3\2\2\2\u011e\u011c\3\2\2\2\u011f\u0120\7$\2\2\u0120\u0121\7$\2"+ - "\2\u0121\u0123\7$\2\2\u0122\u00e7\3\2\2\2\u0122\u00f1\3\2\2\2\u0122\u00fb"+ - "\3\2\2\2\u0122\u0107\3\2\2\2\u0122\u0113\3\2\2\2\u0123N\3\2\2\2\u0124"+ - "\u0126\5W,\2\u0125\u0124\3\2\2\2\u0126\u0127\3\2\2\2\u0127\u0125\3\2\2"+ - "\2\u0127\u0128\3\2\2\2\u0128P\3\2\2\2\u0129\u012b\5W,\2\u012a\u0129\3"+ - "\2\2\2\u012b\u012c\3\2\2\2\u012c\u012a\3\2\2\2\u012c\u012d\3\2\2\2\u012d"+ - "\u012e\3\2\2\2\u012e\u0132\5=\37\2\u012f\u0131\5W,\2\u0130\u012f\3\2\2"+ - "\2\u0131\u0134\3\2\2\2\u0132\u0130\3\2\2\2\u0132\u0133\3\2\2\2\u0133\u0154"+ - "\3\2\2\2\u0134\u0132\3\2\2\2\u0135\u0137\5=\37\2\u0136\u0138\5W,\2\u0137"+ - "\u0136\3\2\2\2\u0138\u0139\3\2\2\2\u0139\u0137\3\2\2\2\u0139\u013a\3\2"+ - "\2\2\u013a\u0154\3\2\2\2\u013b\u013d\5W,\2\u013c\u013b\3\2\2\2\u013d\u013e"+ - "\3\2\2\2\u013e\u013c\3\2\2\2\u013e\u013f\3\2\2\2\u013f\u0147\3\2\2\2\u0140"+ - "\u0144\5=\37\2\u0141\u0143\5W,\2\u0142\u0141\3\2\2\2\u0143\u0146\3\2\2"+ - "\2\u0144\u0142\3\2\2\2\u0144\u0145\3\2\2\2\u0145\u0148\3\2\2\2\u0146\u0144"+ - "\3\2\2\2\u0147\u0140\3\2\2\2\u0147\u0148\3\2\2\2\u0148\u0149\3\2\2\2\u0149"+ - "\u014a\5U+\2\u014a\u0154\3\2\2\2\u014b\u014d\5=\37\2\u014c\u014e\5W,\2"+ - "\u014d\u014c\3\2\2\2\u014e\u014f\3\2\2\2\u014f\u014d\3\2\2\2\u014f\u0150"+ - "\3\2\2\2\u0150\u0151\3\2\2\2\u0151\u0152\5U+\2\u0152\u0154\3\2\2\2\u0153"+ - "\u012a\3\2\2\2\u0153\u0135\3\2\2\2\u0153\u013c\3\2\2\2\u0153\u014b\3\2"+ - "\2\2\u0154R\3\2\2\2\u0155\u0158\5Y-\2\u0156\u0158\t\t\2\2\u0157\u0155"+ - "\3\2\2\2\u0157\u0156\3\2\2\2\u0158\u015e\3\2\2\2\u0159\u015d\5Y-\2\u015a"+ - "\u015d\5W,\2\u015b\u015d\7a\2\2\u015c\u0159\3\2\2\2\u015c\u015a\3\2\2"+ - "\2\u015c\u015b\3\2\2\2\u015d\u0160\3\2\2\2\u015e\u015c\3\2\2\2\u015e\u015f"+ - "\3\2\2\2\u015fT\3\2\2\2\u0160\u015e\3\2\2\2\u0161\u0163\t\n\2\2\u0162"+ - "\u0164\t\13\2\2\u0163\u0162\3\2\2\2\u0163\u0164\3\2\2\2\u0164\u0166\3"+ - "\2\2\2\u0165\u0167\5W,\2\u0166\u0165\3\2\2\2\u0167\u0168\3\2\2\2\u0168"+ - "\u0166\3\2\2\2\u0168\u0169\3\2\2\2\u0169V\3\2\2\2\u016a\u016b\t\f\2\2"+ - "\u016bX\3\2\2\2\u016c\u016d\t\r\2\2\u016dZ\3\2\2\2\u016e\u016f\7\61\2"+ - "\2\u016f\u0170\7\61\2\2\u0170\u0174\3\2\2\2\u0171\u0173\n\b\2\2\u0172"+ - "\u0171\3\2\2\2\u0173\u0176\3\2\2\2\u0174\u0172\3\2\2\2\u0174\u0175\3\2"+ - "\2\2\u0175\u0178\3\2\2\2\u0176\u0174\3\2\2\2\u0177\u0179\7\17\2\2\u0178"+ - "\u0177\3\2\2\2\u0178\u0179\3\2\2\2\u0179\u017b\3\2\2\2\u017a\u017c\7\f"+ - "\2\2\u017b\u017a\3\2\2\2\u017b\u017c\3\2\2\2\u017c\u017d\3\2\2\2\u017d"+ - "\u017e\b.\2\2\u017e\\\3\2\2\2\u017f\u0180\7\61\2\2\u0180\u0181\7,\2\2"+ - "\u0181\u0186\3\2\2\2\u0182\u0185\5]/\2\u0183\u0185\13\2\2\2\u0184\u0182"+ - "\3\2\2\2\u0184\u0183\3\2\2\2\u0185\u0188\3\2\2\2\u0186\u0187\3\2\2\2\u0186"+ - "\u0184\3\2\2\2\u0187\u0189\3\2\2\2\u0188\u0186\3\2\2\2\u0189\u018a\7,"+ - "\2\2\u018a\u018b\7\61\2\2\u018b\u018c\3\2\2\2\u018c\u018d\b/\2\2\u018d"+ - "^\3\2\2\2\u018e\u0190\t\16\2\2\u018f\u018e\3\2\2\2\u0190\u0191\3\2\2\2"+ - "\u0191\u018f\3\2\2\2\u0191\u0192\3\2\2\2\u0192\u0193\3\2\2\2\u0193\u0194"+ - "\b\60\2\2\u0194`\3\2\2\2$\2\u00e0\u00e2\u00eb\u00ed\u00f5\u00f7\u0101"+ - "\u0103\u010d\u010f\u011a\u011c\u0122\u0127\u012c\u0132\u0139\u013e\u0144"+ - "\u0147\u014f\u0153\u0157\u015c\u015e\u0163\u0168\u0174\u0178\u017b\u0184"+ - "\u0186\u0191\3\2\3\2"; + "\13\'\3\'\3\'\3\'\3\'\3\'\3\'\7\'\u0119\n\'\f\'\16\'\u011c\13\'\3\'\3"+ + "\'\3\'\3\'\3\'\5\'\u0123\n\'\3\'\5\'\u0126\n\'\5\'\u0128\n\'\3(\6(\u012b"+ + "\n(\r(\16(\u012c\3)\6)\u0130\n)\r)\16)\u0131\3)\3)\7)\u0136\n)\f)\16)"+ + "\u0139\13)\3)\3)\6)\u013d\n)\r)\16)\u013e\3)\6)\u0142\n)\r)\16)\u0143"+ + "\3)\3)\7)\u0148\n)\f)\16)\u014b\13)\5)\u014d\n)\3)\3)\3)\3)\6)\u0153\n"+ + ")\r)\16)\u0154\3)\3)\5)\u0159\n)\3*\3*\5*\u015d\n*\3*\3*\3*\7*\u0162\n"+ + "*\f*\16*\u0165\13*\3+\3+\5+\u0169\n+\3+\6+\u016c\n+\r+\16+\u016d\3,\3"+ + ",\3-\3-\3.\3.\3.\3.\7.\u0178\n.\f.\16.\u017b\13.\3.\5.\u017e\n.\3.\5."+ + "\u0181\n.\3.\3.\3/\3/\3/\3/\3/\7/\u018a\n/\f/\16/\u018d\13/\3/\3/\3/\3"+ + "/\3/\3\60\6\60\u0195\n\60\r\60\16\60\u0196\3\60\3\60\4\u011a\u018b\2\61"+ + "\3\3\5\4\7\5\t\6\13\7\r\b\17\t\21\n\23\13\25\f\27\r\31\16\33\17\35\20"+ + "\37\21!\22#\23%\24\'\25)\26+\27-\30/\31\61\32\63\33\65\34\67\359\36;\37"+ + "= ?!A\"C#E$G%I&K\'M(O)Q*S+U\2W\2Y\2[,]-_.\3\2\17\3\2bb\n\2$$))^^ddhhp"+ + "pttvv\6\2\f\f\17\17))^^\6\2\f\f\17\17$$^^\5\2\f\f\17\17$$\5\2\f\f\17\17"+ + "))\4\2\f\f\17\17\4\2BBaa\4\2GGgg\4\2--//\3\2\62;\4\2C\\c|\5\2\13\f\17"+ + "\17\"\"\u01be\2\3\3\2\2\2\2\5\3\2\2\2\2\7\3\2\2\2\2\t\3\2\2\2\2\13\3\2"+ + "\2\2\2\r\3\2\2\2\2\17\3\2\2\2\2\21\3\2\2\2\2\23\3\2\2\2\2\25\3\2\2\2\2"+ + "\27\3\2\2\2\2\31\3\2\2\2\2\33\3\2\2\2\2\35\3\2\2\2\2\37\3\2\2\2\2!\3\2"+ + "\2\2\2#\3\2\2\2\2%\3\2\2\2\2\'\3\2\2\2\2)\3\2\2\2\2+\3\2\2\2\2-\3\2\2"+ + "\2\2/\3\2\2\2\2\61\3\2\2\2\2\63\3\2\2\2\2\65\3\2\2\2\2\67\3\2\2\2\29\3"+ + "\2\2\2\2;\3\2\2\2\2=\3\2\2\2\2?\3\2\2\2\2A\3\2\2\2\2C\3\2\2\2\2E\3\2\2"+ + "\2\2G\3\2\2\2\2I\3\2\2\2\2K\3\2\2\2\2M\3\2\2\2\2O\3\2\2\2\2Q\3\2\2\2\2"+ + "S\3\2\2\2\2[\3\2\2\2\2]\3\2\2\2\2_\3\2\2\2\3a\3\2\2\2\5e\3\2\2\2\7i\3"+ + "\2\2\2\tl\3\2\2\2\13r\3\2\2\2\ru\3\2\2\2\17z\3\2\2\2\21\u0082\3\2\2\2"+ + "\23\u0086\3\2\2\2\25\u008b\3\2\2\2\27\u008e\3\2\2\2\31\u0091\3\2\2\2\33"+ + "\u009a\3\2\2\2\35\u009f\3\2\2\2\37\u00a5\3\2\2\2!\u00ab\3\2\2\2#\u00b0"+ + "\3\2\2\2%\u00b2\3\2\2\2\'\u00b4\3\2\2\2)\u00b7\3\2\2\2+\u00ba\3\2\2\2"+ + "-\u00bc\3\2\2\2/\u00bf\3\2\2\2\61\u00c1\3\2\2\2\63\u00c4\3\2\2\2\65\u00c6"+ + "\3\2\2\2\67\u00c8\3\2\2\29\u00ca\3\2\2\2;\u00cc\3\2\2\2=\u00ce\3\2\2\2"+ + "?\u00d0\3\2\2\2A\u00d2\3\2\2\2C\u00d4\3\2\2\2E\u00d6\3\2\2\2G\u00d8\3"+ + "\2\2\2I\u00da\3\2\2\2K\u00dc\3\2\2\2M\u0127\3\2\2\2O\u012a\3\2\2\2Q\u0158"+ + "\3\2\2\2S\u015c\3\2\2\2U\u0166\3\2\2\2W\u016f\3\2\2\2Y\u0171\3\2\2\2["+ + "\u0173\3\2\2\2]\u0184\3\2\2\2_\u0194\3\2\2\2ab\7c\2\2bc\7p\2\2cd\7f\2"+ + "\2d\4\3\2\2\2ef\7c\2\2fg\7p\2\2gh\7{\2\2h\6\3\2\2\2ij\7d\2\2jk\7{\2\2"+ + "k\b\3\2\2\2lm\7h\2\2mn\7c\2\2no\7n\2\2op\7u\2\2pq\7g\2\2q\n\3\2\2\2rs"+ + "\7k\2\2st\7p\2\2t\f\3\2\2\2uv\7l\2\2vw\7q\2\2wx\7k\2\2xy\7p\2\2y\16\3"+ + "\2\2\2z{\7o\2\2{|\7c\2\2|}\7z\2\2}~\7u\2\2~\177\7r\2\2\177\u0080\7c\2"+ + "\2\u0080\u0081\7p\2\2\u0081\20\3\2\2\2\u0082\u0083\7p\2\2\u0083\u0084"+ + "\7q\2\2\u0084\u0085\7v\2\2\u0085\22\3\2\2\2\u0086\u0087\7p\2\2\u0087\u0088"+ + "\7w\2\2\u0088\u0089\7n\2\2\u0089\u008a\7n\2\2\u008a\24\3\2\2\2\u008b\u008c"+ + "\7q\2\2\u008c\u008d\7h\2\2\u008d\26\3\2\2\2\u008e\u008f\7q\2\2\u008f\u0090"+ + "\7t\2\2\u0090\30\3\2\2\2\u0091\u0092\7u\2\2\u0092\u0093\7g\2\2\u0093\u0094"+ + "\7s\2\2\u0094\u0095\7w\2\2\u0095\u0096\7g\2\2\u0096\u0097\7p\2\2\u0097"+ + "\u0098\7e\2\2\u0098\u0099\7g\2\2\u0099\32\3\2\2\2\u009a\u009b\7v\2\2\u009b"+ + "\u009c\7t\2\2\u009c\u009d\7w\2\2\u009d\u009e\7g\2\2\u009e\34\3\2\2\2\u009f"+ + "\u00a0\7w\2\2\u00a0\u00a1\7p\2\2\u00a1\u00a2\7v\2\2\u00a2\u00a3\7k\2\2"+ + "\u00a3\u00a4\7n\2\2\u00a4\36\3\2\2\2\u00a5\u00a6\7y\2\2\u00a6\u00a7\7"+ + "j\2\2\u00a7\u00a8\7g\2\2\u00a8\u00a9\7t\2\2\u00a9\u00aa\7g\2\2\u00aa "+ + "\3\2\2\2\u00ab\u00ac\7y\2\2\u00ac\u00ad\7k\2\2\u00ad\u00ae\7v\2\2\u00ae"+ + "\u00af\7j\2\2\u00af\"\3\2\2\2\u00b0\u00b1\7<\2\2\u00b1$\3\2\2\2\u00b2"+ + "\u00b3\7?\2\2\u00b3&\3\2\2\2\u00b4\u00b5\7?\2\2\u00b5\u00b6\7?\2\2\u00b6"+ + "(\3\2\2\2\u00b7\u00b8\7#\2\2\u00b8\u00b9\7?\2\2\u00b9*\3\2\2\2\u00ba\u00bb"+ + "\7>\2\2\u00bb,\3\2\2\2\u00bc\u00bd\7>\2\2\u00bd\u00be\7?\2\2\u00be.\3"+ + "\2\2\2\u00bf\u00c0\7@\2\2\u00c0\60\3\2\2\2\u00c1\u00c2\7@\2\2\u00c2\u00c3"+ + "\7?\2\2\u00c3\62\3\2\2\2\u00c4\u00c5\7-\2\2\u00c5\64\3\2\2\2\u00c6\u00c7"+ + "\7/\2\2\u00c7\66\3\2\2\2\u00c8\u00c9\7,\2\2\u00c98\3\2\2\2\u00ca\u00cb"+ + "\7\61\2\2\u00cb:\3\2\2\2\u00cc\u00cd\7\'\2\2\u00cd<\3\2\2\2\u00ce\u00cf"+ + "\7\60\2\2\u00cf>\3\2\2\2\u00d0\u00d1\7.\2\2\u00d1@\3\2\2\2\u00d2\u00d3"+ + "\7]\2\2\u00d3B\3\2\2\2\u00d4\u00d5\7_\2\2\u00d5D\3\2\2\2\u00d6\u00d7\7"+ + "*\2\2\u00d7F\3\2\2\2\u00d8\u00d9\7+\2\2\u00d9H\3\2\2\2\u00da\u00db\7~"+ + "\2\2\u00dbJ\3\2\2\2\u00dc\u00e2\7b\2\2\u00dd\u00e1\n\2\2\2\u00de\u00df"+ + "\7b\2\2\u00df\u00e1\7b\2\2\u00e0\u00dd\3\2\2\2\u00e0\u00de\3\2\2\2\u00e1"+ + "\u00e4\3\2\2\2\u00e2\u00e0\3\2\2\2\u00e2\u00e3\3\2\2\2\u00e3\u00e5\3\2"+ + "\2\2\u00e4\u00e2\3\2\2\2\u00e5\u00e6\7b\2\2\u00e6L\3\2\2\2\u00e7\u00ed"+ + "\7)\2\2\u00e8\u00e9\7^\2\2\u00e9\u00ec\t\3\2\2\u00ea\u00ec\n\4\2\2\u00eb"+ + "\u00e8\3\2\2\2\u00eb\u00ea\3\2\2\2\u00ec\u00ef\3\2\2\2\u00ed\u00eb\3\2"+ + "\2\2\u00ed\u00ee\3\2\2\2\u00ee\u00f0\3\2\2\2\u00ef\u00ed\3\2\2\2\u00f0"+ + "\u0128\7)\2\2\u00f1\u00f7\7$\2\2\u00f2\u00f3\7^\2\2\u00f3\u00f6\t\3\2"+ + "\2\u00f4\u00f6\n\5\2\2\u00f5\u00f2\3\2\2\2\u00f5\u00f4\3\2\2\2\u00f6\u00f9"+ + "\3\2\2\2\u00f7\u00f5\3\2\2\2\u00f7\u00f8\3\2\2\2\u00f8\u00fa\3\2\2\2\u00f9"+ + "\u00f7\3\2\2\2\u00fa\u0128\7$\2\2\u00fb\u00fc\7A\2\2\u00fc\u00fd\7$\2"+ + "\2\u00fd\u0103\3\2\2\2\u00fe\u00ff\7^\2\2\u00ff\u0102\7$\2\2\u0100\u0102"+ + "\n\6\2\2\u0101\u00fe\3\2\2\2\u0101\u0100\3\2\2\2\u0102\u0105\3\2\2\2\u0103"+ + "\u0101\3\2\2\2\u0103\u0104\3\2\2\2\u0104\u0106\3\2\2\2\u0105\u0103\3\2"+ + "\2\2\u0106\u0128\7$\2\2\u0107\u0108\7A\2\2\u0108\u0109\7)\2\2\u0109\u010f"+ + "\3\2\2\2\u010a\u010b\7^\2\2\u010b\u010e\7)\2\2\u010c\u010e\n\7\2\2\u010d"+ + "\u010a\3\2\2\2\u010d\u010c\3\2\2\2\u010e\u0111\3\2\2\2\u010f\u010d\3\2"+ + "\2\2\u010f\u0110\3\2\2\2\u0110\u0112\3\2\2\2\u0111\u010f\3\2\2\2\u0112"+ + "\u0128\7)\2\2\u0113\u0114\7$\2\2\u0114\u0115\7$\2\2\u0115\u0116\7$\2\2"+ + "\u0116\u011a\3\2\2\2\u0117\u0119\n\b\2\2\u0118\u0117\3\2\2\2\u0119\u011c"+ + "\3\2\2\2\u011a\u011b\3\2\2\2\u011a\u0118\3\2\2\2\u011b\u011d\3\2\2\2\u011c"+ + "\u011a\3\2\2\2\u011d\u011e\7$\2\2\u011e\u011f\7$\2\2\u011f\u0120\7$\2"+ + "\2\u0120\u0122\3\2\2\2\u0121\u0123\7$\2\2\u0122\u0121\3\2\2\2\u0122\u0123"+ + "\3\2\2\2\u0123\u0125\3\2\2\2\u0124\u0126\7$\2\2\u0125\u0124\3\2\2\2\u0125"+ + "\u0126\3\2\2\2\u0126\u0128\3\2\2\2\u0127\u00e7\3\2\2\2\u0127\u00f1\3\2"+ + "\2\2\u0127\u00fb\3\2\2\2\u0127\u0107\3\2\2\2\u0127\u0113\3\2\2\2\u0128"+ + "N\3\2\2\2\u0129\u012b\5W,\2\u012a\u0129\3\2\2\2\u012b\u012c\3\2\2\2\u012c"+ + "\u012a\3\2\2\2\u012c\u012d\3\2\2\2\u012dP\3\2\2\2\u012e\u0130\5W,\2\u012f"+ + "\u012e\3\2\2\2\u0130\u0131\3\2\2\2\u0131\u012f\3\2\2\2\u0131\u0132\3\2"+ + "\2\2\u0132\u0133\3\2\2\2\u0133\u0137\5=\37\2\u0134\u0136\5W,\2\u0135\u0134"+ + "\3\2\2\2\u0136\u0139\3\2\2\2\u0137\u0135\3\2\2\2\u0137\u0138\3\2\2\2\u0138"+ + "\u0159\3\2\2\2\u0139\u0137\3\2\2\2\u013a\u013c\5=\37\2\u013b\u013d\5W"+ + ",\2\u013c\u013b\3\2\2\2\u013d\u013e\3\2\2\2\u013e\u013c\3\2\2\2\u013e"+ + "\u013f\3\2\2\2\u013f\u0159\3\2\2\2\u0140\u0142\5W,\2\u0141\u0140\3\2\2"+ + "\2\u0142\u0143\3\2\2\2\u0143\u0141\3\2\2\2\u0143\u0144\3\2\2\2\u0144\u014c"+ + "\3\2\2\2\u0145\u0149\5=\37\2\u0146\u0148\5W,\2\u0147\u0146\3\2\2\2\u0148"+ + "\u014b\3\2\2\2\u0149\u0147\3\2\2\2\u0149\u014a\3\2\2\2\u014a\u014d\3\2"+ + "\2\2\u014b\u0149\3\2\2\2\u014c\u0145\3\2\2\2\u014c\u014d\3\2\2\2\u014d"+ + "\u014e\3\2\2\2\u014e\u014f\5U+\2\u014f\u0159\3\2\2\2\u0150\u0152\5=\37"+ + "\2\u0151\u0153\5W,\2\u0152\u0151\3\2\2\2\u0153\u0154\3\2\2\2\u0154\u0152"+ + "\3\2\2\2\u0154\u0155\3\2\2\2\u0155\u0156\3\2\2\2\u0156\u0157\5U+\2\u0157"+ + "\u0159\3\2\2\2\u0158\u012f\3\2\2\2\u0158\u013a\3\2\2\2\u0158\u0141\3\2"+ + "\2\2\u0158\u0150\3\2\2\2\u0159R\3\2\2\2\u015a\u015d\5Y-\2\u015b\u015d"+ + "\t\t\2\2\u015c\u015a\3\2\2\2\u015c\u015b\3\2\2\2\u015d\u0163\3\2\2\2\u015e"+ + "\u0162\5Y-\2\u015f\u0162\5W,\2\u0160\u0162\7a\2\2\u0161\u015e\3\2\2\2"+ + "\u0161\u015f\3\2\2\2\u0161\u0160\3\2\2\2\u0162\u0165\3\2\2\2\u0163\u0161"+ + "\3\2\2\2\u0163\u0164\3\2\2\2\u0164T\3\2\2\2\u0165\u0163\3\2\2\2\u0166"+ + "\u0168\t\n\2\2\u0167\u0169\t\13\2\2\u0168\u0167\3\2\2\2\u0168\u0169\3"+ + "\2\2\2\u0169\u016b\3\2\2\2\u016a\u016c\5W,\2\u016b\u016a\3\2\2\2\u016c"+ + "\u016d\3\2\2\2\u016d\u016b\3\2\2\2\u016d\u016e\3\2\2\2\u016eV\3\2\2\2"+ + "\u016f\u0170\t\f\2\2\u0170X\3\2\2\2\u0171\u0172\t\r\2\2\u0172Z\3\2\2\2"+ + "\u0173\u0174\7\61\2\2\u0174\u0175\7\61\2\2\u0175\u0179\3\2\2\2\u0176\u0178"+ + "\n\b\2\2\u0177\u0176\3\2\2\2\u0178\u017b\3\2\2\2\u0179\u0177\3\2\2\2\u0179"+ + "\u017a\3\2\2\2\u017a\u017d\3\2\2\2\u017b\u0179\3\2\2\2\u017c\u017e\7\17"+ + "\2\2\u017d\u017c\3\2\2\2\u017d\u017e\3\2\2\2\u017e\u0180\3\2\2\2\u017f"+ + "\u0181\7\f\2\2\u0180\u017f\3\2\2\2\u0180\u0181\3\2\2\2\u0181\u0182\3\2"+ + "\2\2\u0182\u0183\b.\2\2\u0183\\\3\2\2\2\u0184\u0185\7\61\2\2\u0185\u0186"+ + "\7,\2\2\u0186\u018b\3\2\2\2\u0187\u018a\5]/\2\u0188\u018a\13\2\2\2\u0189"+ + "\u0187\3\2\2\2\u0189\u0188\3\2\2\2\u018a\u018d\3\2\2\2\u018b\u018c\3\2"+ + "\2\2\u018b\u0189\3\2\2\2\u018c\u018e\3\2\2\2\u018d\u018b\3\2\2\2\u018e"+ + "\u018f\7,\2\2\u018f\u0190\7\61\2\2\u0190\u0191\3\2\2\2\u0191\u0192\b/"+ + "\2\2\u0192^\3\2\2\2\u0193\u0195\t\16\2\2\u0194\u0193\3\2\2\2\u0195\u0196"+ + "\3\2\2\2\u0196\u0194\3\2\2\2\u0196\u0197\3\2\2\2\u0197\u0198\3\2\2\2\u0198"+ + "\u0199\b\60\2\2\u0199`\3\2\2\2%\2\u00e0\u00e2\u00eb\u00ed\u00f5\u00f7"+ + "\u0101\u0103\u010d\u010f\u011a\u0122\u0125\u0127\u012c\u0131\u0137\u013e"+ + "\u0143\u0149\u014c\u0154\u0158\u015c\u0161\u0163\u0168\u016d\u0179\u017d"+ + "\u0180\u0189\u018b\u0196\3\2\3\2"; public static final ATN _ATN = new ATNDeserializer().deserialize(_serializedATN.toCharArray()); static { diff --git a/x-pack/plugin/eql/src/test/java/org/elasticsearch/xpack/eql/parser/ExpressionTests.java b/x-pack/plugin/eql/src/test/java/org/elasticsearch/xpack/eql/parser/ExpressionTests.java index 6f4a33856f585..0fae824a65db2 100644 --- a/x-pack/plugin/eql/src/test/java/org/elasticsearch/xpack/eql/parser/ExpressionTests.java +++ b/x-pack/plugin/eql/src/test/java/org/elasticsearch/xpack/eql/parser/ExpressionTests.java @@ -68,19 +68,19 @@ public void testStrings() { // test for unescaped strings: """....""" assertEquals("hello\"world", unquoteString(source("\"\"\"hello\"world\"\"\""))); - assertEquals("hello\"world", unquoteString(source("\"\"\"hello\\\"world\"\"\""))); - assertEquals("\"\"hello\"\"world\"\"\"", unquoteString(source("\"\"\"\"\"hello\"\\\"world\"\"\"\"\"\""))); + assertEquals("hello\\\"world", unquoteString(source("\"\"\"hello\\\"world\"\"\""))); + assertEquals("\"\"hello\"\\\"world\"\"\"", unquoteString(source("\"\"\"\"\"hello\"\\\"world\"\"\"\"\"\""))); assertEquals("hello'world", unquoteString(source("\"\"\"hello'world\"\"\""))); assertEquals("hello'world", unquoteString(source("\"\"\"hello\'world\"\"\""))); assertEquals("hello\\'world", unquoteString(source("\"\"\"hello\\\'world\"\"\""))); assertEquals("hello\\nworld", unquoteString(source("\"\"\"hello\\nworld\"\"\""))); assertEquals("hello\\\\nworld", unquoteString(source("\"\"\"hello\\\\nworld\"\"\""))); assertEquals("hello\\\\\\nworld", unquoteString(source("\"\"\"hello\\\\\\nworld\"\"\""))); - assertEquals("hello\\\\\"world", unquoteString(source("\"\"\"hello\\\\\\\"world\"\"\""))); - assertEquals("\"\"", unquoteString(source("\"\"\"\"\\\"\"\"\""))); - assertEquals("\"\"\"", unquoteString(source("\"\"\"\\\"\"\"\"\"\""))); - assertEquals("\"\"\"", unquoteString(source("\"\"\"\"\\\"\"\"\"\""))); - assertEquals("\"\"\"", unquoteString(source("\"\"\"\"\"\\\"\"\"\""))); + assertEquals("hello\\\\\\\"world", unquoteString(source("\"\"\"hello\\\\\\\"world\"\"\""))); + assertEquals("\"\\\"", unquoteString(source("\"\"\"\"\\\"\"\"\""))); + assertEquals("\\\"\"\"", unquoteString(source("\"\"\"\\\"\"\"\"\"\""))); + assertEquals("\"\\\"\"", unquoteString(source("\"\"\"\"\\\"\"\"\"\""))); + assertEquals("\"\"\\\"", unquoteString(source("\"\"\"\"\"\\\"\"\"\""))); assertEquals("\"\"", unquoteString(source("\"\"\"\"\"\"\"\""))); assertEquals("\"\" \"\"", unquoteString(source("\"\"\"\"\" \"\"\"\"\""))); assertEquals("", unquoteString(source("\"\"\"\"\"\""))); @@ -139,10 +139,10 @@ public void testTripleDoubleQuotedUnescapedString() { assertEquals(Literal.class, eq.right().getClass()); assertEquals(expectedStrRight, ((Literal) eq.right()).value()); - // """""hello\"""world!\"""" == """"foo"\""bar""\"""" => ""hello"""world!" = "foo"""bar""" - str = " \"\"\"\"\"hello\\\"\"\"world!\\\"\"\"\" == \"\"\"\"foo\"\\\"\"bar\"\"\\\"\"\"\" "; - expectedStrLeft = "\"\"hello\"\"\"world!\""; - expectedStrRight = "\"foo\"\"\"bar\"\"\""; + // """""hello""world!"""" == """"foo"bar""""" => ""hello""world!" = "foo""bar"" + str = " \"\"\"\"\"hello\"\"world!\"\"\"\" == \"\"\"\"foo\"bar\"\"\"\"\" "; + expectedStrLeft = "\"\"hello\"\"world!\""; + expectedStrRight = "\"foo\"bar\"\""; parsed = expr(str); assertEquals(Equals.class, parsed.getClass()); eq = (Equals) parsed; @@ -151,12 +151,12 @@ public void testTripleDoubleQuotedUnescapedString() { assertEquals(Literal.class, eq.right().getClass()); assertEquals(expectedStrRight, ((Literal) eq.right()).value()); - // """""\"""hello\\"""\"""world!\\"""\"""" == """\\"""\"""foo\\"""\"\"""\\"bar""\\"""\"""" => - // """""hello\""""""world!\"""" == \""""""foo\"""""""\"bar""\"""" - str = "\"\"\"\"\"\\\"\"\"hello\\\\\"\"\"\\\"\"\"world!\\\\\"\"\"\\\"\"\"\" == " + - "\"\"\"\\\\\"\"\"\\\"\"\"foo\\\\\"\"\"\\\"\\\"\"\"\\\\\"bar\"\"\\\\\"\"\"\\\"\"\"\""; - expectedStrLeft = "\"\"\"\"\"hello\\\"\"\"\"\"\"world!\\\"\"\"\""; - expectedStrRight = "\\\"\"\"\"\"\"foo\\\"\"\"\"\"\"\"\\\"bar\"\"\\\"\"\"\""; + // """""\""hello\\""\""world!\\""""" == """\\""\""foo""\\""\"bar""\\""\"""" => + // ""\""hello\\""\""world!\\"" == \\""\""foo""\\""\"bar""\\""\" + str = " \"\"\"\"\"\\\"\"hello\\\\\"\"\\\"\"world!\\\\\"\"\"\"\" == " + + " \"\"\"\\\\\"\"\\\"\"foo\"\"\\\\\"\"\\\"bar\"\"\\\\\"\"\\\"\"\"\" "; + expectedStrLeft = "\"\"\\\"\"hello\\\\\"\"\\\"\"world!\\\\\"\""; + expectedStrRight = "\\\\\"\"\\\"\"foo\"\"\\\\\"\"\\\"bar\"\"\\\\\"\"\\\""; parsed = expr(str); assertEquals(Equals.class, parsed.getClass()); eq = (Equals) parsed; @@ -170,10 +170,10 @@ public void testTripleDoubleQuotedUnescapedString() { () -> expr("\"\"\"\"\"\"hello world!\"\"\" == \"\"\"foobar\"\"\"")); assertThat(e.getMessage(), startsWith("line 1:7: mismatched input 'hello' expecting {,")); - // """""\"hello world!"""" == """foobar""" + // """""\"hello world!"""""" == """foobar""" e = expectThrows(ParsingException.class, "Expected syntax error", - () -> expr("\"\"\"\"\"\\\"hello world!\"\"\"\" == \"\"\"foobar\"\"\"")); - assertThat(e.getMessage(), startsWith("line 1:23: mismatched input '\" == \"' expecting {,")); + () -> expr("\"\"\"\"\"\\\"hello world!\"\"\"\"\"\" == \"\"\"foobar\"\"\"")); + assertThat(e.getMessage(), startsWith("line 1:25: mismatched input '\" == \"' expecting {,")); // """""\"hello world!""\"""" == """"""foobar""" e = expectThrows(ParsingException.class, "Expected syntax error", @@ -183,7 +183,7 @@ public void testTripleDoubleQuotedUnescapedString() { // """""\"hello world!""\"""" == """""\"foobar\"\"""""" e = expectThrows(ParsingException.class, "Expected syntax error", () -> expr("\"\"\"\"\"\\\"hello world!\"\"\\\"\"\"\" == \"\"\"\"\"\\\"foobar\\\"\\\"\"\"\"\"\"")); - assertThat(e.getMessage(), startsWith("line 1:51: extraneous input '\"\"' expecting {,")); + assertEquals("line 1:52: token recognition error at: '\"'", e.getMessage()); } public void testNumbers() {