@jsb188/mday 1.1.10 → 1.1.12
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/package.json +140 -54
- package/src/constants/agentMemory.ts +123 -0
- package/src/constants/agentNote.ts +212 -0
- package/src/constants/aiChat.ts +10 -0
- package/src/constants/billing.ts +126 -0
- package/src/constants/campaign.ts +236 -0
- package/src/constants/contact.ts +72 -0
- package/src/constants/csvExport.ts +133 -0
- package/src/constants/dataTable.ts +21 -21
- package/src/constants/dataTableFieldTypes.generated.ts +59 -0
- package/src/constants/docAccess.ts +33 -0
- package/src/constants/dt.ts +234 -0
- package/src/constants/email.ts +125 -7
- package/src/constants/fieldDoc.ts +104 -0
- package/src/constants/graphqlReactivity.ts +196 -0
- package/src/constants/integration.ts +8 -9
- package/src/constants/log.ts +14 -408
- package/src/constants/logDisplay/README.md +88 -0
- package/src/constants/logDisplay/defaults.ts +39 -0
- package/src/constants/logDisplay/index.ts +27 -0
- package/src/constants/logDisplay/operations/arable.ts +16 -0
- package/src/constants/logDisplay/operations/farmersMarket.ts +10 -0
- package/src/constants/logDisplay/operations/foodManufacturing.ts +13 -0
- package/src/constants/logDisplay/shared/accounting.ts +13 -0
- package/src/constants/logDisplay/shared/interactions.ts +13 -0
- package/src/constants/logDisplay/shared/rackTemperatures.ts +42 -0
- package/src/constants/logTaxonomy.generated.ts +2207 -0
- package/src/constants/noteDoc.ts +77 -0
- package/src/constants/organization.ts +18 -21
- package/src/constants/pageRoute.ts +23 -0
- package/src/constants/qrCode.ts +30 -0
- package/src/constants/sheet.ts +126 -14
- package/src/constants/sms.ts +18 -0
- package/src/constants/square.ts +6 -6
- package/src/constants/storage.ts +80 -7
- package/src/constants/usage.ts +82 -0
- package/src/constants/workflowSteps.ts +60 -0
- package/src/schemas/editLogEntry.ts +836 -780
- package/src/schemas/inboundContact.ts +60 -55
- package/src/schemas/logsQuery.ts +55 -49
- package/src/types/account.d.ts +4 -1
- package/src/types/agentMemory.d.ts +98 -0
- package/src/types/agentNote.d.ts +443 -0
- package/src/types/billing.d.ts +537 -0
- package/src/types/campaign.d.ts +1533 -0
- package/src/types/contact.d.ts +15 -0
- package/src/types/csvExport.d.ts +213 -0
- package/src/types/dataAnalysis.d.ts +44 -0
- package/src/types/dataTable.d.ts +115 -403
- package/src/types/definitionElement.d.ts +35 -0
- package/src/types/docAccess.d.ts +96 -0
- package/src/types/dt.d.ts +257 -0
- package/src/types/email.d.ts +184 -24
- package/src/types/emailReplyReport.d.ts +76 -0
- package/src/types/fieldDoc.d.ts +702 -0
- package/src/types/fieldDocContract.d.ts +90 -0
- package/src/types/inboundContact.d.ts +10 -1
- package/src/types/log.d.ts +254 -295
- package/src/types/logDisplay.types.ts +85 -0
- package/src/types/organization.d.ts +91 -43
- package/src/types/pageRoute.d.ts +48 -0
- package/src/types/qrCode.d.ts +96 -0
- package/src/types/richText.d.ts +81 -0
- package/src/types/sheet.d.ts +678 -129
- package/src/types/sms.d.ts +38 -0
- package/src/types/storage.d.ts +449 -129
- package/src/types/usage.d.ts +106 -0
- package/src/types/workflow.d.ts +315 -54
- package/src/utils/agentMemory.ts +15 -0
- package/src/utils/agentNote.ts +850 -0
- package/src/utils/aiChat.ts +43 -0
- package/src/utils/aiChatWork.ts +64 -0
- package/src/utils/billing.ts +37 -0
- package/src/utils/campaign.ts +1174 -0
- package/src/utils/campaignAI.ts +72 -0
- package/src/utils/campaignAccess.ts +239 -0
- package/src/utils/campaignEmail.ts +601 -0
- package/src/utils/campaignEmailCompiler.ts +372 -0
- package/src/utils/campaignEmailImages.ts +60 -0
- package/src/utils/campaignEmailStyles.ts +544 -0
- package/src/utils/campaignLifecycle.ts +104 -0
- package/src/utils/campaignPreview.ts +285 -0
- package/src/utils/contact.ts +50 -0
- package/src/utils/csvExport.ts +19 -0
- package/src/utils/dataTable.ts +95 -618
- package/src/utils/dataTableFieldTypeRegistry.ts +106 -0
- package/src/utils/dataTableRelativeDate.ts +447 -0
- package/src/utils/definitionElement.ts +84 -0
- package/src/utils/docAccess.ts +383 -0
- package/src/utils/documentName.ts +53 -0
- package/src/utils/email.ts +317 -51
- package/src/utils/emailReplyReport.test.ts +187 -0
- package/src/utils/emailReplyReport.ts +143 -0
- package/src/utils/fieldDoc.ts +157 -0
- package/src/utils/fieldDocAnswers.ts +128 -0
- package/src/utils/fieldDocDefaults.ts +36 -0
- package/src/utils/fieldDocProgram.ts +36 -0
- package/src/utils/fieldDocSummary.ts +30 -0
- package/src/utils/log.ts +276 -192
- package/src/utils/logDisplay.helpers.ts +177 -0
- package/src/utils/logDisplay.ts +87 -0
- package/src/utils/logRegistryValue.ts +90 -0
- package/src/utils/logStoreRead.ts +262 -0
- package/src/utils/logTaxonomy.helpers.ts +17 -0
- package/src/utils/logTaxonomy.ts +76 -0
- package/src/utils/logTaxonomyDisplay.ts +395 -0
- package/src/utils/noteDoc.ts +609 -0
- package/src/utils/organization.ts +337 -84
- package/src/utils/pageRoute.ts +71 -0
- package/src/utils/qrCode.helpers.ts +189 -0
- package/src/utils/qrCode.test.ts +519 -0
- package/src/utils/qrCode.ts +273 -0
- package/src/utils/richTextHTML.ts +385 -0
- package/src/utils/sheet.ts +199 -107
- package/src/utils/sheetAxisMove.ts +616 -0
- package/src/utils/sheetBootstrap.ts +1402 -0
- package/src/utils/sheetCellLiteral.ts +101 -0
- package/src/utils/sheetCommand.ts +358 -0
- package/src/utils/sheetDesign.ts +705 -0
- package/src/utils/sheetExport.ts +186 -0
- package/src/utils/sheetFeatureReference.ts +183 -0
- package/src/utils/sheetFormulaArgs.ts +168 -0
- package/src/utils/sheetFormulaCompile.ts +475 -0
- package/src/utils/sheetFormulaConditionalAggregate.ts +254 -0
- package/src/utils/sheetFormulaCriteria.ts +656 -0
- package/src/utils/sheetFormulaDate.ts +444 -0
- package/src/utils/sheetFormulaEvaluation.ts +899 -0
- package/src/utils/sheetFormulaEvaluator.ts +997 -0
- package/src/utils/sheetFormulaFunctionHandlers.ts +403 -0
- package/src/utils/sheetFormulaLogical.ts +116 -0
- package/src/utils/sheetFormulaLookup.ts +488 -0
- package/src/utils/sheetFormulaMath.ts +48 -0
- package/src/utils/sheetFormulaParser.ts +729 -0
- package/src/utils/sheetFormulaRange.ts +330 -0
- package/src/utils/sheetFormulaReference.ts +703 -0
- package/src/utils/sheetFormulaReferenceAggregates.ts +313 -0
- package/src/utils/sheetFormulaReferenceDates.ts +237 -0
- package/src/utils/sheetFormulaReferenceLogical.ts +330 -0
- package/src/utils/sheetFormulaReferenceLookup.ts +341 -0
- package/src/utils/sheetFormulaReferenceMath.ts +95 -0
- package/src/utils/sheetFormulaReferenceRewrite.ts +220 -0
- package/src/utils/sheetFormulaReferenceText.ts +462 -0
- package/src/utils/sheetFormulaSyntax.ts +1027 -0
- package/src/utils/sheetFormulaText.ts +430 -0
- package/src/utils/sheetJournal.ts +200 -0
- package/src/utils/sheetNumberFormat.ts +1012 -0
- package/src/utils/sheetPreview.ts +68 -0
- package/src/utils/sheetSequence.ts +118 -0
- package/src/utils/sheetSnapshot.ts +739 -0
- package/src/utils/sheetStructureEdit.ts +914 -0
- package/src/utils/sheetStructureReferences.ts +389 -0
- package/src/utils/square.ts +22 -12
- package/src/utils/storage.ts +198 -0
- package/src/utils/table-route.ts +127 -11
- package/src/utils/time.ts +12 -0
- package/src/utils/workflow.ts +334 -40
- package/src/utils/workflowLogFingerprint.ts +302 -0
- package/src/utils/workflowLogRevisionSnapshot.ts +424 -0
- package/src/utils/workflowProgress.ts +280 -0
- package/src/utils/workflowTriggers.ts +61 -0
- package/tests/agentNote.test.ts +395 -0
- package/tests/campaignAI.test.ts +119 -0
- package/tests/campaignAccess.test.ts +239 -0
- package/tests/campaignEmail.test.ts +441 -0
- package/tests/campaignLifecycle.test.ts +134 -0
- package/tests/campaignPublication.test.ts +309 -0
- package/tests/dataTableFieldTypeRegistry.test.ts +111 -0
- package/tests/dataTableRelativeDate.test.ts +412 -0
- package/tests/docAccess.test.ts +525 -0
- package/tests/editLogEntry.test.ts +112 -0
- package/tests/email.test.ts +39 -0
- package/tests/fieldDocProgram.test.ts +114 -0
- package/tests/logDisplay.fixtures.ts +67 -0
- package/tests/logDisplay.test.ts +227 -0
- package/tests/noteDoc.test.ts +514 -0
- package/tests/richTextHTML.test.ts +185 -0
- package/tests/sheetAxisMove.test.ts +352 -0
- package/tests/sheetBootstrap.test.ts +1967 -0
- package/tests/sheetFeatureReference.test.ts +22 -0
- package/tests/sheetFormulaCriteria.test.ts +269 -0
- package/tests/sheetFormulaEvaluator.test.ts +468 -0
- package/tests/sheetFormulaFunctions.test.ts +538 -0
- package/tests/sheetFormulaLanguage.test.ts +361 -0
- package/tests/sheetFormulaParity.fixtures.ts +872 -0
- package/tests/sheetFormulaParity.test.ts +188 -0
- package/tests/sheetFormulaRange.test.ts +167 -0
- package/tests/sheetFormulaReference.test.ts +78 -0
- package/tests/sheetFormulaReferenceRewrite.test.ts +117 -0
- package/tests/sheetFormulaTextDate.test.ts +512 -0
- package/tests/sheetSequence.test.ts +22 -0
- package/tests/sheetSnapshot.test.ts +134 -0
- package/tests/sheetStructureEdit.test.ts +537 -0
- package/tests/sheetStructureReferences.test.ts +589 -0
- package/tests/workflowLifecycleStatus.test.ts +60 -0
- package/tests/workflowLogFingerprint.test.ts +203 -0
- package/tests/workflowLogRevisionSnapshot.test.ts +96 -0
- package/tests/workflowProgress.test.ts +180 -0
- package/tests/workflowTriggers.test.ts +29 -0
- package/tsconfig.json +10 -10
- package/vitest.config.ts +8 -0
- package/src/constants/log-activityTexts.ts +0 -235
- package/src/constants/product.ts +0 -42
- package/src/constants/report.ts +0 -44
- package/src/schemas/organization.ts +0 -65
- package/src/schemas/productsQuery.ts +0 -53
- package/src/schemas/reportsQuery.ts +0 -20
- package/src/types/product.d.ts +0 -84
- package/src/types/report.d.ts +0 -290
- package/src/utils/product-calEvent.ts +0 -455
- package/src/utils/report.ts +0 -158
|
@@ -0,0 +1,729 @@
|
|
|
1
|
+
import { SHEET_MAX_ROW_COUNT } from '../constants/sheet.ts';
|
|
2
|
+
import {
|
|
3
|
+
getSheetFormulaCellReferenceEndIndex,
|
|
4
|
+
getSheetFormulaColumnIndex,
|
|
5
|
+
getSheetFormulaStringEndIndex,
|
|
6
|
+
isSheetFormulaIdentifierChar,
|
|
7
|
+
isSheetFormulaStringQuoteChar,
|
|
8
|
+
normalizeSheetFormulaReferenceSheetName,
|
|
9
|
+
parseSheetFormulaCellReference,
|
|
10
|
+
parseSheetFormulaStringLiteral,
|
|
11
|
+
type SheetFormulaASTNode,
|
|
12
|
+
type SheetFormulaBinaryOperator,
|
|
13
|
+
type SheetFormulaCellReference,
|
|
14
|
+
type SheetFormulaRangeReference,
|
|
15
|
+
type SheetFormulaReferenceToken,
|
|
16
|
+
} from './sheetFormulaSyntax.ts';
|
|
17
|
+
|
|
18
|
+
export type SheetFormulaSyntaxIssue = {
|
|
19
|
+
message: string;
|
|
20
|
+
text?: string | null;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
type SheetFormulaParserState = {
|
|
24
|
+
index: number;
|
|
25
|
+
value: string;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const FILE_CONSTANTS = {
|
|
29
|
+
bareStringValuePattern: /^[A-Za-z_][A-Za-z0-9_-]*$/,
|
|
30
|
+
isoDateValuePattern: /^\d{4}-\d{2}-\d{2}(?:[T ][0-9]{2}:[0-9]{2}(?::[0-9]{2}(?:\.[0-9]+)?)?(?:Z|[+-][0-9]{2}:[0-9]{2})?)?$/,
|
|
31
|
+
// Error literals the parser accepts, keyed by their uppercase spelling
|
|
32
|
+
errorLiteralCodes: {
|
|
33
|
+
'#REF!': 'INVALID_REFERENCE',
|
|
34
|
+
} as Readonly<Record<string, string>>,
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
/*
|
|
38
|
+
* Return the current parser offset after any whitespace.
|
|
39
|
+
*/
|
|
40
|
+
function skipSheetFormulaParserWhitespace(state: SheetFormulaParserState) {
|
|
41
|
+
while (/\s/.test(state.value[state.index] || '')) {
|
|
42
|
+
state.index += 1;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/*
|
|
47
|
+
* Return source text covered by one parser span.
|
|
48
|
+
*/
|
|
49
|
+
function getSheetFormulaParserSpanText(state: SheetFormulaParserState, startIndex: number) {
|
|
50
|
+
return state.value.slice(startIndex, state.index).trim();
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/*
|
|
54
|
+
* Return whether the parser has consumed the full formula expression.
|
|
55
|
+
*/
|
|
56
|
+
function isSheetFormulaParserAtEnd(state: SheetFormulaParserState) {
|
|
57
|
+
skipSheetFormulaParserWhitespace(state);
|
|
58
|
+
return state.index >= state.value.length;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/*
|
|
62
|
+
* Return a parsed function or identifier name at the current parser position.
|
|
63
|
+
*/
|
|
64
|
+
function parseSheetFormulaIdentifierName(state: SheetFormulaParserState) {
|
|
65
|
+
const match = state.value.slice(state.index).match(/^@?[A-Za-z_][A-Za-z0-9_]*/);
|
|
66
|
+
if (!match) {
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
state.index += match[0].length;
|
|
71
|
+
return match[0];
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/*
|
|
75
|
+
* Return a quoted sheet-tab prefix at the current parser position.
|
|
76
|
+
*/
|
|
77
|
+
function parseSheetFormulaQuotedSheetNamePrefix(state: SheetFormulaParserState) {
|
|
78
|
+
if (state.value[state.index] !== "'") {
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
let sheetName = '';
|
|
83
|
+
let index = state.index + 1;
|
|
84
|
+
while (index < state.value.length) {
|
|
85
|
+
const char = state.value[index];
|
|
86
|
+
|
|
87
|
+
if (char === "'" && state.value[index + 1] === "'") {
|
|
88
|
+
sheetName += "'";
|
|
89
|
+
index += 2;
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
if (char === "'") {
|
|
94
|
+
const normalizedName = normalizeSheetFormulaReferenceSheetName(sheetName);
|
|
95
|
+
if (!normalizedName || state.value[index + 1] !== '!') {
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
state.index = index + 2;
|
|
100
|
+
return normalizedName;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
sheetName += char;
|
|
104
|
+
index += 1;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
return null;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/*
|
|
111
|
+
* Return an unquoted sheet-tab prefix at the current parser position.
|
|
112
|
+
*/
|
|
113
|
+
function parseSheetFormulaUnquotedSheetNamePrefix(state: SheetFormulaParserState) {
|
|
114
|
+
const remaining = state.value.slice(state.index);
|
|
115
|
+
const match = remaining.match(/^([A-Za-z_][A-Za-z0-9_ .-]*)!/);
|
|
116
|
+
if (!match) {
|
|
117
|
+
return null;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
const sheetName = normalizeSheetFormulaReferenceSheetName(match[1]);
|
|
121
|
+
if (!sheetName) {
|
|
122
|
+
return null;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
state.index += match[0].length;
|
|
126
|
+
return sheetName;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/*
|
|
130
|
+
* Return an optional sheet-tab prefix before a cell or range reference.
|
|
131
|
+
*/
|
|
132
|
+
function parseSheetFormulaSheetNamePrefix(state: SheetFormulaParserState) {
|
|
133
|
+
const startIndex = state.index;
|
|
134
|
+
const sheetName = parseSheetFormulaQuotedSheetNamePrefix(state) || parseSheetFormulaUnquotedSheetNamePrefix(state);
|
|
135
|
+
if (!sheetName || getSheetFormulaCellReferenceEndIndex(state.value, state.index) === null) {
|
|
136
|
+
state.index = startIndex;
|
|
137
|
+
return null;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
return sheetName;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/*
|
|
144
|
+
* Return a parsed cell reference at the current parser position.
|
|
145
|
+
*/
|
|
146
|
+
function parseSheetFormulaCellReferenceAtState(state: SheetFormulaParserState) {
|
|
147
|
+
const startIndex = state.index;
|
|
148
|
+
const sheetName = parseSheetFormulaSheetNamePrefix(state);
|
|
149
|
+
const coordinateStartIndex = state.index;
|
|
150
|
+
const match = state.value.slice(state.index).match(/^(\$?[A-Za-z]+\$?[1-9]\d*)/);
|
|
151
|
+
if (!match) {
|
|
152
|
+
state.index = startIndex;
|
|
153
|
+
return null;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
const nextChar = state.value[state.index + match[1].length];
|
|
157
|
+
if (isSheetFormulaIdentifierChar(nextChar)) {
|
|
158
|
+
state.index = startIndex;
|
|
159
|
+
return null;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
const reference = parseSheetFormulaCellReference(match[1]);
|
|
163
|
+
if (!reference) {
|
|
164
|
+
state.index = startIndex;
|
|
165
|
+
return null;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
state.index += match[1].length;
|
|
169
|
+
return {
|
|
170
|
+
coordinateEndIndex: state.index,
|
|
171
|
+
coordinateStartIndex,
|
|
172
|
+
reference: {
|
|
173
|
+
...reference,
|
|
174
|
+
sheetName,
|
|
175
|
+
},
|
|
176
|
+
text: state.value.slice(startIndex, state.index),
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/*
|
|
181
|
+
* Return a parsed column-only range endpoint at the current parser position.
|
|
182
|
+
* Its effective row is always the shared sheet row cap so shorthand such as
|
|
183
|
+
* C3:C automatically follows future increases to that cap.
|
|
184
|
+
*/
|
|
185
|
+
function parseSheetFormulaOpenRowEndReferenceAtState(state: SheetFormulaParserState) {
|
|
186
|
+
const coordinateStartIndex = state.index;
|
|
187
|
+
const match = state.value.slice(state.index).match(/^(\$?)([A-Za-z]+)/);
|
|
188
|
+
if (!match) {
|
|
189
|
+
return null;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
const nextChar = state.value[state.index + match[0].length];
|
|
193
|
+
if (isSheetFormulaIdentifierChar(nextChar)) {
|
|
194
|
+
return null;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
const columnLabel = match[2].toUpperCase();
|
|
198
|
+
state.index += match[0].length;
|
|
199
|
+
|
|
200
|
+
return {
|
|
201
|
+
coordinateEndIndex: state.index,
|
|
202
|
+
coordinateStartIndex,
|
|
203
|
+
endRowOpen: true as const,
|
|
204
|
+
reference: {
|
|
205
|
+
...(match[1] ? { columnAbsolute: true } : {}),
|
|
206
|
+
columnIndex: getSheetFormulaColumnIndex(columnLabel),
|
|
207
|
+
columnLabel,
|
|
208
|
+
rowAbsolute: true,
|
|
209
|
+
rowIndex: SHEET_MAX_ROW_COUNT,
|
|
210
|
+
},
|
|
211
|
+
text: state.value.slice(coordinateStartIndex, state.index),
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/*
|
|
216
|
+
* Return a range reference with ordered corners.
|
|
217
|
+
*/
|
|
218
|
+
function buildSheetFormulaRangeReference(
|
|
219
|
+
start: SheetFormulaCellReference,
|
|
220
|
+
end: SheetFormulaCellReference,
|
|
221
|
+
endRowOpen = false,
|
|
222
|
+
): SheetFormulaRangeReference | null {
|
|
223
|
+
if (start.sheetName && end.sheetName && start.sheetName.toLowerCase() !== end.sheetName.toLowerCase()) {
|
|
224
|
+
return null;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
const startColumnIndex = Math.min(start.columnIndex, end.columnIndex);
|
|
228
|
+
const endColumnIndex = Math.max(start.columnIndex, end.columnIndex);
|
|
229
|
+
const startRowIndex = Math.min(start.rowIndex, end.rowIndex);
|
|
230
|
+
const endRowIndex = Math.max(start.rowIndex, end.rowIndex);
|
|
231
|
+
|
|
232
|
+
return {
|
|
233
|
+
endColumnIndex,
|
|
234
|
+
endColumnLabel: start.columnIndex <= end.columnIndex ? end.columnLabel : start.columnLabel,
|
|
235
|
+
...(endRowOpen ? { endRowOpen: true } : {}),
|
|
236
|
+
endRowIndex,
|
|
237
|
+
sheetName: start.sheetName || end.sheetName || null,
|
|
238
|
+
startColumnIndex,
|
|
239
|
+
startColumnLabel: start.columnIndex <= end.columnIndex ? start.columnLabel : end.columnLabel,
|
|
240
|
+
startRowIndex,
|
|
241
|
+
};
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/*
|
|
245
|
+
* Return a parsed range reference from a complete formula expression.
|
|
246
|
+
*/
|
|
247
|
+
export function parseSheetFormulaRangeReference(value: string): SheetFormulaRangeReference | null {
|
|
248
|
+
const state = {
|
|
249
|
+
index: 0,
|
|
250
|
+
value: value.trim(),
|
|
251
|
+
};
|
|
252
|
+
const start = parseSheetFormulaCellReferenceAtState(state);
|
|
253
|
+
if (!start) {
|
|
254
|
+
return null;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
skipSheetFormulaParserWhitespace(state);
|
|
258
|
+
if (state.value[state.index] !== ':') {
|
|
259
|
+
return null;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
state.index += 1;
|
|
263
|
+
skipSheetFormulaParserWhitespace(state);
|
|
264
|
+
const end = parseSheetFormulaCellReferenceAtState(state) || parseSheetFormulaOpenRowEndReferenceAtState(state);
|
|
265
|
+
if (!end || !isSheetFormulaParserAtEnd(state)) {
|
|
266
|
+
return null;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
return buildSheetFormulaRangeReference(start.reference, end.reference, 'endRowOpen' in end);
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
/*
|
|
273
|
+
* Return a parsed string literal node at the current parser position.
|
|
274
|
+
*/
|
|
275
|
+
function parseSheetFormulaStringNode(state: SheetFormulaParserState): SheetFormulaASTNode | null {
|
|
276
|
+
if (!isSheetFormulaStringQuoteChar(state.value[state.index])) {
|
|
277
|
+
return null;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
const startIndex = state.index;
|
|
281
|
+
const endIndex = getSheetFormulaStringEndIndex(state.value, state.index);
|
|
282
|
+
const text = state.value.slice(startIndex, endIndex);
|
|
283
|
+
const value = parseSheetFormulaStringLiteral(text);
|
|
284
|
+
if (value === null) {
|
|
285
|
+
return null;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
state.index = endIndex;
|
|
289
|
+
return {
|
|
290
|
+
kind: 'STRING_LITERAL',
|
|
291
|
+
text,
|
|
292
|
+
value,
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
/*
|
|
297
|
+
* Return a parsed number literal node at the current parser position.
|
|
298
|
+
*/
|
|
299
|
+
function parseSheetFormulaNumberNode(state: SheetFormulaParserState): SheetFormulaASTNode | null {
|
|
300
|
+
const match = state.value.slice(state.index).match(/^(?:\d+(?:\.\d+)?|\.\d+)/);
|
|
301
|
+
if (!match) {
|
|
302
|
+
return null;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
const nextChar = state.value[state.index + match[0].length];
|
|
306
|
+
if (isSheetFormulaIdentifierChar(nextChar)) {
|
|
307
|
+
return null;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
state.index += match[0].length;
|
|
311
|
+
return {
|
|
312
|
+
kind: 'NUMBER_LITERAL',
|
|
313
|
+
text: match[0],
|
|
314
|
+
value: Number(match[0]),
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
/*
|
|
319
|
+
* Return a parsed comma-separated function argument list.
|
|
320
|
+
*/
|
|
321
|
+
function parseSheetFormulaFunctionArguments(state: SheetFormulaParserState) {
|
|
322
|
+
const args: SheetFormulaASTNode[] = [];
|
|
323
|
+
skipSheetFormulaParserWhitespace(state);
|
|
324
|
+
if (state.value[state.index] === ')') {
|
|
325
|
+
state.index += 1;
|
|
326
|
+
return args;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
while (state.index < state.value.length) {
|
|
330
|
+
const arg = parseSheetFormulaComparisonExpression(state);
|
|
331
|
+
if (!arg) {
|
|
332
|
+
return null;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
args.push(arg);
|
|
336
|
+
skipSheetFormulaParserWhitespace(state);
|
|
337
|
+
const char = state.value[state.index];
|
|
338
|
+
|
|
339
|
+
if (char === ')') {
|
|
340
|
+
state.index += 1;
|
|
341
|
+
return args;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
if (char !== ',') {
|
|
345
|
+
return null;
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
state.index += 1;
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
return null;
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
/*
|
|
355
|
+
* Return a parsed function call node for one already-read function name.
|
|
356
|
+
*/
|
|
357
|
+
function parseSheetFormulaFunctionCallNode(
|
|
358
|
+
state: SheetFormulaParserState,
|
|
359
|
+
name: string,
|
|
360
|
+
startIndex: number,
|
|
361
|
+
): SheetFormulaASTNode | null {
|
|
362
|
+
state.index += 1;
|
|
363
|
+
const args = parseSheetFormulaFunctionArguments(state);
|
|
364
|
+
if (!args) {
|
|
365
|
+
return null;
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
return {
|
|
369
|
+
args,
|
|
370
|
+
kind: 'FUNCTION_CALL',
|
|
371
|
+
name,
|
|
372
|
+
text: state.value.slice(startIndex, state.index).trim(),
|
|
373
|
+
};
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
/*
|
|
377
|
+
* Return a parsed cell or range reference node at the current parser position.
|
|
378
|
+
*/
|
|
379
|
+
function parseSheetFormulaReferenceNode(state: SheetFormulaParserState): SheetFormulaASTNode | null {
|
|
380
|
+
const startIndex = state.index;
|
|
381
|
+
const start = parseSheetFormulaCellReferenceAtState(state);
|
|
382
|
+
if (!start) {
|
|
383
|
+
return null;
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
skipSheetFormulaParserWhitespace(state);
|
|
387
|
+
if (state.value[state.index] !== ':') {
|
|
388
|
+
return {
|
|
389
|
+
kind: 'CELL_REFERENCE',
|
|
390
|
+
reference: start.reference,
|
|
391
|
+
text: start.text,
|
|
392
|
+
};
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
state.index += 1;
|
|
396
|
+
skipSheetFormulaParserWhitespace(state);
|
|
397
|
+
const end = parseSheetFormulaCellReferenceAtState(state) || parseSheetFormulaOpenRowEndReferenceAtState(state);
|
|
398
|
+
if (!end) {
|
|
399
|
+
state.index = startIndex;
|
|
400
|
+
return null;
|
|
401
|
+
}
|
|
402
|
+
const reference = buildSheetFormulaRangeReference(start.reference, end.reference, 'endRowOpen' in end);
|
|
403
|
+
if (!reference) {
|
|
404
|
+
state.index = startIndex;
|
|
405
|
+
return null;
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
return {
|
|
409
|
+
kind: 'RANGE_REFERENCE',
|
|
410
|
+
reference,
|
|
411
|
+
text: state.value.slice(startIndex, state.index).trim(),
|
|
412
|
+
};
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
/*
|
|
416
|
+
* Return a parsed identifier-backed node such as a boolean, function call, or reference.
|
|
417
|
+
*/
|
|
418
|
+
function parseSheetFormulaIdentifierNode(state: SheetFormulaParserState): SheetFormulaASTNode | null {
|
|
419
|
+
const startIndex = state.index;
|
|
420
|
+
const name = parseSheetFormulaIdentifierName(state);
|
|
421
|
+
if (!name) {
|
|
422
|
+
return null;
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
skipSheetFormulaParserWhitespace(state);
|
|
426
|
+
if (state.value[state.index] === '(') {
|
|
427
|
+
return parseSheetFormulaFunctionCallNode(state, name, startIndex);
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
if (/^(?:true|false)$/i.test(name)) {
|
|
431
|
+
return {
|
|
432
|
+
kind: 'BOOLEAN_LITERAL',
|
|
433
|
+
text: name,
|
|
434
|
+
value: /^true$/i.test(name),
|
|
435
|
+
};
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
return null;
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
/*
|
|
442
|
+
* Return a parsed error literal node such as #REF! (case-insensitive) at the
|
|
443
|
+
* current parser position.
|
|
444
|
+
*/
|
|
445
|
+
function parseSheetFormulaErrorLiteralNode(state: SheetFormulaParserState): SheetFormulaASTNode | null {
|
|
446
|
+
if (state.value[state.index] !== '#') {
|
|
447
|
+
return null;
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
const match = state.value.slice(state.index).match(/^#[A-Za-z]+!/);
|
|
451
|
+
const code = match ? FILE_CONSTANTS.errorLiteralCodes[match[0].toUpperCase()] : null;
|
|
452
|
+
if (!match || !code || isSheetFormulaIdentifierChar(state.value[state.index + match[0].length])) {
|
|
453
|
+
return null;
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
state.index += match[0].length;
|
|
457
|
+
return {
|
|
458
|
+
code,
|
|
459
|
+
kind: 'ERROR_LITERAL',
|
|
460
|
+
text: match[0].toUpperCase(),
|
|
461
|
+
};
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
/*
|
|
465
|
+
* Return a parsed grouped or atomic formula expression.
|
|
466
|
+
*/
|
|
467
|
+
function parseSheetFormulaPrimaryExpression(state: SheetFormulaParserState): SheetFormulaASTNode | null {
|
|
468
|
+
skipSheetFormulaParserWhitespace(state);
|
|
469
|
+
const startIndex = state.index;
|
|
470
|
+
|
|
471
|
+
if (state.value[state.index] === '(') {
|
|
472
|
+
state.index += 1;
|
|
473
|
+
const node = parseSheetFormulaComparisonExpression(state);
|
|
474
|
+
skipSheetFormulaParserWhitespace(state);
|
|
475
|
+
if (!node || state.value[state.index] !== ')') {
|
|
476
|
+
return null;
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
state.index += 1;
|
|
480
|
+
return {
|
|
481
|
+
...node,
|
|
482
|
+
text: state.value.slice(startIndex, state.index).trim(),
|
|
483
|
+
};
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
return (
|
|
487
|
+
parseSheetFormulaErrorLiteralNode(state) ||
|
|
488
|
+
parseSheetFormulaReferenceNode(state) ||
|
|
489
|
+
parseSheetFormulaStringNode(state) ||
|
|
490
|
+
parseSheetFormulaNumberNode(state) ||
|
|
491
|
+
parseSheetFormulaIdentifierNode(state)
|
|
492
|
+
);
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
/*
|
|
496
|
+
* Return a parsed unary formula expression.
|
|
497
|
+
*/
|
|
498
|
+
function parseSheetFormulaUnaryExpression(state: SheetFormulaParserState): SheetFormulaASTNode | null {
|
|
499
|
+
skipSheetFormulaParserWhitespace(state);
|
|
500
|
+
const startIndex = state.index;
|
|
501
|
+
const operator = state.value[state.index];
|
|
502
|
+
if (operator === '+' || operator === '-') {
|
|
503
|
+
state.index += 1;
|
|
504
|
+
const value = parseSheetFormulaUnaryExpression(state);
|
|
505
|
+
if (!value) {
|
|
506
|
+
return null;
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
return {
|
|
510
|
+
kind: 'UNARY_EXPRESSION',
|
|
511
|
+
operator,
|
|
512
|
+
text: state.value.slice(startIndex, state.index).trim(),
|
|
513
|
+
value,
|
|
514
|
+
};
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
return parseSheetFormulaPrimaryExpression(state);
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
/*
|
|
521
|
+
* Return a parsed left-associative binary expression for the provided operators.
|
|
522
|
+
*/
|
|
523
|
+
function parseSheetFormulaBinaryExpression(
|
|
524
|
+
state: SheetFormulaParserState,
|
|
525
|
+
parseOperand: (state: SheetFormulaParserState) => SheetFormulaASTNode | null,
|
|
526
|
+
operators: readonly SheetFormulaBinaryOperator[],
|
|
527
|
+
) {
|
|
528
|
+
let left = parseOperand(state);
|
|
529
|
+
if (!left) {
|
|
530
|
+
return null;
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
while (state.index < state.value.length) {
|
|
534
|
+
skipSheetFormulaParserWhitespace(state);
|
|
535
|
+
const operator = operators.find((candidate) => state.value.slice(state.index).startsWith(candidate));
|
|
536
|
+
if (!operator) {
|
|
537
|
+
break;
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
const startIndex = state.index;
|
|
541
|
+
state.index += operator.length;
|
|
542
|
+
const right = parseOperand(state);
|
|
543
|
+
if (!right) {
|
|
544
|
+
state.index = startIndex;
|
|
545
|
+
return null;
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
left = {
|
|
549
|
+
kind: 'BINARY_EXPRESSION',
|
|
550
|
+
left,
|
|
551
|
+
operator,
|
|
552
|
+
right,
|
|
553
|
+
text: `${left.text}${operator}${right.text}`,
|
|
554
|
+
};
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
return left;
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
/*
|
|
561
|
+
* Return a parsed power formula expression. ^ is left-associative and binds
|
|
562
|
+
* looser than unary minus, as in Excel and Sheets: 2^3^2 = 64, -2^2 = 4.
|
|
563
|
+
*/
|
|
564
|
+
function parseSheetFormulaPowerExpressionNode(state: SheetFormulaParserState) {
|
|
565
|
+
return parseSheetFormulaBinaryExpression(state, parseSheetFormulaUnaryExpression, ['^'] as const);
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
/*
|
|
569
|
+
* Return a parsed multiplicative formula expression.
|
|
570
|
+
*/
|
|
571
|
+
function parseSheetFormulaMultiplicativeExpressionNode(state: SheetFormulaParserState) {
|
|
572
|
+
return parseSheetFormulaBinaryExpression(state, parseSheetFormulaPowerExpressionNode, ['*', '/'] as const);
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
/*
|
|
576
|
+
* Return a parsed additive formula expression.
|
|
577
|
+
*/
|
|
578
|
+
function parseSheetFormulaAdditiveExpressionNode(state: SheetFormulaParserState) {
|
|
579
|
+
return parseSheetFormulaBinaryExpression(state, parseSheetFormulaMultiplicativeExpressionNode, ['+', '-'] as const);
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
/*
|
|
583
|
+
* Return a parsed text concatenation (&) formula expression. It binds looser
|
|
584
|
+
* than + and - and tighter than comparisons: 1+2&3 = "33".
|
|
585
|
+
*/
|
|
586
|
+
function parseSheetFormulaConcatenationExpressionNode(state: SheetFormulaParserState) {
|
|
587
|
+
return parseSheetFormulaBinaryExpression(state, parseSheetFormulaAdditiveExpressionNode, ['&'] as const);
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
/*
|
|
591
|
+
* Return a parsed comparison formula expression.
|
|
592
|
+
*/
|
|
593
|
+
function parseSheetFormulaComparisonExpression(state: SheetFormulaParserState): SheetFormulaASTNode | null {
|
|
594
|
+
return parseSheetFormulaBinaryExpression(state, parseSheetFormulaConcatenationExpressionNode, [
|
|
595
|
+
'<=',
|
|
596
|
+
'>=',
|
|
597
|
+
'<>',
|
|
598
|
+
'!=',
|
|
599
|
+
'=',
|
|
600
|
+
'<',
|
|
601
|
+
'>',
|
|
602
|
+
] as const);
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
/*
|
|
606
|
+
* Parse one full formula expression into an AST node.
|
|
607
|
+
*/
|
|
608
|
+
export function parseSheetFormulaExpression(value: string): SheetFormulaASTNode | null {
|
|
609
|
+
const state = {
|
|
610
|
+
index: 0,
|
|
611
|
+
value: value.trim(),
|
|
612
|
+
};
|
|
613
|
+
const node = parseSheetFormulaComparisonExpression(state);
|
|
614
|
+
|
|
615
|
+
return node && isSheetFormulaParserAtEnd(state)
|
|
616
|
+
? {
|
|
617
|
+
...node,
|
|
618
|
+
text: getSheetFormulaParserSpanText(state, 0),
|
|
619
|
+
}
|
|
620
|
+
: null;
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
/*
|
|
624
|
+
* Return a concise syntax error message that points at the unsupported formula parts.
|
|
625
|
+
*/
|
|
626
|
+
export function getSheetFormulaSyntaxErrorMessage(value: string) {
|
|
627
|
+
const trimmed = value.trim();
|
|
628
|
+
|
|
629
|
+
const state = {
|
|
630
|
+
index: 0,
|
|
631
|
+
value: trimmed,
|
|
632
|
+
};
|
|
633
|
+
const node = parseSheetFormulaComparisonExpression(state);
|
|
634
|
+
if (node) {
|
|
635
|
+
skipSheetFormulaParserWhitespace(state);
|
|
636
|
+
const unsupportedText = trimmed.slice(state.index).trim();
|
|
637
|
+
if (unsupportedText) {
|
|
638
|
+
return `Formula syntax is not supported. Unsupported part: ${unsupportedText}`;
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
return 'Formula syntax is not supported.';
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
/*
|
|
646
|
+
* Return one complete qualified or unqualified cell/range token at a formula
|
|
647
|
+
* text index. Coordinate spans are retained separately so rewriters can keep
|
|
648
|
+
* the user's exact sheet-name quoting and whitespace.
|
|
649
|
+
*/
|
|
650
|
+
function getSheetFormulaDirectReferenceTokenAtIndex(value: string, startIndex: number): SheetFormulaReferenceToken | null {
|
|
651
|
+
const state = { index: startIndex, value };
|
|
652
|
+
const start = parseSheetFormulaCellReferenceAtState(state);
|
|
653
|
+
if (!start) {
|
|
654
|
+
return null;
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
const afterStartIndex = state.index;
|
|
658
|
+
skipSheetFormulaParserWhitespace(state);
|
|
659
|
+
if (value[state.index] !== ':') {
|
|
660
|
+
return {
|
|
661
|
+
...start.reference,
|
|
662
|
+
coordinateEndIndex: start.coordinateEndIndex,
|
|
663
|
+
coordinateStartIndex: start.coordinateStartIndex,
|
|
664
|
+
endIndex: afterStartIndex,
|
|
665
|
+
kind: 'SHEET_CELL',
|
|
666
|
+
startIndex,
|
|
667
|
+
text: value.slice(startIndex, afterStartIndex),
|
|
668
|
+
};
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
state.index += 1;
|
|
672
|
+
skipSheetFormulaParserWhitespace(state);
|
|
673
|
+
const end = parseSheetFormulaCellReferenceAtState(state) || parseSheetFormulaOpenRowEndReferenceAtState(state);
|
|
674
|
+
if (!end) {
|
|
675
|
+
return null;
|
|
676
|
+
}
|
|
677
|
+
const rangeReference = buildSheetFormulaRangeReference(start.reference, end.reference, 'endRowOpen' in end);
|
|
678
|
+
if (!rangeReference) {
|
|
679
|
+
return null;
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
return {
|
|
683
|
+
...rangeReference,
|
|
684
|
+
endReference: end.reference,
|
|
685
|
+
endReferenceCoordinateEndIndex: end.coordinateEndIndex,
|
|
686
|
+
endReferenceCoordinateStartIndex: end.coordinateStartIndex,
|
|
687
|
+
endIndex: state.index,
|
|
688
|
+
kind: 'SHEET_RANGE',
|
|
689
|
+
startReference: start.reference,
|
|
690
|
+
startReferenceCoordinateEndIndex: start.coordinateEndIndex,
|
|
691
|
+
startReferenceCoordinateStartIndex: start.coordinateStartIndex,
|
|
692
|
+
startIndex,
|
|
693
|
+
text: value.slice(startIndex, state.index),
|
|
694
|
+
};
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
/*
|
|
698
|
+
* Return reference tokens from formula text for live client highlighting.
|
|
699
|
+
*/
|
|
700
|
+
export function tokenizeSheetFormulaReferences(value: string): SheetFormulaReferenceToken[] {
|
|
701
|
+
const tokens: SheetFormulaReferenceToken[] = [];
|
|
702
|
+
let index = 0;
|
|
703
|
+
|
|
704
|
+
while (index < value.length) {
|
|
705
|
+
const char = value[index];
|
|
706
|
+
const quotedReferenceToken = char === "'" ? getSheetFormulaDirectReferenceTokenAtIndex(value, index) : null;
|
|
707
|
+
|
|
708
|
+
if (isSheetFormulaStringQuoteChar(char) && !quotedReferenceToken) {
|
|
709
|
+
index = getSheetFormulaStringEndIndex(value, index);
|
|
710
|
+
continue;
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
if (isSheetFormulaIdentifierChar(value[index - 1])) {
|
|
714
|
+
index += 1;
|
|
715
|
+
continue;
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
const directToken = quotedReferenceToken || getSheetFormulaDirectReferenceTokenAtIndex(value, index);
|
|
719
|
+
if (directToken) {
|
|
720
|
+
tokens.push(directToken);
|
|
721
|
+
index = directToken.endIndex;
|
|
722
|
+
continue;
|
|
723
|
+
}
|
|
724
|
+
|
|
725
|
+
index += 1;
|
|
726
|
+
}
|
|
727
|
+
|
|
728
|
+
return tokens;
|
|
729
|
+
}
|