diff --git a/tests/Lexer/LexerTest.php b/tests/Lexer/LexerTest.php index abee44f3..e310c94f 100644 --- a/tests/Lexer/LexerTest.php +++ b/tests/Lexer/LexerTest.php @@ -79,6 +79,7 @@ public static function lexProvider(): array ['lexer/lexOperator'], ['lexer/lexOperatorStarIsArithmetic'], ['lexer/lexOperatorStarIsWildcard'], + ['lexer/lexEmptyCStyleComment'], ['lexer/lexString'], ['lexer/lexStringErr1'], ['lexer/lexSymbol'], diff --git a/tests/data/lexer/lexEmptyCStyleComment.in b/tests/data/lexer/lexEmptyCStyleComment.in new file mode 100644 index 00000000..b32191ce --- /dev/null +++ b/tests/data/lexer/lexEmptyCStyleComment.in @@ -0,0 +1,5 @@ +SELECT /**/ 1 +SELECT /*+*/ 1 +SELECT /***/ 1 +SELECT /** */ 1 +SELECT /* **/ 1 diff --git a/tests/data/lexer/lexEmptyCStyleComment.out b/tests/data/lexer/lexEmptyCStyleComment.out new file mode 100644 index 00000000..f970fe6a --- /dev/null +++ b/tests/data/lexer/lexEmptyCStyleComment.out @@ -0,0 +1,385 @@ +{ + "query": "SELECT /**/ 1\nSELECT /*+*/ 1\nSELECT /***/ 1\nSELECT /** */ 1\nSELECT /* **/ 1\n", + "lexer": { + "@type": "PhpMyAdmin\\SqlParser\\Lexer", + "str": "SELECT /**/ 1\nSELECT /*+*/ 1\nSELECT /***/ 1\nSELECT /** */ 1\nSELECT /* **/ 1\n", + "len": 76, + "last": 76, + "list": { + "@type": "PhpMyAdmin\\SqlParser\\TokensList", + "tokens": [ + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "SELECT", + "value": "SELECT", + "keyword": "SELECT", + "type": 1, + "flags": 3, + "position": 0 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 6 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "/", + "value": "/", + "keyword": null, + "type": 2, + "flags": 1, + "position": 7 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "*", + "value": "*", + "keyword": null, + "type": 2, + "flags": 1, + "position": 8 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "*/", + "value": "*/", + "keyword": null, + "type": 4, + "flags": 2, + "position": 9 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 11 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "1", + "value": 1, + "keyword": null, + "type": 6, + "flags": 0, + "position": 12 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "\n", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 13 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "SELECT", + "value": "SELECT", + "keyword": "SELECT", + "type": 1, + "flags": 3, + "position": 14 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 20 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "/*+*/", + "value": "/*+*/", + "keyword": null, + "type": 4, + "flags": 2, + "position": 21 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 26 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "1", + "value": 1, + "keyword": null, + "type": 6, + "flags": 0, + "position": 27 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "\n", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 28 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "SELECT", + "value": "SELECT", + "keyword": "SELECT", + "type": 1, + "flags": 3, + "position": 29 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 35 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "/", + "value": "/", + "keyword": null, + "type": 2, + "flags": 1, + "position": 36 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "*", + "value": "*", + "keyword": null, + "type": 2, + "flags": 1, + "position": 37 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "*", + "value": "*", + "keyword": null, + "type": 2, + "flags": 1, + "position": 38 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "*/", + "value": "*/", + "keyword": null, + "type": 4, + "flags": 2, + "position": 39 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 41 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "1", + "value": 1, + "keyword": null, + "type": 6, + "flags": 0, + "position": 42 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "\n", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 43 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "SELECT", + "value": "SELECT", + "keyword": "SELECT", + "type": 1, + "flags": 3, + "position": 44 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 50 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "/", + "value": "/", + "keyword": null, + "type": 2, + "flags": 1, + "position": 51 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "*", + "value": "*", + "keyword": null, + "type": 2, + "flags": 1, + "position": 52 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "*", + "value": "*", + "keyword": null, + "type": 2, + "flags": 1, + "position": 53 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 54 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "*/", + "value": "*/", + "keyword": null, + "type": 4, + "flags": 2, + "position": 55 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 57 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "1", + "value": 1, + "keyword": null, + "type": 6, + "flags": 0, + "position": 58 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "\n", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 59 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "SELECT", + "value": "SELECT", + "keyword": "SELECT", + "type": 1, + "flags": 3, + "position": 60 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 66 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "/* **/", + "value": "/* **/", + "keyword": null, + "type": 4, + "flags": 2, + "position": 67 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": " ", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 73 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "1", + "value": 1, + "keyword": null, + "type": 6, + "flags": 0, + "position": 74 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": "\n", + "value": " ", + "keyword": null, + "type": 3, + "flags": 0, + "position": 75 + }, + { + "@type": "PhpMyAdmin\\SqlParser\\Token", + "token": null, + "value": null, + "keyword": null, + "type": 9, + "flags": 0, + "position": null + } + ], + "count": 40, + "idx": 0 + }, + "delimiter": ";", + "delimiterLen": 1, + "strict": false, + "errors": [] + }, + "parser": null, + "errors": { + "lexer": [], + "parser": [] + } +} \ No newline at end of file