@jesscss/css-parser 1.0.8-alpha.6 → 2.0.0-alpha.1
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/lib/advancedActionsParser.d.ts +60 -0
- package/lib/advancedActionsParser.js +203 -0
- package/lib/advancedActionsParser.js.map +1 -0
- package/lib/cssActionsParser.d.ts +155 -0
- package/lib/cssActionsParser.js +376 -0
- package/lib/cssActionsParser.js.map +1 -0
- package/lib/cssErrorMessageProvider.d.ts +14 -0
- package/lib/cssErrorMessageProvider.js +40 -0
- package/lib/cssErrorMessageProvider.js.map +1 -0
- package/lib/cssParser.d.ts +36 -103
- package/lib/cssParser.js +75 -58
- package/lib/cssParser.js.map +1 -0
- package/lib/cssTokens.d.ts +539 -5
- package/lib/cssTokens.js +488 -232
- package/lib/cssTokens.js.map +1 -0
- package/lib/index.d.ts +8 -16
- package/lib/index.js +9 -41
- package/lib/index.js.map +1 -0
- package/lib/productions.d.ts +273 -0
- package/lib/productions.js +3499 -0
- package/lib/productions.js.map +1 -0
- package/lib/test/ast-serialize.test.d.ts +1 -0
- package/lib/test/ast-serialize.test.js +157 -0
- package/lib/test/ast-serialize.test.js.map +1 -0
- package/lib/test/container.test.d.ts +1 -0
- package/lib/test/container.test.js +369 -0
- package/lib/test/container.test.js.map +1 -0
- package/lib/test/css-files.test.d.ts +1 -0
- package/lib/test/css-files.test.js +21 -0
- package/lib/test/css-files.test.js.map +1 -0
- package/lib/test/less-output.test.d.ts +1 -0
- package/lib/test/less-output.test.js +52 -0
- package/lib/test/less-output.test.js.map +1 -0
- package/lib/util/cst.d.ts +7 -2
- package/lib/util/cst.js +5 -9
- package/lib/util/cst.js.map +1 -0
- package/lib/util/index.d.ts +19 -13
- package/lib/util/index.js +98 -87
- package/lib/util/index.js.map +1 -0
- package/package.json +43 -20
- package/lib/productions/atRules.d.ts +0 -2
- package/lib/productions/atRules.js +0 -196
- package/lib/productions/blocks.d.ts +0 -2
- package/lib/productions/blocks.js +0 -181
- package/lib/productions/declarations.d.ts +0 -14
- package/lib/productions/declarations.js +0 -59
- package/lib/productions/root.d.ts +0 -2
- package/lib/productions/root.js +0 -49
- package/lib/productions/selectors.d.ts +0 -2
- package/lib/productions/selectors.js +0 -231
- package/lib/productions/values.d.ts +0 -2
- package/lib/productions/values.js +0 -114
|
@@ -0,0 +1,376 @@
|
|
|
1
|
+
import { tokenMatcher } from 'chevrotain';
|
|
2
|
+
// import { AdvancedCstParser } from './advancedCstParser'
|
|
3
|
+
import { LLStarLookaheadStrategy } from 'chevrotain-allstar';
|
|
4
|
+
import { AdvancedActionsParser } from './advancedActionsParser.js';
|
|
5
|
+
import * as productions from './productions.js';
|
|
6
|
+
import { Node, Comment, F_VISIBLE, Color, ColorFormat, Dimension, Num, Rules, Any } from '@jesscss/core';
|
|
7
|
+
import colors from 'color-name';
|
|
8
|
+
const { isArray } = Array;
|
|
9
|
+
/**
|
|
10
|
+
* @note - we use an EmbeddedActionsParser for a few reasons:
|
|
11
|
+
* 1. Jess's AST is essentially a CST; that is, it records
|
|
12
|
+
* all whitespace and comments. (The one difference may
|
|
13
|
+
* be that some nodes are "simplified" in the Jess AST.)
|
|
14
|
+
* 2. Chevrotain's CST is not the most efficient structure
|
|
15
|
+
* for a CST.
|
|
16
|
+
* 3. We can avoid the overhead of a CST visitor by creating
|
|
17
|
+
* the Jess nodes directly.
|
|
18
|
+
* 4. In some cases, we need some additional business logic
|
|
19
|
+
* about what the intended structure of the AST is, based
|
|
20
|
+
* on the presence of certain tokens.
|
|
21
|
+
*/
|
|
22
|
+
export class CssActionsParser extends AdvancedActionsParser {
|
|
23
|
+
T;
|
|
24
|
+
legacyMode;
|
|
25
|
+
ruleIndex = 0;
|
|
26
|
+
/** Rewire, declaring class fields in constructor with `public` */
|
|
27
|
+
stylesheet;
|
|
28
|
+
main;
|
|
29
|
+
qualifiedRule;
|
|
30
|
+
atRule;
|
|
31
|
+
selectorList;
|
|
32
|
+
declarationList;
|
|
33
|
+
forgivingSelectorList;
|
|
34
|
+
classSelector;
|
|
35
|
+
idSelector;
|
|
36
|
+
pseudoSelector;
|
|
37
|
+
attributeSelector;
|
|
38
|
+
nthValue;
|
|
39
|
+
complexSelector;
|
|
40
|
+
simpleSelector;
|
|
41
|
+
compoundSelector;
|
|
42
|
+
relativeSelector;
|
|
43
|
+
declaration;
|
|
44
|
+
valueList;
|
|
45
|
+
/** Often a space-separated sequence */
|
|
46
|
+
valueSequence;
|
|
47
|
+
value;
|
|
48
|
+
squareValue;
|
|
49
|
+
customValue;
|
|
50
|
+
innerCustomValue;
|
|
51
|
+
functionCall;
|
|
52
|
+
functionCallLike;
|
|
53
|
+
functionCallArgs;
|
|
54
|
+
ifFunction;
|
|
55
|
+
ifFunctionArgs;
|
|
56
|
+
knownFunctions;
|
|
57
|
+
varFunction;
|
|
58
|
+
calcFunction;
|
|
59
|
+
urlFunction;
|
|
60
|
+
unknownValue;
|
|
61
|
+
string;
|
|
62
|
+
// expression: Rule
|
|
63
|
+
// calc()
|
|
64
|
+
mathSum;
|
|
65
|
+
mathProduct;
|
|
66
|
+
mathValue;
|
|
67
|
+
mathParen;
|
|
68
|
+
/** At Rules */
|
|
69
|
+
innerAtRule;
|
|
70
|
+
importAtRule;
|
|
71
|
+
importPrelude;
|
|
72
|
+
importPostlude;
|
|
73
|
+
mediaAtRule;
|
|
74
|
+
supportsAtRule;
|
|
75
|
+
containerAtRule;
|
|
76
|
+
containerName;
|
|
77
|
+
containerQueryList;
|
|
78
|
+
containerQuery;
|
|
79
|
+
containerCondition;
|
|
80
|
+
containerInParens;
|
|
81
|
+
containerFeature;
|
|
82
|
+
containerAnd;
|
|
83
|
+
containerOr;
|
|
84
|
+
atRuleBody;
|
|
85
|
+
pageAtRule;
|
|
86
|
+
keyframesAtRule;
|
|
87
|
+
keyframesName;
|
|
88
|
+
layerAtRule;
|
|
89
|
+
layerName;
|
|
90
|
+
scopeAtRule;
|
|
91
|
+
documentAtRule;
|
|
92
|
+
pageSelector;
|
|
93
|
+
fontFaceAtRule;
|
|
94
|
+
nestedAtRule;
|
|
95
|
+
nonNestedAtRule;
|
|
96
|
+
unknownAtRule;
|
|
97
|
+
/** `@media` syntax */
|
|
98
|
+
mediaQueryList;
|
|
99
|
+
mediaQuery;
|
|
100
|
+
mediaCondition;
|
|
101
|
+
mediaType;
|
|
102
|
+
mediaConditionWithoutOr;
|
|
103
|
+
mediaNot;
|
|
104
|
+
mediaInParens;
|
|
105
|
+
mediaAnd;
|
|
106
|
+
mediaOr;
|
|
107
|
+
mediaFeature;
|
|
108
|
+
mfValue;
|
|
109
|
+
mediaRange;
|
|
110
|
+
mfComparison;
|
|
111
|
+
mfNonIdentifierValue;
|
|
112
|
+
/** `@container` syntax - declarations are above */
|
|
113
|
+
/**
|
|
114
|
+
* `@supports` syntax - the parsing is defined differently
|
|
115
|
+
* from `@media`, which is fortunate, because it's much
|
|
116
|
+
* simpler.
|
|
117
|
+
*/
|
|
118
|
+
supportsCondition;
|
|
119
|
+
supportsInParens;
|
|
120
|
+
/** General purpose subrules */
|
|
121
|
+
anyOuterValue;
|
|
122
|
+
anyInnerValue;
|
|
123
|
+
extraTokens;
|
|
124
|
+
customBlock;
|
|
125
|
+
constructor(tokenVocabulary, T, config = {}) {
|
|
126
|
+
const defaultConfig = {
|
|
127
|
+
maxLookahead: 1,
|
|
128
|
+
lookaheadStrategy: new LLStarLookaheadStrategy({
|
|
129
|
+
// suppress ambiguity logging
|
|
130
|
+
// logging() {}
|
|
131
|
+
})
|
|
132
|
+
};
|
|
133
|
+
const { legacyMode = true, ...rest } = { ...defaultConfig, ...config };
|
|
134
|
+
super(tokenVocabulary, rest);
|
|
135
|
+
this.T = T;
|
|
136
|
+
this.legacyMode = legacyMode;
|
|
137
|
+
for (let [key, value] of Object.entries(productions)) {
|
|
138
|
+
let rule = value.call(this, T);
|
|
139
|
+
this.RULE(key, rule);
|
|
140
|
+
}
|
|
141
|
+
if (this.constructor === CssActionsParser) {
|
|
142
|
+
this.performSelfAnalysis();
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
set input(value) {
|
|
146
|
+
this.ruleIndex = 0;
|
|
147
|
+
super.input = value;
|
|
148
|
+
}
|
|
149
|
+
getLocationFromNodes(nodes) {
|
|
150
|
+
let startNode = nodes[0];
|
|
151
|
+
let lastNode = nodes[nodes.length - 1];
|
|
152
|
+
let startOffset;
|
|
153
|
+
let startLine;
|
|
154
|
+
let startColumn;
|
|
155
|
+
let endOffset;
|
|
156
|
+
let endLine;
|
|
157
|
+
let endColumn;
|
|
158
|
+
if (startNode === undefined) {
|
|
159
|
+
return undefined;
|
|
160
|
+
}
|
|
161
|
+
if (startNode instanceof Node) {
|
|
162
|
+
([startOffset, startLine, startColumn] = startNode.location);
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
({ startOffset, startLine, startColumn } = startNode);
|
|
166
|
+
}
|
|
167
|
+
if (lastNode instanceof Node) {
|
|
168
|
+
([, , , endOffset, endLine, endColumn] = lastNode.location);
|
|
169
|
+
}
|
|
170
|
+
else {
|
|
171
|
+
({ endOffset, endLine, endColumn } = lastNode);
|
|
172
|
+
}
|
|
173
|
+
if (startOffset === undefined) {
|
|
174
|
+
throw new Error(`Node "${startNode instanceof Node ? startNode.type : startNode.tokenType.name}" has no location info`);
|
|
175
|
+
}
|
|
176
|
+
else if (endOffset === undefined) {
|
|
177
|
+
throw new Error(`Node "${lastNode instanceof Node ? lastNode.type : lastNode.tokenType.name}" has no location info`);
|
|
178
|
+
}
|
|
179
|
+
let location = [startOffset, startLine, startColumn, endOffset, endLine, endColumn];
|
|
180
|
+
return location;
|
|
181
|
+
}
|
|
182
|
+
getRulesWithComments(existingRules = [], nextTokenLocation) {
|
|
183
|
+
if (!nextTokenLocation) {
|
|
184
|
+
nextTokenLocation = this.getLocationInfo(this.LA(1));
|
|
185
|
+
}
|
|
186
|
+
let rules = [];
|
|
187
|
+
/**
|
|
188
|
+
* @todo - I think this pattern means that comments after
|
|
189
|
+
* the last rule will be tossed out, so we need to figure
|
|
190
|
+
* out a way to get comments when comments are the only
|
|
191
|
+
* content in a file.
|
|
192
|
+
*/
|
|
193
|
+
// let rule: Node | undefined
|
|
194
|
+
const processPrePost = (prePost) => {
|
|
195
|
+
if (isArray(prePost)) {
|
|
196
|
+
// Build a new remainder array while moving comment nodes to top-level rules
|
|
197
|
+
const remainder = [];
|
|
198
|
+
for (let i = 0; i < prePost.length; i++) {
|
|
199
|
+
const item = prePost[i];
|
|
200
|
+
if (item instanceof Node) {
|
|
201
|
+
// Attach immediately preceding whitespace (if any) to the comment
|
|
202
|
+
const prev = remainder.length > 0 ? remainder[remainder.length - 1] : undefined;
|
|
203
|
+
if (typeof prev === 'string') {
|
|
204
|
+
item.pre = [prev];
|
|
205
|
+
remainder.pop();
|
|
206
|
+
}
|
|
207
|
+
// Attach immediately following whitespace (if any) to comment.post
|
|
208
|
+
const next = prePost[i + 1];
|
|
209
|
+
if (typeof next === 'string') {
|
|
210
|
+
item.post = [next];
|
|
211
|
+
i++; // consume the following whitespace
|
|
212
|
+
}
|
|
213
|
+
rules.push(item);
|
|
214
|
+
}
|
|
215
|
+
else {
|
|
216
|
+
remainder.push(item);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
return remainder.length === 0 ? 0 : remainder;
|
|
220
|
+
}
|
|
221
|
+
return prePost;
|
|
222
|
+
};
|
|
223
|
+
for (let rule of existingRules) {
|
|
224
|
+
if (rule.pre === undefined) {
|
|
225
|
+
let pre = this.getPrePost(rule.location[0]);
|
|
226
|
+
const processed = processPrePost(pre);
|
|
227
|
+
rule.pre = processed;
|
|
228
|
+
}
|
|
229
|
+
rules.push(rule);
|
|
230
|
+
}
|
|
231
|
+
// Do not mutate lastRule.post here; lift only at tail capture time to avoid duplication/newlines.
|
|
232
|
+
// Then capture any remaining EOF tail via preSkipped at LA(1).startOffset.
|
|
233
|
+
const tail = this.getPrePost(nextTokenLocation[0]);
|
|
234
|
+
const remainder = processPrePost(tail);
|
|
235
|
+
let returnRules = new Rules(rules, undefined, rules.length ? this.getLocationFromNodes(rules) : undefined, this.context);
|
|
236
|
+
returnRules.post = remainder;
|
|
237
|
+
return returnRules;
|
|
238
|
+
}
|
|
239
|
+
getPrePost(offset, post, ctx) {
|
|
240
|
+
let skipped = post ? this.postSkippedTokenMap.get(offset) : this.preSkippedTokenMap.get(offset);
|
|
241
|
+
if (!skipped) {
|
|
242
|
+
return 0;
|
|
243
|
+
}
|
|
244
|
+
if (this.usedSkippedTokens.has(skipped)) {
|
|
245
|
+
return 0;
|
|
246
|
+
}
|
|
247
|
+
this.usedSkippedTokens.add(skipped);
|
|
248
|
+
let pre = skipped.map((token) => {
|
|
249
|
+
let name = token.tokenType.name;
|
|
250
|
+
if (name === 'WS') {
|
|
251
|
+
return token.image;
|
|
252
|
+
}
|
|
253
|
+
else {
|
|
254
|
+
const comment = new Comment(token.image, { lineComment: name.includes('Line') }, this.getLocationInfo(token), this.context);
|
|
255
|
+
if (ctx?.inCustomPropertyValue && comment.options.lineComment) {
|
|
256
|
+
comment.addFlag(F_VISIBLE);
|
|
257
|
+
}
|
|
258
|
+
return comment;
|
|
259
|
+
}
|
|
260
|
+
});
|
|
261
|
+
if (pre.length === 1 && pre[0] === ' ') {
|
|
262
|
+
pre = 1;
|
|
263
|
+
}
|
|
264
|
+
return pre;
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* Attaches pre / post whitespace and comments.
|
|
268
|
+
* Note that nodes can be wrapped more than once.
|
|
269
|
+
*
|
|
270
|
+
* @note Some nodes can't be wrapped because they
|
|
271
|
+
* don't represent a location. For instance, a
|
|
272
|
+
* Rules node may be empty, and hence doesn't
|
|
273
|
+
* have a location.
|
|
274
|
+
*/
|
|
275
|
+
wrap(node, post, ctx) {
|
|
276
|
+
if (!(node instanceof Node)) {
|
|
277
|
+
return node;
|
|
278
|
+
}
|
|
279
|
+
// let skipValidations = this.skipValidations
|
|
280
|
+
if (post) {
|
|
281
|
+
if (node.post === undefined) {
|
|
282
|
+
let offset = node.location[3];
|
|
283
|
+
if (offset !== undefined) {
|
|
284
|
+
node.post = this.getPrePost(offset, true, ctx);
|
|
285
|
+
// throw new Error(`Node "${node.type}" can't be wrapped`)
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
if (post !== 'both') {
|
|
289
|
+
return node;
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
if ((!post || post === 'both')) {
|
|
293
|
+
// Always record pre for a node, but if it is the leading child
|
|
294
|
+
// of a parent that will itself own pre (e.g., first selector in a qualified rule),
|
|
295
|
+
// allow callers to reassign this pre to the parent Rules/Ruleset.
|
|
296
|
+
let offset = node.location[0];
|
|
297
|
+
if (offset !== undefined && node.pre === undefined) {
|
|
298
|
+
const pre = this.getPrePost(offset, false, ctx);
|
|
299
|
+
// Narrow to allowed type: Array<Comment | Nil | string> | 1 | 0 | undefined
|
|
300
|
+
node.pre = pre;
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
return node;
|
|
304
|
+
}
|
|
305
|
+
processValueToken(token, _ctx) {
|
|
306
|
+
let tokValue = token.image;
|
|
307
|
+
let tokType = token.tokenType;
|
|
308
|
+
let tokName = tokType.name;
|
|
309
|
+
let T = this.T;
|
|
310
|
+
let dimValue;
|
|
311
|
+
let numValue;
|
|
312
|
+
const getDimension = (finalValue) => new Dimension(finalValue, undefined, this.getLocationInfo(token), this.context);
|
|
313
|
+
const getNumber = (finalValue) => new Num(finalValue, undefined, this.getLocationInfo(token), this.context);
|
|
314
|
+
let result;
|
|
315
|
+
if (tokenMatcher(token, T.Ident)) {
|
|
316
|
+
// Check if it's a color keyword
|
|
317
|
+
const colorKey = tokValue.toLowerCase();
|
|
318
|
+
if (colorKey === 'transparent') {
|
|
319
|
+
result = new Color({
|
|
320
|
+
node: 'transparent',
|
|
321
|
+
rgb: [0, 0, 0],
|
|
322
|
+
alpha: 0
|
|
323
|
+
}, { format: ColorFormat.HEX }, this.getLocationInfo(token), this.context);
|
|
324
|
+
}
|
|
325
|
+
else if (colors[colorKey]) {
|
|
326
|
+
// Create a Color node with the keyword data
|
|
327
|
+
const colorValue = colors[colorKey];
|
|
328
|
+
const colorNode = new Color({
|
|
329
|
+
node: tokValue, // Store the original keyword string
|
|
330
|
+
rgb: colorValue,
|
|
331
|
+
alpha: 1
|
|
332
|
+
}, { format: ColorFormat.HEX }, this.getLocationInfo(token), this.context);
|
|
333
|
+
result = colorNode;
|
|
334
|
+
}
|
|
335
|
+
else {
|
|
336
|
+
// In value position, treat as a generic identifier
|
|
337
|
+
result = new Any(tokValue, { role: 'ident' }, this.getLocationInfo(token), this.context);
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
else if (tokenMatcher(token, T.Dimension)) {
|
|
341
|
+
dimValue = { number: parseFloat(token.payload[0]), unit: token.payload[1] };
|
|
342
|
+
result = getDimension(dimValue);
|
|
343
|
+
}
|
|
344
|
+
else if (tokName === 'MathConstant') {
|
|
345
|
+
switch (tokValue.toLowerCase()) {
|
|
346
|
+
case 'pi':
|
|
347
|
+
numValue = Math.PI;
|
|
348
|
+
break;
|
|
349
|
+
case 'infinity':
|
|
350
|
+
numValue = Infinity;
|
|
351
|
+
break;
|
|
352
|
+
case '-infinity':
|
|
353
|
+
numValue = -Infinity;
|
|
354
|
+
break;
|
|
355
|
+
case 'e':
|
|
356
|
+
numValue = Math.E;
|
|
357
|
+
break;
|
|
358
|
+
case 'nan':
|
|
359
|
+
numValue = NaN;
|
|
360
|
+
}
|
|
361
|
+
result = getNumber(numValue);
|
|
362
|
+
}
|
|
363
|
+
else if (tokenMatcher(token, T.Number)) {
|
|
364
|
+
numValue = parseFloat(tokValue);
|
|
365
|
+
result = getNumber(numValue);
|
|
366
|
+
}
|
|
367
|
+
else if (tokenMatcher(token, T.Color)) {
|
|
368
|
+
result = new Color(tokValue, undefined, this.getLocationInfo(token), this.context);
|
|
369
|
+
}
|
|
370
|
+
else {
|
|
371
|
+
result = new Any(tokValue, { type: token.tokenType.name }, this.getLocationInfo(token), this.context);
|
|
372
|
+
}
|
|
373
|
+
return result;
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
//# sourceMappingURL=cssActionsParser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cssActionsParser.js","sourceRoot":"","sources":["../src/cssActionsParser.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,YAAY,EAEb,MAAM,YAAY,CAAC;AAEpB,0DAA0D;AAC1D,OAAO,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAE7D,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAGnE,OAAO,KAAK,WAAW,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAEL,IAAI,EACJ,OAAO,EACP,SAAS,EACT,KAAK,EACL,WAAW,EACX,SAAS,EACT,GAAG,EACH,KAAK,EACL,GAAG,EAEJ,MAAM,eAAe,CAAC;AACvB,OAAO,MAAM,MAAM,YAAY,CAAC;AAEhC,MAAM,EAAE,OAAO,EAAE,GAAG,KAAK,CAAC;AA6B1B;;;;;;;;;;;;GAYG;AACH,MAAM,OAAO,gBAAiB,SAAQ,qBAAqB;IACzD,CAAC,CAAW;IACZ,UAAU,CAAU;IACpB,SAAS,GAAG,CAAC,CAAC;IAMd,kEAAkE;IAClE,UAAU,CAAiD;IAC3D,IAAI,CAAQ;IACZ,aAAa,CAAQ;IACrB,MAAM,CAAQ;IACd,YAAY,CAAQ;IACpB,eAAe,CAAQ;IACvB,qBAAqB,CAAQ;IAC7B,aAAa,CAAQ;IACrB,UAAU,CAAQ;IAClB,cAAc,CAAQ;IACtB,iBAAiB,CAAQ;IACzB,QAAQ,CAAQ;IAChB,eAAe,CAAQ;IACvB,cAAc,CAAQ;IACtB,gBAAgB,CAAQ;IACxB,gBAAgB,CAAQ;IAExB,WAAW,CAAQ;IACnB,SAAS,CAAQ;IACjB,uCAAuC;IACvC,aAAa,CAAQ;IACrB,KAAK,CAA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AAC,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC;YACzC,QAAQ,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAC;YAChC,MAAM,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;QAC/B,CAAC;aAAM,IAAI,YAAY,CAAC,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC;YACxC,MAAM,GAAG,IAAI,KAAK,CAAC,QAAQ,EAAE,SAAS,EAAE,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;QACrF,CAAC;aAAM,CAAC;YACN,MAAM,GAAG,IAAI,GAAG,CAAC,QAAQ,EAAE,EAAE,IAAI,EAAE,KAAK,CAAC,SAAS,CAAC,IAAI,EAAE,EAAE,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;QACxG,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type IParserErrorMessageProvider } from 'chevrotain';
|
|
2
|
+
export declare class CssErrorMessageProvider implements IParserErrorMessageProvider {
|
|
3
|
+
buildMismatchTokenMessage(options: Parameters<IParserErrorMessageProvider['buildMismatchTokenMessage']>[0]): string;
|
|
4
|
+
buildNotAllInputParsedMessage(options: Parameters<IParserErrorMessageProvider['buildNotAllInputParsedMessage']>[0]): string;
|
|
5
|
+
/**
|
|
6
|
+
* This error message needs to be reduced, because the lookahead strategy
|
|
7
|
+
* can generate thousands of possible paths.
|
|
8
|
+
*
|
|
9
|
+
* @todo - we may be able to eliminate this by addressing all ambiguity in the parser
|
|
10
|
+
* from chevrotain-allstar
|
|
11
|
+
*/
|
|
12
|
+
buildNoViableAltMessage(options: Parameters<IParserErrorMessageProvider['buildNoViableAltMessage']>[0]): string;
|
|
13
|
+
buildEarlyExitMessage(options: Parameters<IParserErrorMessageProvider['buildEarlyExitMessage']>[0]): string;
|
|
14
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { defaultParserErrorProvider } from 'chevrotain';
|
|
2
|
+
const camelToSpaces = (str) => str.replace(/([A-Z])/g, ' $1').toLowerCase();
|
|
3
|
+
export class CssErrorMessageProvider {
|
|
4
|
+
buildMismatchTokenMessage(options) {
|
|
5
|
+
return defaultParserErrorProvider.buildMismatchTokenMessage(options);
|
|
6
|
+
}
|
|
7
|
+
buildNotAllInputParsedMessage(options) {
|
|
8
|
+
return defaultParserErrorProvider.buildNotAllInputParsedMessage(options);
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* This error message needs to be reduced, because the lookahead strategy
|
|
12
|
+
* can generate thousands of possible paths.
|
|
13
|
+
*
|
|
14
|
+
* @todo - we may be able to eliminate this by addressing all ambiguity in the parser
|
|
15
|
+
* from chevrotain-allstar
|
|
16
|
+
*/
|
|
17
|
+
buildNoViableAltMessage(options) {
|
|
18
|
+
const initialTokens = [];
|
|
19
|
+
options.expectedPathsPerAlt.forEach((expectedPath) => {
|
|
20
|
+
expectedPath.forEach((path) => {
|
|
21
|
+
let pathStr = path[0]?.name;
|
|
22
|
+
if (path && !initialTokens.includes(pathStr)) {
|
|
23
|
+
initialTokens.push(pathStr);
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
const firstOfTokens = initialTokens.slice(0, 4);
|
|
28
|
+
const rest = initialTokens.slice(5);
|
|
29
|
+
let err = `Error in ${camelToSpaces(options.ruleName)}: Expected '${firstOfTokens.join(`', '`)}' `;
|
|
30
|
+
if (rest.length > 0) {
|
|
31
|
+
err += `(and ${rest.length} more) `;
|
|
32
|
+
}
|
|
33
|
+
err += `but found '${options.actual[0].image}'`;
|
|
34
|
+
return err;
|
|
35
|
+
}
|
|
36
|
+
buildEarlyExitMessage(options) {
|
|
37
|
+
return `Expected a ${camelToSpaces(options.ruleName)}, but found '${options.actual[0].image}'`;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=cssErrorMessageProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cssErrorMessageProvider.js","sourceRoot":"","sources":["../src/cssErrorMessageProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,0BAA0B,EAC3B,MAAM,YAAY,CAAC;AAEpB,MAAM,aAAa,GAAG,CAAC,GAAW,EAAE,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC,WAAW,EAAE,CAAC;AAEpF,MAAM,OAAO,uBAAuB;IAClC,yBAAyB,CACvB,OAAgF;QAEhF,OAAO,0BAA0B,CAAC,yBAAyB,CAAC,OAAO,CAAC,CAAC;IACvE,CAAC;IAED,6BAA6B,CAC3B,OAAoF;QAEpF,OAAO,0BAA0B,CAAC,6BAA6B,CAAC,OAAO,CAAC,CAAC;IAC3E,CAAC;IAED;;;;;;OAMG;IACH,uBAAuB,CACrB,OAA8E;QAE9E,MAAM,aAAa,GAAa,EAAE,CAAC;QACnC,OAAO,CAAC,mBAAmB,CAAC,OAAO,CAAC,CAAC,YAAY,EAAE,EAAE;YACnD,YAAY,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;gBAC5B,IAAI,OAAO,GAAG,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC;gBAC5B,IAAI,IAAI,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,OAAQ,CAAC,EAAE,CAAC;oBAC9C,aAAa,CAAC,IAAI,CAAC,OAAQ,CAAC,CAAC;gBAC/B,CAAC;YACH,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QACH,MAAM,aAAa,GAAG,aAAa,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QAChD,MAAM,IAAI,GAAG,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QACpC,IAAI,GAAG,GAAG,YAAY,aAAa,CAAC,OAAO,CAAC,QAAQ,CAAC,eAAe,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;QACnG,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACpB,GAAG,IAAI,QAAQ,IAAI,CAAC,MAAM,SAAS,CAAC;QACtC,CAAC;QACD,GAAG,IAAI,cAAc,OAAO,CAAC,MAAM,CAAC,CAAC,CAAE,CAAC,KAAK,GAAG,CAAC;QACjD,OAAO,GAAG,CAAC;IACb,CAAC;IAED,qBAAqB,CACnB,OAA4E;QAE5E,OAAO,cAAc,aAAa,CAAC,OAAO,CAAC,QAAQ,CAAC,gBAAgB,OAAO,CAAC,MAAM,CAAC,CAAC,CAAE,CAAC,KAAK,GAAG,CAAC;IAClG,CAAC;CACF"}
|
package/lib/cssParser.d.ts
CHANGED
|
@@ -1,106 +1,39 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
export
|
|
1
|
+
import { Lexer } from 'chevrotain';
|
|
2
|
+
import { type CssParserConfig, CssActionsParser } from './cssActionsParser.js';
|
|
3
|
+
import type { ConditionalPick } from 'type-fest';
|
|
4
|
+
import { type Node, type Rules, type IParseResult } from '@jesscss/core';
|
|
5
|
+
export type CssRules = keyof ConditionalPick<CssActionsParser, () => Node>;
|
|
6
|
+
export type SyntacticContentAssistSuggestion = {
|
|
7
|
+
nextTokenType: string;
|
|
8
|
+
nextTokenLabel?: string;
|
|
9
|
+
ruleStack: string[];
|
|
10
|
+
occurrenceStack: number[];
|
|
11
|
+
};
|
|
6
12
|
/**
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* ```
|
|
11
|
-
* {
|
|
12
|
-
* name: 'root'
|
|
13
|
-
* children: [
|
|
14
|
-
* {
|
|
15
|
-
* name: 'AtRule',
|
|
16
|
-
* children: [...]
|
|
17
|
-
* location: {...}
|
|
18
|
-
* },
|
|
19
|
-
* {
|
|
20
|
-
* name: 'WS',
|
|
21
|
-
* value: '\n',
|
|
22
|
-
* location: {...}
|
|
23
|
-
* }
|
|
24
|
-
* ]
|
|
25
|
-
* location: {...}
|
|
26
|
-
* }
|
|
27
|
-
* ```
|
|
13
|
+
* If we're not extending the CSS parser,
|
|
14
|
+
* this is the friendlier interface for returning
|
|
15
|
+
* a CST, as it assigns tokens to the parser automatically.
|
|
28
16
|
*/
|
|
29
|
-
export declare
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
rule: Rule;
|
|
52
|
-
atRule: Rule;
|
|
53
|
-
knownAtRule: Rule;
|
|
54
|
-
unknownAtRule: Rule;
|
|
55
|
-
atImport: Rule;
|
|
56
|
-
atMedia: Rule;
|
|
57
|
-
atSupports: Rule;
|
|
58
|
-
atNested: Rule;
|
|
59
|
-
atNonNested: Rule;
|
|
60
|
-
/** @media */
|
|
61
|
-
mediaQueryList: Rule;
|
|
62
|
-
mediaQuery: Rule;
|
|
63
|
-
mediaCondition: Rule;
|
|
64
|
-
mediaFeature: Rule;
|
|
65
|
-
mediaAnd: Rule;
|
|
66
|
-
/** blocks */
|
|
67
|
-
qualifiedRule: Rule;
|
|
68
|
-
testQualifiedRule: Rule;
|
|
69
|
-
testQualifiedRuleExpression: Rule;
|
|
70
|
-
block: Rule;
|
|
71
|
-
curlyBlock: Rule;
|
|
72
|
-
customBlock: Rule;
|
|
73
|
-
customPreludeBlock: Rule;
|
|
74
|
-
/** Selector rules */
|
|
75
|
-
selectorList: Rule;
|
|
76
|
-
complexSelector: Rule;
|
|
77
|
-
combinatorSelector: Rule;
|
|
78
|
-
compoundSelector: Rule;
|
|
79
|
-
simpleSelector: Rule;
|
|
80
|
-
pseudoSelector: Rule;
|
|
81
|
-
attrSelector: Rule;
|
|
82
|
-
attrIdent: Rule;
|
|
83
|
-
nameSelector: Rule;
|
|
84
|
-
/** declarations */
|
|
85
|
-
declaration: Rule;
|
|
86
|
-
customDeclaration: Rule;
|
|
87
|
-
property: Rule;
|
|
88
|
-
customProperty: Rule;
|
|
89
|
-
/** expressions */
|
|
90
|
-
expressionList: Rule;
|
|
91
|
-
expression: Rule;
|
|
92
|
-
/** values */
|
|
93
|
-
value: Rule;
|
|
94
|
-
atomicValue: Rule;
|
|
95
|
-
customValue: Rule;
|
|
96
|
-
customPrelude: Rule;
|
|
97
|
-
customValueOrSemi: Rule;
|
|
98
|
-
anyToken: Rule;
|
|
99
|
-
extraTokens: Rule;
|
|
100
|
-
protected currIdx: number;
|
|
101
|
-
constructor(tokens: TokenType[], T: TokenMap, config?: IParserConfig);
|
|
102
|
-
/** Capture location information for CST nodes */
|
|
103
|
-
CAPTURE(func: () => any): any;
|
|
104
|
-
protected RULE<T>(name: string, impl: (...implArgs: any[]) => T, config?: IRuleConfig<T>): (idxInCallingRule?: number, ...args: any[]) => any;
|
|
105
|
-
protected OVERRIDE_RULE<T>(name: string, impl: (...implArgs: any[]) => T, config?: IRuleConfig<T>): (idxInCallingRule?: number, ...args: any[]) => any;
|
|
17
|
+
export declare class CssParser {
|
|
18
|
+
lexer: Lexer;
|
|
19
|
+
parser: CssActionsParser;
|
|
20
|
+
/**
|
|
21
|
+
* @note `recoveryEnabled` should be set to true for
|
|
22
|
+
* linting and language services.
|
|
23
|
+
*/
|
|
24
|
+
constructor(config?: CssParserConfig);
|
|
25
|
+
parse(text: string): IParseResult<Rules>;
|
|
26
|
+
parse(text: string, rule: 'stylesheet'): IParseResult<Rules>;
|
|
27
|
+
parse(text: string, rule?: CssRules): IParseResult;
|
|
28
|
+
/**
|
|
29
|
+
* IDE helper: suggest next possible token types at `offset` using Chevrotain's
|
|
30
|
+
* syntactic content assist. This is syntactic-only (not semantic completion).
|
|
31
|
+
*
|
|
32
|
+
* Note: content assist is significantly slower than normal parsing, so it
|
|
33
|
+
* should be called on-demand (e.g. near the cursor).
|
|
34
|
+
*/
|
|
35
|
+
suggest(text: string, init: {
|
|
36
|
+
offset: number;
|
|
37
|
+
rule?: CssRules;
|
|
38
|
+
}): SyntacticContentAssistSuggestion[];
|
|
106
39
|
}
|