Skip to content

Commit c7eafef

Browse files
committed
Add propertyAccessOperator to TokenizerOptions
Use it to implement schema..table operator in Transact-SQL
1 parent b9f8268 commit c7eafef

File tree

3 files changed

+5
-1
lines changed

3 files changed

+5
-1
lines changed

src/languages/transactsql/transactsql.formatter.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,7 @@ export const transactsql: DialectOptions = {
260260
'::',
261261
':',
262262
],
263+
propertyAccessOperators: ['..'],
263264
// TODO: Support for money constants
264265
},
265266
formatOptions: {

src/lexer/Tokenizer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ export default class Tokenizer {
189189
]),
190190
},
191191
{ type: TokenType.ASTERISK, regex: /[*]/uy },
192-
{ type: TokenType.DOT, regex: /[.]+/uy },
192+
{ type: TokenType.DOT, regex: regex.operator(['.', ...(cfg.propertyAccessOperators ?? [])]) },
193193
]);
194194
}
195195

src/lexer/TokenizerOptions.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,9 @@ export interface TokenizerOptions {
9595
paramChars?: IdentChars;
9696
// Additional multi-character operators to support, in addition to <=, >=, <>, !=
9797
operators?: string[];
98+
// Additional operators for property access, in addition to .
99+
// Like in table.column
100+
propertyAccessOperators?: string[];
98101
// Allows custom modifications on the token array.
99102
// Called after the whole input string has been split into tokens.
100103
// The result of this will be the output of the tokenizer.

0 commit comments

Comments
 (0)