solve-engine 1.0.0-beta.2 → 1.0.0-beta.3
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.
- package/dist/{Lexer-BJdhlnej.d.cts → Lexer-Dkt7KGaU.d.ts} +18 -2
- package/dist/{Lexer-D9l4Yrk2.d.ts → Lexer-y8uY6n6t.d.cts} +18 -2
- package/dist/{PackageRegistry-D-Tv_7ca.d.cts → PackageRegistry-CblRmrHc.d.cts} +60 -4
- package/dist/{PackageRegistry-DaH4aIKP.d.ts → PackageRegistry-wUQyVEyw.d.ts} +60 -4
- package/dist/{Parselet-CK8cQu2a.d.cts → Parselet-C974vhZG.d.cts} +1 -1
- package/dist/{Parselet-ConOIdRO.d.ts → Parselet-CsmtM3It.d.ts} +1 -1
- package/dist/{Token-0jpvUdPY.d.cts → Token-DnU2hwFY.d.cts} +14 -0
- package/dist/{Token-0jpvUdPY.d.ts → Token-DnU2hwFY.d.ts} +14 -0
- package/dist/TokenNormalizer-B8zmhO5X.d.ts +377 -0
- package/dist/TokenNormalizer-CqBCrYkR.d.cts +377 -0
- package/dist/{chunk-M5LX5AOO.js → chunk-23MFG6GG.js} +21 -8
- package/dist/chunk-23MFG6GG.js.map +1 -0
- package/dist/{chunk-SDGRK7EP.js → chunk-2A3VOGVG.js} +4 -4
- package/dist/{chunk-SDGRK7EP.js.map → chunk-2A3VOGVG.js.map} +1 -1
- package/dist/{chunk-NMD5VRN4.cjs → chunk-2R7SVDDB.cjs} +68 -67
- package/dist/chunk-2R7SVDDB.cjs.map +1 -0
- package/dist/{chunk-RIN643A3.js → chunk-626UW5RU.js} +2 -2
- package/dist/chunk-626UW5RU.js.map +1 -0
- package/dist/{chunk-CLL7RUQV.cjs → chunk-7J2Q77OH.cjs} +34 -13
- package/dist/chunk-7J2Q77OH.cjs.map +1 -0
- package/dist/{chunk-HWSZJQCI.js → chunk-AF5AE52C.js} +33 -12
- package/dist/chunk-AF5AE52C.js.map +1 -0
- package/dist/{chunk-RZCWSXTA.cjs → chunk-BOAVE4FC.cjs} +129 -129
- package/dist/{chunk-RZCWSXTA.cjs.map → chunk-BOAVE4FC.cjs.map} +1 -1
- package/dist/{chunk-EBSPLUW4.cjs → chunk-CGIDYRAX.cjs} +19 -9
- package/dist/chunk-CGIDYRAX.cjs.map +1 -0
- package/dist/{chunk-C4XZV6E7.cjs → chunk-EEJSQEHC.cjs} +20 -20
- package/dist/{chunk-C4XZV6E7.cjs.map → chunk-EEJSQEHC.cjs.map} +1 -1
- package/dist/{chunk-LR7YASZF.cjs → chunk-F7G7ZFIZ.cjs} +3 -3
- package/dist/chunk-F7G7ZFIZ.cjs.map +1 -0
- package/dist/{chunk-GW32KPCU.cjs → chunk-FI4WDYSL.cjs} +2 -2
- package/dist/chunk-FI4WDYSL.cjs.map +1 -0
- package/dist/{chunk-EIGTWK5N.js → chunk-KFRBAXKW.js} +3 -3
- package/dist/chunk-KFRBAXKW.js.map +1 -0
- package/dist/{chunk-64W6GLLZ.js → chunk-OJ6LW7VQ.js} +15 -5
- package/dist/chunk-OJ6LW7VQ.js.map +1 -0
- package/dist/{chunk-3PPFLFH4.js → chunk-OWXIOHQB.js} +6 -6
- package/dist/{chunk-3PPFLFH4.js.map → chunk-OWXIOHQB.js.map} +1 -1
- package/dist/{chunk-JBSYC7BB.cjs → chunk-PG2K5BL6.cjs} +41 -28
- package/dist/chunk-PG2K5BL6.cjs.map +1 -0
- package/dist/{chunk-XVWCOTR6.js → chunk-VM5ZKDLH.js} +5 -4
- package/dist/chunk-VM5ZKDLH.js.map +1 -0
- package/dist/{chunk-NMCRQP3Z.cjs → chunk-ZH2PCJ4V.cjs} +68 -68
- package/dist/{chunk-NMCRQP3Z.cjs.map → chunk-ZH2PCJ4V.cjs.map} +1 -1
- package/dist/{chunk-5YEMOYSE.js → chunk-ZS6CRJZP.js} +3 -3
- package/dist/{chunk-5YEMOYSE.js.map → chunk-ZS6CRJZP.js.map} +1 -1
- package/dist/constants.cjs +4 -4
- package/dist/constants.js +1 -1
- package/dist/engine.cjs +19 -19
- package/dist/engine.d.cts +6 -6
- package/dist/engine.d.ts +6 -6
- package/dist/engine.js +9 -9
- package/dist/index.cjs +18 -18
- package/dist/index.d.cts +6 -6
- package/dist/index.d.ts +6 -6
- package/dist/index.js +10 -10
- package/dist/language.cjs +63 -1
- package/dist/language.cjs.map +1 -1
- package/dist/language.d.cts +6 -6
- package/dist/language.d.ts +6 -6
- package/dist/language.js +63 -1
- package/dist/language.js.map +1 -1
- package/dist/lexer.cjs +14 -14
- package/dist/lexer.d.cts +3 -3
- package/dist/lexer.d.ts +3 -3
- package/dist/lexer.js +3 -3
- package/dist/normalizer.cjs +9 -9
- package/dist/normalizer.d.cts +4 -210
- package/dist/normalizer.d.ts +4 -210
- package/dist/normalizer.js +3 -3
- package/dist/packages.cjs +28 -28
- package/dist/packages.d.cts +5 -5
- package/dist/packages.d.ts +5 -5
- package/dist/packages.js +5 -5
- package/dist/parser.cjs +11 -11
- package/dist/parser.d.cts +2 -2
- package/dist/parser.d.ts +2 -2
- package/dist/parser.js +3 -3
- package/dist/resolvers.d.cts +1 -1
- package/dist/resolvers.d.ts +1 -1
- package/dist/uom.d.cts +1 -1
- package/dist/uom.d.ts +1 -1
- package/package.json +2 -1
- package/dist/NormalizerRule-BrVoVjmP.d.cts +0 -163
- package/dist/NormalizerRule-CEjf1FyD.d.ts +0 -163
- package/dist/chunk-64W6GLLZ.js.map +0 -1
- package/dist/chunk-CLL7RUQV.cjs.map +0 -1
- package/dist/chunk-EBSPLUW4.cjs.map +0 -1
- package/dist/chunk-EIGTWK5N.js.map +0 -1
- package/dist/chunk-GW32KPCU.cjs.map +0 -1
- package/dist/chunk-HWSZJQCI.js.map +0 -1
- package/dist/chunk-JBSYC7BB.cjs.map +0 -1
- package/dist/chunk-LR7YASZF.cjs.map +0 -1
- package/dist/chunk-M5LX5AOO.js.map +0 -1
- package/dist/chunk-NMD5VRN4.cjs.map +0 -1
- package/dist/chunk-RIN643A3.js.map +0 -1
- package/dist/chunk-XVWCOTR6.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { T as Token } from './Token-
|
|
1
|
+
import { T as Token } from './Token-DnU2hwFY.js';
|
|
2
2
|
|
|
3
3
|
/** Trie node for multi-word phrase matching. */
|
|
4
4
|
interface PhraseNode {
|
|
@@ -102,7 +102,11 @@ declare class LexerToken implements Token {
|
|
|
102
102
|
lineBreaks: number;
|
|
103
103
|
line: number;
|
|
104
104
|
col: number;
|
|
105
|
-
|
|
105
|
+
/** See {@link Token.sourceEnd}. Set only on normalizer-fused tokens. */
|
|
106
|
+
sourceEnd?: number | undefined;
|
|
107
|
+
constructor(type: string, typeId: number, value: string, text: string, offset: number, lineBreaks: number, line: number, col: number,
|
|
108
|
+
/** See {@link Token.sourceEnd}. Set only on normalizer-fused tokens. */
|
|
109
|
+
sourceEnd?: number | undefined);
|
|
106
110
|
}
|
|
107
111
|
/**
|
|
108
112
|
* Plugin interface for extending the ExpressionLexer with custom tokens.
|
|
@@ -512,6 +516,18 @@ declare class Lexer {
|
|
|
512
516
|
length: number;
|
|
513
517
|
category: TokenCategory | undefined;
|
|
514
518
|
}[];
|
|
519
|
+
/**
|
|
520
|
+
* The same tokens {@link getHighlightTokens} reduces, before reduction.
|
|
521
|
+
*
|
|
522
|
+
* Exists because normalization operates on tokens, not on the flattened
|
|
523
|
+
* shape, and a consumer that wants phrase-fused highlighting has to run the
|
|
524
|
+
* normalizer between the two. See `LanguageService.getSemanticTokens`.
|
|
525
|
+
*
|
|
526
|
+
* @param lineText - One line of source.
|
|
527
|
+
* @returns Every token on the line that is worth painting, unreduced.
|
|
528
|
+
*/
|
|
529
|
+
getHighlightTokenObjects(lineText: string): Token[];
|
|
530
|
+
private collectTokenObjects;
|
|
515
531
|
private collectHighlightTokens;
|
|
516
532
|
}
|
|
517
533
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { T as Token } from './Token-
|
|
1
|
+
import { T as Token } from './Token-DnU2hwFY.cjs';
|
|
2
2
|
|
|
3
3
|
/** Trie node for multi-word phrase matching. */
|
|
4
4
|
interface PhraseNode {
|
|
@@ -102,7 +102,11 @@ declare class LexerToken implements Token {
|
|
|
102
102
|
lineBreaks: number;
|
|
103
103
|
line: number;
|
|
104
104
|
col: number;
|
|
105
|
-
|
|
105
|
+
/** See {@link Token.sourceEnd}. Set only on normalizer-fused tokens. */
|
|
106
|
+
sourceEnd?: number | undefined;
|
|
107
|
+
constructor(type: string, typeId: number, value: string, text: string, offset: number, lineBreaks: number, line: number, col: number,
|
|
108
|
+
/** See {@link Token.sourceEnd}. Set only on normalizer-fused tokens. */
|
|
109
|
+
sourceEnd?: number | undefined);
|
|
106
110
|
}
|
|
107
111
|
/**
|
|
108
112
|
* Plugin interface for extending the ExpressionLexer with custom tokens.
|
|
@@ -512,6 +516,18 @@ declare class Lexer {
|
|
|
512
516
|
length: number;
|
|
513
517
|
category: TokenCategory | undefined;
|
|
514
518
|
}[];
|
|
519
|
+
/**
|
|
520
|
+
* The same tokens {@link getHighlightTokens} reduces, before reduction.
|
|
521
|
+
*
|
|
522
|
+
* Exists because normalization operates on tokens, not on the flattened
|
|
523
|
+
* shape, and a consumer that wants phrase-fused highlighting has to run the
|
|
524
|
+
* normalizer between the two. See `LanguageService.getSemanticTokens`.
|
|
525
|
+
*
|
|
526
|
+
* @param lineText - One line of source.
|
|
527
|
+
* @returns Every token on the line that is worth painting, unreduced.
|
|
528
|
+
*/
|
|
529
|
+
getHighlightTokenObjects(lineText: string): Token[];
|
|
530
|
+
private collectTokenObjects;
|
|
515
531
|
private collectHighlightTokens;
|
|
516
532
|
}
|
|
517
533
|
/**
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { a as PrecedenceParser, b as PrefixParselet, I as InfixParselet } from './Parselet-
|
|
1
|
+
import { a as PrecedenceParser, b as PrefixParselet, I as InfixParselet } from './Parselet-C974vhZG.cjs';
|
|
2
2
|
import { V as Value } from './Value-KtAQNHur.cjs';
|
|
3
3
|
import { IVariableSource } from './variables.cjs';
|
|
4
|
-
import { M as MarkdownLineType, L as Lexer, e as TokenCategory, c as LexerVocabulary } from './Lexer-
|
|
4
|
+
import { M as MarkdownLineType, L as Lexer, e as TokenCategory, c as LexerVocabulary } from './Lexer-y8uY6n6t.cjs';
|
|
5
5
|
import { IAsyncResolver } from './resolvers.cjs';
|
|
6
|
-
import { T as TokenFusion,
|
|
6
|
+
import { T as TokenFusion, c as TokenNormalizer, a as NormalizerRule } from './TokenNormalizer-CqBCrYkR.cjs';
|
|
7
7
|
import { D as DependencyGraph, V as VM, a as DagSnapshot, b as EngineContext, S as ScopeManager, L as LineExecutionContext } from './ScopeManager-CKfQtl7l.cjs';
|
|
8
8
|
import { a as BytecodeProgram } from './BytecodeBuilder-3egMyuDi.cjs';
|
|
9
9
|
import { QueryClient } from '@tanstack/query-core';
|
|
10
10
|
import { E as EngineError } from './EngineError-DvPSnhZi.cjs';
|
|
11
11
|
import { a as DiagnosticReportJSON, D as DiagnosticPipeline } from './pipeline-DPUQt7yL.cjs';
|
|
12
|
-
import { T as Token } from './Token-
|
|
12
|
+
import { T as Token } from './Token-DnU2hwFY.cjs';
|
|
13
13
|
import { D as DEFAULT_CONFIG, E as EngineConfig } from './Configuration-fVpd-HC-.cjs';
|
|
14
14
|
|
|
15
15
|
/**
|
|
@@ -1958,6 +1958,17 @@ declare class ExpressionEngine {
|
|
|
1958
1958
|
getContext(): EngineContext;
|
|
1959
1959
|
getScopeManager(): ScopeManager;
|
|
1960
1960
|
getLexer(): Lexer;
|
|
1961
|
+
/**
|
|
1962
|
+
* This engine's token normalizer, with every phrase and rule its packages
|
|
1963
|
+
* registered.
|
|
1964
|
+
*
|
|
1965
|
+
* Exposed for the highlighting path. `LanguageService` classifies tokens
|
|
1966
|
+
* after the lexer but can only see phrase-fused types (a date literal, a
|
|
1967
|
+
* timecode, a package's own fused token) by running the same normalizer
|
|
1968
|
+
* evaluation runs. Sharing this instance rather than building a second one
|
|
1969
|
+
* is what keeps the two from disagreeing.
|
|
1970
|
+
*/
|
|
1971
|
+
getNormalizer(): TokenNormalizer;
|
|
1961
1972
|
/**
|
|
1962
1973
|
* Every completion candidate contributed by currently-registered
|
|
1963
1974
|
* packages (`IEnginePackage.completionItems`), flattened across all of
|
|
@@ -2174,6 +2185,20 @@ interface LanguageServiceOptions {
|
|
|
2174
2185
|
* evaluation engine's DAG snapshot instead.
|
|
2175
2186
|
*/
|
|
2176
2187
|
variableNameSource?: () => Iterable<string>;
|
|
2188
|
+
/**
|
|
2189
|
+
* Run the normalizer on the highlighting path, so phrase-fused tokens are
|
|
2190
|
+
* classified as the thing the parser will actually see.
|
|
2191
|
+
*
|
|
2192
|
+
* Off by default, and the default is a judgement rather than an oversight.
|
|
2193
|
+
* Highlighting runs per keystroke, normalization is real work, and a host
|
|
2194
|
+
* that is happy with lexer-level categories should not start paying for
|
|
2195
|
+
* fusion because a new version shipped. Turn it on and `12/09/2026` is one
|
|
2196
|
+
* `datetime` span instead of five number and operator spans; leave it off
|
|
2197
|
+
* and nothing about this class changes.
|
|
2198
|
+
*
|
|
2199
|
+
* See `benchmarks/languageServiceBenchmarks.spec.ts` for what it costs.
|
|
2200
|
+
*/
|
|
2201
|
+
normalizeForHighlighting?: boolean;
|
|
2177
2202
|
}
|
|
2178
2203
|
/**
|
|
2179
2204
|
* Editor-agnostic "language server" for solve expressions: turns a line of
|
|
@@ -2229,11 +2254,42 @@ interface LanguageServiceOptions {
|
|
|
2229
2254
|
declare class LanguageService {
|
|
2230
2255
|
private engine;
|
|
2231
2256
|
private variableNameSource;
|
|
2257
|
+
private readonly normalizeForHighlighting;
|
|
2232
2258
|
private cache;
|
|
2233
2259
|
private staticCompletionCandidates;
|
|
2234
2260
|
private staticCompletionIndex;
|
|
2235
2261
|
constructor(engine?: ExpressionEngine | null, options?: LanguageServiceOptions);
|
|
2236
2262
|
private defaultVariableNames;
|
|
2263
|
+
/**
|
|
2264
|
+
* Lex a line, normalize it, and place every resulting token back in the
|
|
2265
|
+
* source text.
|
|
2266
|
+
*
|
|
2267
|
+
* ## Why placing them back is the hard part
|
|
2268
|
+
*
|
|
2269
|
+
* Normalization produces three kinds of token and only one of them can be
|
|
2270
|
+
* highlighted the obvious way.
|
|
2271
|
+
*
|
|
2272
|
+
* A token the normalizer left alone still describes its own text, so its
|
|
2273
|
+
* span is `offset` to `offset + value.length`, exactly as before.
|
|
2274
|
+
*
|
|
2275
|
+
* A FUSED token does not. `10 frames` becomes a FRAME_COUNT whose value is
|
|
2276
|
+
* `10`, and a timecode becomes a token whose value is a comma-separated
|
|
2277
|
+
* tuple appearing nowhere on the line. Those carry `sourceEnd`, set by
|
|
2278
|
+
* `createFusedToken`, which is the only place that knows where the fusion
|
|
2279
|
+
* ended.
|
|
2280
|
+
*
|
|
2281
|
+
* An INSERTED token has no text at all. Implicit multiplication puts a STAR
|
|
2282
|
+
* at the following token's offset, so `5(3)` gains a `*` sitting exactly
|
|
2283
|
+
* where the `(` is. Painting it would colour a character the reader never
|
|
2284
|
+
* typed as an operator, and would overlap the token that really is there.
|
|
2285
|
+
* These are dropped, detected by the one test that needs no cooperation
|
|
2286
|
+
* from any rule: a token with no recorded fusion span must match the text
|
|
2287
|
+
* at its own offset, and an inserted one does not.
|
|
2288
|
+
*
|
|
2289
|
+
* @param lineText - The raw line.
|
|
2290
|
+
* @returns Spans in the same shape `Lexer.getHighlightTokens` returns.
|
|
2291
|
+
*/
|
|
2292
|
+
private classifyNormalized;
|
|
2237
2293
|
/**
|
|
2238
2294
|
* Classify every recognized token on one line.
|
|
2239
2295
|
*
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { a as PrecedenceParser, b as PrefixParselet, I as InfixParselet } from './Parselet-
|
|
1
|
+
import { a as PrecedenceParser, b as PrefixParselet, I as InfixParselet } from './Parselet-CsmtM3It.js';
|
|
2
2
|
import { V as Value } from './Value-KtAQNHur.js';
|
|
3
3
|
import { IVariableSource } from './variables.js';
|
|
4
|
-
import { M as MarkdownLineType, L as Lexer, e as TokenCategory, c as LexerVocabulary } from './Lexer-
|
|
4
|
+
import { M as MarkdownLineType, L as Lexer, e as TokenCategory, c as LexerVocabulary } from './Lexer-Dkt7KGaU.js';
|
|
5
5
|
import { IAsyncResolver } from './resolvers.js';
|
|
6
|
-
import { T as TokenFusion,
|
|
6
|
+
import { T as TokenFusion, c as TokenNormalizer, a as NormalizerRule } from './TokenNormalizer-B8zmhO5X.js';
|
|
7
7
|
import { D as DependencyGraph, V as VM, a as DagSnapshot, b as EngineContext, S as ScopeManager, L as LineExecutionContext } from './ScopeManager-B5k0nk05.js';
|
|
8
8
|
import { a as BytecodeProgram } from './BytecodeBuilder-3egMyuDi.js';
|
|
9
9
|
import { QueryClient } from '@tanstack/query-core';
|
|
10
10
|
import { E as EngineError } from './EngineError-DvPSnhZi.js';
|
|
11
11
|
import { a as DiagnosticReportJSON, D as DiagnosticPipeline } from './pipeline-CrsRPmsv.js';
|
|
12
|
-
import { T as Token } from './Token-
|
|
12
|
+
import { T as Token } from './Token-DnU2hwFY.js';
|
|
13
13
|
import { D as DEFAULT_CONFIG, E as EngineConfig } from './Configuration-fVpd-HC-.js';
|
|
14
14
|
|
|
15
15
|
/**
|
|
@@ -1958,6 +1958,17 @@ declare class ExpressionEngine {
|
|
|
1958
1958
|
getContext(): EngineContext;
|
|
1959
1959
|
getScopeManager(): ScopeManager;
|
|
1960
1960
|
getLexer(): Lexer;
|
|
1961
|
+
/**
|
|
1962
|
+
* This engine's token normalizer, with every phrase and rule its packages
|
|
1963
|
+
* registered.
|
|
1964
|
+
*
|
|
1965
|
+
* Exposed for the highlighting path. `LanguageService` classifies tokens
|
|
1966
|
+
* after the lexer but can only see phrase-fused types (a date literal, a
|
|
1967
|
+
* timecode, a package's own fused token) by running the same normalizer
|
|
1968
|
+
* evaluation runs. Sharing this instance rather than building a second one
|
|
1969
|
+
* is what keeps the two from disagreeing.
|
|
1970
|
+
*/
|
|
1971
|
+
getNormalizer(): TokenNormalizer;
|
|
1961
1972
|
/**
|
|
1962
1973
|
* Every completion candidate contributed by currently-registered
|
|
1963
1974
|
* packages (`IEnginePackage.completionItems`), flattened across all of
|
|
@@ -2174,6 +2185,20 @@ interface LanguageServiceOptions {
|
|
|
2174
2185
|
* evaluation engine's DAG snapshot instead.
|
|
2175
2186
|
*/
|
|
2176
2187
|
variableNameSource?: () => Iterable<string>;
|
|
2188
|
+
/**
|
|
2189
|
+
* Run the normalizer on the highlighting path, so phrase-fused tokens are
|
|
2190
|
+
* classified as the thing the parser will actually see.
|
|
2191
|
+
*
|
|
2192
|
+
* Off by default, and the default is a judgement rather than an oversight.
|
|
2193
|
+
* Highlighting runs per keystroke, normalization is real work, and a host
|
|
2194
|
+
* that is happy with lexer-level categories should not start paying for
|
|
2195
|
+
* fusion because a new version shipped. Turn it on and `12/09/2026` is one
|
|
2196
|
+
* `datetime` span instead of five number and operator spans; leave it off
|
|
2197
|
+
* and nothing about this class changes.
|
|
2198
|
+
*
|
|
2199
|
+
* See `benchmarks/languageServiceBenchmarks.spec.ts` for what it costs.
|
|
2200
|
+
*/
|
|
2201
|
+
normalizeForHighlighting?: boolean;
|
|
2177
2202
|
}
|
|
2178
2203
|
/**
|
|
2179
2204
|
* Editor-agnostic "language server" for solve expressions: turns a line of
|
|
@@ -2229,11 +2254,42 @@ interface LanguageServiceOptions {
|
|
|
2229
2254
|
declare class LanguageService {
|
|
2230
2255
|
private engine;
|
|
2231
2256
|
private variableNameSource;
|
|
2257
|
+
private readonly normalizeForHighlighting;
|
|
2232
2258
|
private cache;
|
|
2233
2259
|
private staticCompletionCandidates;
|
|
2234
2260
|
private staticCompletionIndex;
|
|
2235
2261
|
constructor(engine?: ExpressionEngine | null, options?: LanguageServiceOptions);
|
|
2236
2262
|
private defaultVariableNames;
|
|
2263
|
+
/**
|
|
2264
|
+
* Lex a line, normalize it, and place every resulting token back in the
|
|
2265
|
+
* source text.
|
|
2266
|
+
*
|
|
2267
|
+
* ## Why placing them back is the hard part
|
|
2268
|
+
*
|
|
2269
|
+
* Normalization produces three kinds of token and only one of them can be
|
|
2270
|
+
* highlighted the obvious way.
|
|
2271
|
+
*
|
|
2272
|
+
* A token the normalizer left alone still describes its own text, so its
|
|
2273
|
+
* span is `offset` to `offset + value.length`, exactly as before.
|
|
2274
|
+
*
|
|
2275
|
+
* A FUSED token does not. `10 frames` becomes a FRAME_COUNT whose value is
|
|
2276
|
+
* `10`, and a timecode becomes a token whose value is a comma-separated
|
|
2277
|
+
* tuple appearing nowhere on the line. Those carry `sourceEnd`, set by
|
|
2278
|
+
* `createFusedToken`, which is the only place that knows where the fusion
|
|
2279
|
+
* ended.
|
|
2280
|
+
*
|
|
2281
|
+
* An INSERTED token has no text at all. Implicit multiplication puts a STAR
|
|
2282
|
+
* at the following token's offset, so `5(3)` gains a `*` sitting exactly
|
|
2283
|
+
* where the `(` is. Painting it would colour a character the reader never
|
|
2284
|
+
* typed as an operator, and would overlap the token that really is there.
|
|
2285
|
+
* These are dropped, detected by the one test that needs no cooperation
|
|
2286
|
+
* from any rule: a token with no recorded fusion span must match the text
|
|
2287
|
+
* at its own offset, and an inserted one does not.
|
|
2288
|
+
*
|
|
2289
|
+
* @param lineText - The raw line.
|
|
2290
|
+
* @returns Spans in the same shape `Lexer.getHighlightTokens` returns.
|
|
2291
|
+
*/
|
|
2292
|
+
private classifyNormalized;
|
|
2237
2293
|
/**
|
|
2238
2294
|
* Classify every recognized token on one line.
|
|
2239
2295
|
*
|
|
@@ -19,6 +19,20 @@ interface Token {
|
|
|
19
19
|
lineBreaks: number;
|
|
20
20
|
line: number;
|
|
21
21
|
col: number;
|
|
22
|
+
/**
|
|
23
|
+
* End offset of the source text this token was fused from, exclusive.
|
|
24
|
+
*
|
|
25
|
+
* Only set on tokens the normalizer built by fusing several lexer tokens
|
|
26
|
+
* into one, and only there because those are the tokens whose `value` no
|
|
27
|
+
* longer describes the text they came from. `10 frames` fuses into a
|
|
28
|
+
* FRAME_COUNT whose value is `10`, so `offset + value.length` would cover
|
|
29
|
+
* two characters of a nine-character phrase.
|
|
30
|
+
*
|
|
31
|
+
* Evaluation never reads this. It exists so that a consumer painting a line
|
|
32
|
+
* (see `LanguageService.getSemanticTokens`) can highlight a fused phrase as
|
|
33
|
+
* the one thing the parser will see rather than as its parts.
|
|
34
|
+
*/
|
|
35
|
+
sourceEnd?: number;
|
|
22
36
|
}
|
|
23
37
|
/**
|
|
24
38
|
* Canonical token type name constants.
|
|
@@ -19,6 +19,20 @@ interface Token {
|
|
|
19
19
|
lineBreaks: number;
|
|
20
20
|
line: number;
|
|
21
21
|
col: number;
|
|
22
|
+
/**
|
|
23
|
+
* End offset of the source text this token was fused from, exclusive.
|
|
24
|
+
*
|
|
25
|
+
* Only set on tokens the normalizer built by fusing several lexer tokens
|
|
26
|
+
* into one, and only there because those are the tokens whose `value` no
|
|
27
|
+
* longer describes the text they came from. `10 frames` fuses into a
|
|
28
|
+
* FRAME_COUNT whose value is `10`, so `offset + value.length` would cover
|
|
29
|
+
* two characters of a nine-character phrase.
|
|
30
|
+
*
|
|
31
|
+
* Evaluation never reads this. It exists so that a consumer painting a line
|
|
32
|
+
* (see `LanguageService.getSemanticTokens`) can highlight a fused phrase as
|
|
33
|
+
* the one thing the parser will see rather than as its parts.
|
|
34
|
+
*/
|
|
35
|
+
sourceEnd?: number;
|
|
22
36
|
}
|
|
23
37
|
/**
|
|
24
38
|
* Canonical token type name constants.
|