All files / src/tokenizer keyword-table.ts

100% Statements 1/1
100% Branches 0/0
100% Functions 0/0
100% Lines 1/1

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32                                        24x                      
import { TokenKind } from './token-kind.js';
 
/**
 * Textual operator names recognised by the tokenizer.
 *
 * This mirrors Spring's `Tokenizer#ALTERNATIVE_OPERATOR_NAMES`, which is
 * matched after folding the scanned identifier to upper case, so `div`, `Div`
 * and `DIV` are all accepted.
 *
 * Two categories of word are deliberately absent:
 *
 *  - `and`, `or`, `matches`, `between`, `instanceof`, `new`: Spring leaves these
 *    as IDENTIFIER tokens and resolves them in `InternalSpelExpressionParser`
 *    with `equalsIgnoreCase`. Keeping them as identifiers here is what allows
 *    them to double as ordinary property and method names, so `'abc'.matches(…)`
 *    and a field literally named `and` both continue to work.
 *  - `true`, `false`, `null`: likewise resolved by the parser.
 *
 * Keys are ASCII upper case; callers fold the identifier before lookup.
 */
export const OPERATOR_KEYWORDS: ReadonlyMap<string, TokenKind> = new Map<string, TokenKind>([
  ['DIV', TokenKind.DIV],
  ['MOD', TokenKind.MOD],
  ['EQ', TokenKind.EQ],
  ['NE', TokenKind.NE],
  ['LT', TokenKind.LT],
  ['LE', TokenKind.LE],
  ['GT', TokenKind.GT],
  ['GE', TokenKind.GE],
  ['NOT', TokenKind.NOT],
]);