123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295 |
- /*---------------------------------------------------------------------------------------------
- * Copyright (c) Microsoft Corporation. All rights reserved.
- * Licensed under the MIT License. See License.txt in the project root for license information.
- *--------------------------------------------------------------------------------------------*/
- 'use strict';
- import { testTokenization } from './testRunner';
- testTokenization('redis', [
- // Numbers
- [{
- line: '123',
- tokens: [
- { startIndex: 0, type: 'number.redis' }
- ]
- }],
- [{
- line: '-123',
- tokens: [
- { startIndex: 0, type: 'operator.redis' },
- { startIndex: 1, type: 'number.redis' }
- ]
- }],
- [{
- line: '0xaBc123',
- tokens: [
- { startIndex: 0, type: 'number.redis' }
- ]
- }],
- [{
- line: '0XaBc123',
- tokens: [
- { startIndex: 0, type: 'number.redis' }
- ]
- }],
- [{
- line: '0x',
- tokens: [
- { startIndex: 0, type: 'number.redis' }
- ]
- }],
- [{
- line: '0x0',
- tokens: [
- { startIndex: 0, type: 'number.redis' }
- ]
- }],
- [{
- line: '0xAB_CD',
- tokens: [
- { startIndex: 0, type: 'number.redis' },
- { startIndex: 4, type: 'identifier.redis' }
- ]
- }],
- [{
- line: '$',
- tokens: [
- { startIndex: 0, type: 'number.redis' }
- ]
- }],
- [{
- line: '$-123',
- tokens: [
- { startIndex: 0, type: 'number.redis' }
- ]
- }],
- [{
- line: '$-+-123',
- tokens: [
- { startIndex: 0, type: 'number.redis' }
- ]
- }],
- [{
- line: '$123.5678',
- tokens: [
- { startIndex: 0, type: 'number.redis' }
- ]
- }],
- [{
- line: '$0.99',
- tokens: [
- { startIndex: 0, type: 'number.redis' }
- ]
- }],
- [{
- line: '$.99',
- tokens: [
- { startIndex: 0, type: 'number.redis' }
- ]
- }],
- [{
- line: '$99.',
- tokens: [
- { startIndex: 0, type: 'number.redis' }
- ]
- }],
- [{
- line: '$0.',
- tokens: [
- { startIndex: 0, type: 'number.redis' }
- ]
- }],
- [{
- line: '$.0',
- tokens: [
- { startIndex: 0, type: 'number.redis' }
- ]
- }],
- [{
- line: '.',
- tokens: [
- { startIndex: 0, type: 'delimiter.redis' }
- ]
- }],
- [{
- line: '123',
- tokens: [
- { startIndex: 0, type: 'number.redis' }
- ]
- }],
- [{
- line: '123.5678',
- tokens: [
- { startIndex: 0, type: 'number.redis' }
- ]
- }],
- [{
- line: '0.99',
- tokens: [
- { startIndex: 0, type: 'number.redis' }
- ]
- }],
- [{
- line: '.99',
- tokens: [
- { startIndex: 0, type: 'number.redis' }
- ]
- }],
- [{
- line: '99.',
- tokens: [
- { startIndex: 0, type: 'number.redis' }
- ]
- }],
- [{
- line: '0.',
- tokens: [
- { startIndex: 0, type: 'number.redis' }
- ]
- }],
- [{
- line: '.0',
- tokens: [
- { startIndex: 0, type: 'number.redis' }
- ]
- }],
- [{
- line: '1E-2',
- tokens: [
- { startIndex: 0, type: 'number.redis' }
- ]
- }],
- [{
- line: '1E+2',
- tokens: [
- { startIndex: 0, type: 'number.redis' }
- ]
- }],
- [{
- line: '1E2',
- tokens: [
- { startIndex: 0, type: 'number.redis' }
- ]
- }],
- [{
- line: '0.1E2',
- tokens: [
- { startIndex: 0, type: 'number.redis' }
- ]
- }],
- [{
- line: '1.E2',
- tokens: [
- { startIndex: 0, type: 'number.redis' }
- ]
- }],
- [{
- line: '.1E2',
- tokens: [
- { startIndex: 0, type: 'number.redis' }
- ]
- }],
- // Strings
- [{
- line: 'SET key1 "Hello"',
- tokens: [
- { startIndex: 0, type: 'keyword.redis' },
- { startIndex: 3, type: 'white.redis' },
- { startIndex: 4, type: 'identifier.redis' },
- { startIndex: 8, type: 'white.redis' },
- { startIndex: 9, type: 'string.double.redis' },
- ]
- }],
- [{
- line: 'SET key1 \'Hello\'',
- tokens: [
- { startIndex: 0, type: 'keyword.redis' },
- { startIndex: 3, type: 'white.redis' },
- { startIndex: 4, type: 'identifier.redis' },
- { startIndex: 8, type: 'white.redis' },
- { startIndex: 9, type: 'string.redis' },
- ]
- }],
- // Commands
- [{
- line: 'DEL key1 key2 key3',
- tokens: [
- { startIndex: 0, type: 'keyword.redis' },
- { startIndex: 3, type: 'white.redis' },
- { startIndex: 4, type: 'identifier.redis' },
- { startIndex: 8, type: 'white.redis' },
- { startIndex: 9, type: 'identifier.redis' },
- { startIndex: 13, type: 'white.redis' },
- { startIndex: 14, type: 'identifier.redis' },
- ]
- }],
- [{
- line: 'GEOADD Sicily 13.361389 38.115556 "Palermo" 15.087269 37.502669 "Catania"',
- tokens: [
- { startIndex: 0, type: 'keyword.redis' },
- { startIndex: 6, type: 'white.redis' },
- { startIndex: 7, type: 'identifier.redis' },
- { startIndex: 13, type: 'white.redis' },
- { startIndex: 14, type: 'number.redis' },
- { startIndex: 23, type: 'white.redis' },
- { startIndex: 24, type: 'number.redis' },
- { startIndex: 33, type: 'white.redis' },
- { startIndex: 34, type: 'string.double.redis' },
- { startIndex: 43, type: 'white.redis' },
- { startIndex: 44, type: 'number.redis' },
- { startIndex: 53, type: 'white.redis' },
- { startIndex: 54, type: 'number.redis' },
- { startIndex: 63, type: 'white.redis' },
- { startIndex: 64, type: 'string.double.redis' },
- ]
- }],
- [{
- line: 'HGET myhash field1',
- tokens: [
- { startIndex: 0, type: 'keyword.redis' },
- { startIndex: 4, type: 'white.redis' },
- { startIndex: 5, type: 'identifier.redis' },
- { startIndex: 11, type: 'white.redis' },
- { startIndex: 12, type: 'identifier.redis' }
- ]
- }],
- ]);
|