@witchcraft/expressit 0.2.1 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (119) hide show
  1. package/README.md +6 -4
  2. package/dist/Lexer.d.ts +102 -99
  3. package/dist/Lexer.d.ts.map +1 -1
  4. package/dist/Lexer.js +211 -557
  5. package/dist/Parser.d.ts +27 -27
  6. package/dist/Parser.d.ts.map +1 -1
  7. package/dist/Parser.js +5 -2
  8. package/dist/ast/builders/condition.d.ts +1 -1
  9. package/dist/ast/builders/condition.d.ts.map +1 -1
  10. package/dist/ast/builders/condition.js +1 -0
  11. package/dist/ast/builders/delim.d.ts +3 -3
  12. package/dist/ast/builders/delim.d.ts.map +1 -1
  13. package/dist/ast/builders/error.d.ts +2 -2
  14. package/dist/ast/builders/error.d.ts.map +1 -1
  15. package/dist/ast/builders/expression.d.ts +2 -2
  16. package/dist/ast/builders/expression.d.ts.map +1 -1
  17. package/dist/ast/builders/expression.js +2 -6
  18. package/dist/ast/builders/group.d.ts +1 -1
  19. package/dist/ast/builders/group.d.ts.map +1 -1
  20. package/dist/ast/builders/group.js +1 -3
  21. package/dist/ast/builders/pos.d.ts +2 -2
  22. package/dist/ast/builders/pos.d.ts.map +1 -1
  23. package/dist/ast/builders/token.d.ts +2 -2
  24. package/dist/ast/builders/token.d.ts.map +1 -1
  25. package/dist/ast/builders/type.d.ts +2 -2
  26. package/dist/ast/builders/type.d.ts.map +1 -1
  27. package/dist/ast/builders/variable.d.ts +3 -3
  28. package/dist/ast/builders/variable.d.ts.map +1 -1
  29. package/dist/ast/createConditionNode.d.ts +1 -1
  30. package/dist/ast/createConditionNode.d.ts.map +1 -1
  31. package/dist/ast/createGroupNode.d.ts +1 -1
  32. package/dist/ast/createGroupNode.d.ts.map +1 -1
  33. package/dist/ast/createToken.d.ts +2 -2
  34. package/dist/ast/createToken.d.ts.map +1 -1
  35. package/dist/ast/createToken.js +2 -2
  36. package/dist/ast/error.d.ts +2 -2
  37. package/dist/ast/error.d.ts.map +1 -1
  38. package/dist/ast/error.js +1 -0
  39. package/dist/ast/handlers.d.ts +23 -23
  40. package/dist/ast/handlers.d.ts.map +1 -1
  41. package/dist/ast/handlers.js +4 -4
  42. package/dist/examples/ParserWithSqlSupport.d.ts +62 -0
  43. package/dist/examples/ParserWithSqlSupport.d.ts.map +1 -0
  44. package/dist/examples/ParserWithSqlSupport.js +271 -0
  45. package/dist/examples/{shortcutContextParser.d.ts → ShortcutContextParser.d.ts} +5 -5
  46. package/dist/examples/ShortcutContextParser.d.ts.map +1 -0
  47. package/dist/examples/{shortcutContextParser.js → ShortcutContextParser.js} +2 -2
  48. package/dist/examples/index.d.ts +2 -1
  49. package/dist/examples/index.d.ts.map +1 -1
  50. package/dist/examples/index.js +3 -1
  51. package/dist/index.js +2 -2
  52. package/dist/internal/ExpressitError.d.ts +2 -2
  53. package/dist/internal/ExpressitError.d.ts.map +1 -1
  54. package/dist/internal/ExpressitError.js +2 -1
  55. package/dist/internal/checkParserOpts.d.ts +1 -1
  56. package/dist/internal/checkParserOpts.d.ts.map +1 -1
  57. package/dist/internal/checkParserOpts.js +11 -11
  58. package/dist/internal/parseParserOptions.d.ts +1 -1
  59. package/dist/internal/parseParserOptions.d.ts.map +1 -1
  60. package/dist/package.json.js +4 -195
  61. package/dist/types/ast.d.ts +60 -58
  62. package/dist/types/ast.d.ts.map +1 -1
  63. package/dist/types/ast.js +26 -27
  64. package/dist/types/autocomplete.d.ts +23 -21
  65. package/dist/types/autocomplete.d.ts.map +1 -1
  66. package/dist/types/autocomplete.js +24 -21
  67. package/dist/types/errors.d.ts +12 -10
  68. package/dist/types/errors.d.ts.map +1 -1
  69. package/dist/types/errors.js +8 -7
  70. package/dist/types/index.js +2 -2
  71. package/dist/types/parser.d.ts +9 -9
  72. package/dist/types/parser.d.ts.map +1 -1
  73. package/dist/utils/getCursorInfo.js +3 -1
  74. package/dist/utils/getOppositeDelimiter.d.ts +2 -2
  75. package/dist/utils/getOppositeDelimiter.d.ts.map +1 -1
  76. package/dist/utils/isDelimiter.d.ts +2 -2
  77. package/dist/utils/isDelimiter.d.ts.map +1 -1
  78. package/dist/utils/isParen.d.ts +2 -2
  79. package/dist/utils/isParen.d.ts.map +1 -1
  80. package/dist/utils/isQuote.d.ts +2 -2
  81. package/dist/utils/isQuote.d.ts.map +1 -1
  82. package/package.json +29 -27
  83. package/src/Lexer.ts +103 -92
  84. package/src/Parser.ts +70 -64
  85. package/src/ast/builders/condition.ts +3 -3
  86. package/src/ast/builders/delim.ts +5 -5
  87. package/src/ast/builders/error.ts +3 -3
  88. package/src/ast/builders/expression.ts +4 -8
  89. package/src/ast/builders/group.ts +2 -4
  90. package/src/ast/builders/pos.ts +3 -3
  91. package/src/ast/builders/token.ts +2 -2
  92. package/src/ast/builders/type.ts +2 -2
  93. package/src/ast/builders/variable.ts +5 -5
  94. package/src/ast/createConditionNode.ts +2 -2
  95. package/src/ast/createGroupNode.ts +4 -4
  96. package/src/ast/createToken.ts +6 -6
  97. package/src/ast/error.ts +2 -2
  98. package/src/ast/handlers.ts +23 -23
  99. package/src/examples/ParserWithSqlSupport.ts +371 -0
  100. package/src/examples/{shortcutContextParser.ts → ShortcutContextParser.ts} +14 -14
  101. package/src/examples/index.ts +2 -1
  102. package/src/internal/ExpressitError.ts +4 -4
  103. package/src/internal/checkParserOpts.ts +14 -14
  104. package/src/internal/parseParserOptions.ts +2 -2
  105. package/src/types/ast.ts +101 -96
  106. package/src/types/autocomplete.ts +26 -22
  107. package/src/types/errors.ts +18 -13
  108. package/src/types/parser.ts +9 -9
  109. package/src/utils/getCursorInfo.ts +1 -1
  110. package/src/utils/getOppositeDelimiter.ts +2 -2
  111. package/src/utils/getSurroundingErrors.ts +4 -4
  112. package/src/utils/isDelimiter.ts +3 -3
  113. package/src/utils/isParen.ts +2 -2
  114. package/src/utils/isQuote.ts +2 -2
  115. package/dist/examples/shortcutContextParser.d.ts.map +0 -1
  116. package/dist/global.d.js +0 -1
  117. package/dist/package.js +0 -7
  118. package/src/global.d.ts +0 -4
  119. package/src/package.js +0 -11
package/src/Lexer.ts CHANGED
@@ -1,3 +1,5 @@
1
+ import type { EnumLike } from "@alanscodelog/utils"
2
+ import { enumFromArray } from "@alanscodelog/utils/enumFromArray.js"
1
3
  import { isBlank } from "@alanscodelog/utils/isBlank.js"
2
4
  import { pushIfNotIn } from "@alanscodelog/utils/pushIfNotIn.js"
3
5
 
@@ -7,63 +9,68 @@ import type { FullParserOptions } from "./types/index.js"
7
9
 
8
10
  const regexFlags = /^[a-zA-Z]+/
9
11
 
10
- enum MODE {
11
- MAIN = "MAIN",
12
- MAYBE_QUOTE_ERROR = "MAYBE_QUOTE_ERROR",
13
- NOT_SINGLE = "NOT_SINGLE",
14
- NOT_DOUBLE = "NOT_DOUBLE",
15
- NOT_BACKTICK = "NOT_BACKTICK",
16
- NOT_REGEX = "NOT_REGEX",
17
- REGEX_END = "REGEX_END",
18
- BRACKET_MAIN = "BRACKET_MAIN",
19
- BRACKET_MAYBE_QUOTE_ERROR = "BRACKET_MAYBE_QUOTE_ERROR",
20
- BRACKET_NOT_SINGLE = "BRACKET_NOT_SINGLE",
21
- BRACKET_NOT_DOUBLE = "BRACKET_NOT_DOUBLE",
22
- BRACKET_NOT_BACKTICK = "BRACKET_NOT_BACKTICK",
23
-
24
- }
12
+ const MODE = enumFromArray([
13
+ "MAIN",
14
+ "MAYBE_QUOTE_ERROR",
15
+ "NOT_SINGLE",
16
+ "NOT_DOUBLE",
17
+ "NOT_BACKTICK",
18
+ "NOT_REGEX",
19
+ "REGEX_END",
20
+ "BRACKET_MAIN",
21
+ "BRACKET_MAYBE_QUOTE_ERROR",
22
+ "BRACKET_NOT_SINGLE",
23
+ "BRACKET_NOT_DOUBLE",
24
+ "BRACKET_NOT_BACKTICK",
25
+ "BRACKET_NOT_REGEX",
26
+ "BRACKET_REGEX_END",
27
+ ])
28
+
25
29
  const BRACKET_PREFIX = "BRACKET"
26
30
 
31
+ export const $T = enumFromArray([
32
+ "_",
33
+ "VALUE_UNQUOTED",
34
+ "VALUE_REGEX",
35
+ "VALUE_NOT_SINGLE",
36
+ "VALUE_NOT_DOUBLE",
37
+ "VALUE_NOT_BACKTICK",
38
+ "SYM_OR",
39
+ "SYM_AND",
40
+ "SYM_NOT",
41
+ "WORD_OR",
42
+ "WORD_AND",
43
+ "WORD_NOT",
44
+ "REGEX_START",
45
+ "REGEX_END",
46
+ "EXP_PROP_OP",
47
+ "CUSTOM_PROP_OP",
48
+ "PAREN_L",
49
+ "PAREN_R",
50
+ "BRACKET_L",
51
+ "BRACKET_R",
52
+ "QUOTE_SINGLE",
53
+ "QUOTE_DOUBLE",
54
+ "QUOTE_BACKTICK",
55
+ ])
56
+
27
57
  // eslint-disable-next-line @typescript-eslint/naming-convention
28
- export enum $T {
29
- _ = "_", // whitespace,
30
- VALUE_UNQUOTED = "VALUE_UNQUOTED",
31
- VALUE_REGEX = "VALUE_REGEX",
32
- VALUE_NOT_SINGLE = "VALUE_NOT_SINGLE",
33
- VALUE_NOT_DOUBLE = "VALUE_NOT_DOUBLE",
34
- VALUE_NOT_BACKTICK = "VALUE_NOT_BACKTICK",
35
- SYM_OR = "SYM_OR",
36
- SYM_AND = "SYM_AND",
37
- SYM_NOT = "SYM_NOT",
38
- WORD_OR = "WORD_OR",
39
- WORD_AND = "WORD_AND",
40
- WORD_NOT = "WORD_NOT",
41
- REGEX_START = "REGEX_START",
42
- REGEX_END = "REGEX_END",
43
- EXP_PROP_OP = "EXP_PROP_OP",
44
- CUSTOM_PROP_OP = "CUSTOM_PROP_OP",
45
- PAREN_L = "PAREN_L",
46
- PAREN_R = "PAREN_R",
47
- BRACKET_L = "BRACKET_L",
48
- BRACKET_R = "BRACKET_R",
49
- QUOTE_SINGLE = "QUOTE_SINGLE",
50
- QUOTE_DOUBLE = "QUOTE_DOUBLE",
51
- QUOTE_BACKTICK = "QUOTE_BACKTICK",
52
- }
58
+ export type $TType = EnumLike<typeof $T>
53
59
 
60
+ export const $C = enumFromArray([
61
+ "ANY",
62
+ "QUOTE_ANY",
63
+ "REGEX_ANY",
64
+ "VALUE_FOR_SINGLE",
65
+ "VALUE_FOR_DOUBLE",
66
+ "VALUE_FOR_BACKTICK",
67
+ "OPERATOR_OR",
68
+ "OPERATOR_AND",
69
+ "OPERATOR_NOT",
70
+ "VALUE",
71
+ ])
54
72
  // eslint-disable-next-line @typescript-eslint/naming-convention
55
- export enum $C {
56
- ANY = "ANY",
57
- QUOTE_ANY = "QUOTE_ANY",
58
- REGEX_ANY = "REGEX_ANY",
59
- VALUE_FOR_SINGLE = "VALUE_FOR_SINGLE",
60
- VALUE_FOR_DOUBLE = "VALUE_FOR_DOUBLE",
61
- VALUE_FOR_BACKTICK = "VALUE_FOR_BACKTICK",
62
- OPERATOR_OR = "OPERATOR_OR",
63
- OPERATOR_AND = "OPERATOR_AND",
64
- OPERATOR_NOT = "OPERATOR_NOT",
65
- VALUE = "VALUE",
66
- }
73
+ export type $CType = EnumLike<typeof $C>
67
74
 
68
75
 
69
76
  type SymbolInfo = {
@@ -80,40 +87,42 @@ type SymbolInfo = {
80
87
 
81
88
  type TokenMatchFunc = (c: string, input: string, start: number, mode: string) => string | boolean
82
89
 
83
- interface BaseTokenType<T extends $T | $C> {
90
+ interface LexerBaseToken<T extends $TType | $CType> {
84
91
  type: T
85
92
  skip?: boolean
86
93
  }
87
- export interface RealTokenType<
88
- T extends $T = $T,
94
+
95
+ export interface LexerRealToken<
96
+ T extends $TType = $TType,
89
97
  TPush extends string | undefined = undefined,
90
98
  // TCategories extends $C[] | undefined = undefined,
91
- > extends BaseTokenType<T> {
99
+ > extends LexerBaseToken<T> {
92
100
  matches: TokenMatchFunc
93
101
  push?: TPush | ((mode: string, tokens: Token[]) => TPush)
94
102
  // categories?: TCategories
95
- longerAlt?: $T
103
+ longerAlt?: $TType
96
104
  skip?: boolean
97
105
  }
98
- export interface TokenCategoryType<
99
- TC extends $C,
100
- TTokens extends RealTokenType<$T, any>[] = RealTokenType<$T, any>[],
101
- > extends BaseTokenType<TC> {
106
+
107
+ export interface LexerCategoryToken<
108
+ TC extends $CType,
109
+ TTokens extends LexerRealToken<$TType, any>[] = LexerRealToken<$TType, any>[],
110
+ > extends LexerBaseToken<TC> {
102
111
  isCategory: true
103
- entries: Partial<{[ key in TTokens[number]["type"]]: TTokens[number] }>
112
+ entries: Partial<Record<TTokens[number]["type"], TTokens[number]>>
104
113
  // entries: Partial<Record<TTokens[number]["type"], TTokens[number]>>
105
114
  }
106
115
 
107
- export type TokenType<TC extends $C | $T> = TC extends $T
108
- ? RealTokenType<TC, any>
109
- : TC extends $C
110
- ? TokenCategoryType<TC>
116
+ export type LexerToken<TC extends $CType | $TType> = TC extends $TType
117
+ ? LexerRealToken<TC, any>
118
+ : TC extends $CType
119
+ ? LexerCategoryToken<TC>
111
120
  : never
112
121
 
113
- function createTokenCategoryType<T extends $C, TTokens extends RealTokenType<$T, any>>(
122
+ function createLexerCategoryToken<T extends $CType, TTokens extends LexerRealToken<$TType, any>>(
114
123
  type: T,
115
124
  entries: (TTokens | undefined)[],
116
- ): TokenCategoryType<T, TTokens[]> {
125
+ ): LexerCategoryToken<T, TTokens[]> {
117
126
  return {
118
127
  type,
119
128
  isCategory: true,
@@ -125,12 +134,12 @@ function createTokenCategoryType<T extends $C, TTokens extends RealTokenType<$T,
125
134
  }
126
135
 
127
136
  function createTokenType<
128
- T extends $T,
137
+ T extends $TType,
129
138
  TPush extends string | undefined = undefined,
130
139
  >(
131
140
  type: T,
132
- opts: Omit<RealTokenType<T, TPush>, "type">,
133
- ): RealTokenType<T, TPush > {
141
+ opts: Omit<LexerRealToken<T, TPush>, "type">,
142
+ ): LexerRealToken<T, TPush > {
134
143
  return {
135
144
  type,
136
145
  ...opts,
@@ -164,7 +173,7 @@ function matchSymbol(symbols: string[]): TokenMatchFunc {
164
173
  }
165
174
  }
166
175
 
167
- export interface Token<T extends $T | $C = $T | $C> {
176
+ export interface Token<T extends $TType | $CType = $TType | $CType> {
168
177
  type: T
169
178
  value: string
170
179
  startOffset: number
@@ -175,16 +184,16 @@ export interface Token<T extends $T | $C = $T | $C> {
175
184
  export class Lexer {
176
185
  symbols: SymbolInfo
177
186
 
178
- $: {[key in $T]: RealTokenType<key, any> }
187
+ $: {[key in $TType]: LexerRealToken<key, any> }
179
188
 
180
189
  $categories: ReturnType<Lexer["createTokens"]>["$categories"]
181
190
 
182
- branches: {[key in keyof typeof MODE]?: TokenType<$T>[] }
191
+ branches: {[key in keyof typeof MODE]?: LexerToken<$TType>[] }
183
192
 
184
- opts: FullParserOptions<{}>
193
+ opts: FullParserOptions<any>
185
194
 
186
195
  constructor(
187
- opts: Partial<FullParserOptions<{}>> = {},
196
+ opts: Partial<FullParserOptions<any>> = {},
188
197
  ) {
189
198
  this.opts = parseParserOptions(opts)
190
199
  checkParserOpts(this.opts)
@@ -332,6 +341,7 @@ export class Lexer {
332
341
  previous?.type === $T.VALUE_NOT_SINGLE
333
342
  /* Similarly, if the previous token was an unquoted value, we have a quote error.*/
334
343
  || previous?.type === $T.VALUE_UNQUOTED) {
344
+ if (mode.startsWith(BRACKET_PREFIX)) return MODE.BRACKET_MAIN
335
345
  return MODE.MAIN
336
346
  }
337
347
  switch (mode) {
@@ -369,6 +379,7 @@ export class Lexer {
369
379
  push: (mode, tokens) => {
370
380
  const previous = tokens[tokens.length - 2]
371
381
  if (previous?.type === $T.VALUE_NOT_BACKTICK || previous?.type === $T.VALUE_UNQUOTED) {
382
+ if (mode.startsWith(BRACKET_PREFIX)) return MODE.BRACKET_MAIN
372
383
  return MODE.MAIN
373
384
  }
374
385
  switch (mode) {
@@ -507,7 +518,7 @@ export class Lexer {
507
518
  }),
508
519
  }
509
520
  const $categories = {
510
- [$C.ANY]: createTokenCategoryType($C.ANY, [
521
+ [$C.ANY]: createLexerCategoryToken($C.ANY, [
511
522
  $[$T.REGEX_START],
512
523
  $[$T.REGEX_END],
513
524
  $[$T.QUOTE_SINGLE],
@@ -530,39 +541,39 @@ export class Lexer {
530
541
  $[$T.BRACKET_L],
531
542
  $[$T.BRACKET_R],
532
543
  ] as const),
533
- [$C.VALUE]: createTokenCategoryType($C.VALUE, [
544
+ [$C.VALUE]: createLexerCategoryToken($C.VALUE, [
534
545
  $[$T.VALUE_UNQUOTED],
535
546
  $[$T.VALUE_NOT_SINGLE],
536
547
  $[$T.VALUE_NOT_DOUBLE],
537
548
  $[$T.VALUE_NOT_BACKTICK],
538
549
  ] as const),
539
- [$C.VALUE_FOR_SINGLE]: createTokenCategoryType($C.VALUE_FOR_SINGLE, [
550
+ [$C.VALUE_FOR_SINGLE]: createLexerCategoryToken($C.VALUE_FOR_SINGLE, [
540
551
  $[$T.VALUE_NOT_SINGLE],
541
552
  ] as const),
542
- [$C.VALUE_FOR_DOUBLE]: createTokenCategoryType($C.VALUE_FOR_DOUBLE, [
553
+ [$C.VALUE_FOR_DOUBLE]: createLexerCategoryToken($C.VALUE_FOR_DOUBLE, [
543
554
  $[$T.VALUE_NOT_DOUBLE],
544
555
  ] as const),
545
- [$C.VALUE_FOR_BACKTICK]: createTokenCategoryType($C.VALUE_FOR_BACKTICK, [
556
+ [$C.VALUE_FOR_BACKTICK]: createLexerCategoryToken($C.VALUE_FOR_BACKTICK, [
546
557
  $[$T.VALUE_NOT_BACKTICK],
547
558
  ] as const),
548
- [$C.REGEX_ANY]: createTokenCategoryType($C.REGEX_ANY, [
559
+ [$C.REGEX_ANY]: createLexerCategoryToken($C.REGEX_ANY, [
549
560
  $[$T.REGEX_START],
550
561
  $[$T.REGEX_END],
551
562
  ] as const),
552
- [$C.QUOTE_ANY]: createTokenCategoryType($C.QUOTE_ANY, [
563
+ [$C.QUOTE_ANY]: createLexerCategoryToken($C.QUOTE_ANY, [
553
564
  $[$T.QUOTE_SINGLE],
554
565
  $[$T.QUOTE_DOUBLE],
555
566
  $[$T.QUOTE_BACKTICK],
556
567
  ] as const),
557
- [$C.OPERATOR_OR]: createTokenCategoryType($C.OPERATOR_OR, [
568
+ [$C.OPERATOR_OR]: createLexerCategoryToken($C.OPERATOR_OR, [
558
569
  $[$T.SYM_OR],
559
570
  $[$T.WORD_OR],
560
571
  ] as const),
561
- [$C.OPERATOR_AND]: createTokenCategoryType($C.OPERATOR_AND, [
572
+ [$C.OPERATOR_AND]: createLexerCategoryToken($C.OPERATOR_AND, [
562
573
  $[$T.SYM_AND],
563
574
  $[$T.WORD_AND],
564
575
  ] as const),
565
- [$C.OPERATOR_NOT]: createTokenCategoryType($C.OPERATOR_NOT, [
576
+ [$C.OPERATOR_NOT]: createLexerCategoryToken($C.OPERATOR_NOT, [
566
577
  $[$T.SYM_NOT],
567
578
  $[$T.WORD_NOT],
568
579
  ] as const),
@@ -570,7 +581,7 @@ export class Lexer {
570
581
  return { $, $categories }
571
582
  }
572
583
 
573
- createModeBranches(): {[key in keyof typeof MODE]?: TokenType<$T>[] } {
584
+ createModeBranches(): {[key in keyof typeof MODE]?: LexerToken<$TType>[] } {
574
585
  const opts = this.opts
575
586
  const $ = this.$
576
587
  const quotes = [
@@ -650,20 +661,19 @@ export class Lexer {
650
661
  }
651
662
 
652
663
 
653
- tokenize(input: string): Token<$T>[] {
664
+ tokenize(input: string): Token<$TType>[] {
654
665
  const branches = this.createModeBranches()
655
- const tokens: Token<$T>[] = []
666
+ const tokens: Token<$TType>[] = []
656
667
  let mode = MODE.MAIN
657
668
  let index = 0
658
669
  let c = input[index]
659
- let branch = branches[mode] as any as TokenType<$T>[]
670
+ let branch = branches[mode] as any as LexerToken<$TType>[]
660
671
  while (index < input.length) {
661
672
  for (const t of branch) {
662
673
  let match = t.matches(c, input, index, mode)
663
674
  if (match) {
664
675
  let matchLength = match === true ? 1 : (match as string).length
665
676
  let type = t.type
666
-
667
677
  if (t.longerAlt) {
668
678
  const longerMatch = this.$[t.longerAlt].matches(c, input, index, mode)
669
679
  const longerMatchLength = longerMatch === true ? 1 : (longerMatch as string).length
@@ -693,7 +703,8 @@ export class Lexer {
693
703
  return tokens
694
704
  }
695
705
  }
696
- function createToken<T extends $T>(type: T, value: string, startOffset: number, endOffset: number): Token<T> {
706
+
707
+ function createToken<T extends $TType>(type: T, value: string, startOffset: number, endOffset: number): Token<T> {
697
708
  return {
698
709
  type,
699
710
  value,