File tree Expand file tree Collapse file tree 4 files changed +7
-11
lines changed Expand file tree Collapse file tree 4 files changed +7
-11
lines changed Original file line number Diff line number Diff line change @@ -155,9 +155,7 @@ export const duckdb: DialectOptions = {
155155 reservedFunctionNames : functions ,
156156 nestedBlockComments : true ,
157157 extraParens : [ '[]' , '{}' ] ,
158- // Support underscore separators in numeric literals (e.g., 1_000_000)
159- numberRegex :
160- / (?: 0 x [ 0 - 9 a - f A - F _ ] + | 0 b [ 0 1 _ ] + | (?: - \s * ) ? (?: [ 0 - 9 _ ] * \. [ 0 - 9 _ ] + | [ 0 - 9 _ ] + (?: \. [ 0 - 9 _ ] * ) ? ) (?: [ e E ] [ - + ] ? [ 0 - 9 _ ] + (?: \. [ 0 - 9 _ ] + ) ? ) ? ) (? ! [ \w \p{ Alphabetic} ] ) / uy,
158+ underscoresInNumbers : true ,
161159 stringTypes : [
162160 '$$' ,
163161 "''-qq" ,
Original file line number Diff line number Diff line change @@ -277,9 +277,7 @@ export const postgresql: DialectOptions = {
277277 reservedFunctionNames : functions ,
278278 nestedBlockComments : true ,
279279 extraParens : [ '[]' ] ,
280- // Support underscore separators in numeric literals (e.g., 1_000_000)
281- numberRegex :
282- / (?: 0 x [ 0 - 9 a - f A - F _ ] + | 0 b [ 0 1 _ ] + | (?: - \s * ) ? (?: [ 0 - 9 _ ] * \. [ 0 - 9 _ ] + | [ 0 - 9 _ ] + (?: \. [ 0 - 9 _ ] * ) ? ) (?: [ e E ] [ - + ] ? [ 0 - 9 _ ] + (?: \. [ 0 - 9 _ ] + ) ? ) ? ) (? ! [ \w \p{ Alphabetic} ] ) / uy,
280+ underscoresInNumbers : true ,
283281 stringTypes : [
284282 '$$' ,
285283 { quote : "''-qq" , prefixes : [ 'U&' ] } ,
Original file line number Diff line number Diff line change @@ -50,9 +50,9 @@ export default class Tokenizer {
5050 } ,
5151 {
5252 type : TokenType . NUMBER ,
53- regex :
54- cfg . numberRegex ??
55- / (?: 0 x [ 0 - 9 a - f A - F ] + | 0 b [ 0 1 ] + | (?: - \s * ) ? (?: [ 0 - 9 ] * \. [ 0 - 9 ] + | [ 0 - 9 ] + (?: \. [ 0 - 9 ] * ) ? ) (?: [ e E ] [ - + ] ? [ 0 - 9 ] + (?: \. [ 0 - 9 ] + ) ? ) ? ) (? ! [ \w \p{ Alphabetic} ] ) / uy,
53+ regex : cfg . underscoresInNumbers
54+ ? / (?: 0 x [ 0 - 9 a - f A - F _ ] + | 0 b [ 0 1 _ ] + | (?: - \s * ) ? (?: [ 0 - 9 _ ] * \. [ 0 - 9 _ ] + | [ 0 - 9 _ ] + (?: \. [ 0 - 9 _ ] * ) ? ) (?: [ e E ] [ - + ] ? [ 0 - 9 _ ] + (?: \. [ 0 - 9 _ ] + ) ? ) ? ) (? ! [ \w \p { Alphabetic } ] ) / uy
55+ : / (?: 0 x [ 0 - 9 a - f A - F ] + | 0 b [ 0 1 ] + | (?: - \s * ) ? (?: [ 0 - 9 ] * \. [ 0 - 9 ] + | [ 0 - 9 ] + (?: \. [ 0 - 9 ] * ) ? ) (?: [ e E ] [ - + ] ? [ 0 - 9 ] + (?: \. [ 0 - 9 ] + ) ? ) ? ) (? ! [ \w \p{ Alphabetic} ] ) / uy,
5656 } ,
5757 // RESERVED_PHRASE is matched before all other keyword tokens
5858 // to e.g. prioritize matching "TIMESTAMP WITH TIME ZONE" phrase over "WITH" clause.
Original file line number Diff line number Diff line change @@ -100,8 +100,8 @@ export interface TokenizerOptions {
100100 propertyAccessOperators ?: string [ ] ;
101101 // Enables PostgreSQL-specific OPERATOR(...) syntax
102102 operatorKeyword ?: boolean ;
103- // Custom regex pattern for number tokens (defaults to standard SQL number pattern )
104- numberRegex ?: RegExp ;
103+ // True to support underscores in number literals (e.g., 1_000_000 )
104+ underscoresInNumbers ?: boolean ;
105105 // Allows custom modifications on the token array.
106106 // Called after the whole input string has been split into tokens.
107107 // The result of this will be the output of the tokenizer.
You can’t perform that action at this time.
0 commit comments