@jesscss/less-parser 2.0.0-alpha.11 → 2.0.0-alpha.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/README.md +55 -11
- package/lib/chunks/parse-with.cjs +172 -0
- package/lib/chunks/parse-with.js +161 -0
- package/lib/chunks/trivia-labels.cjs +18 -0
- package/lib/chunks/trivia-labels.js +13 -0
- package/lib/cst/positions.cjs +24 -0
- package/lib/cst/positions.d.ts +8 -0
- package/lib/cst/positions.d.ts.map +1 -0
- package/lib/cst/positions.js +21 -0
- package/lib/cst.cjs +11 -4
- package/lib/cst.d.ts +8 -2
- package/lib/cst.d.ts.map +1 -1
- package/lib/cst.js +10 -4
- package/lib/grammar/ast/positions.cjs +21592 -0
- package/lib/grammar/ast/positions.d.ts +3 -0
- package/lib/grammar/ast/positions.d.ts.map +1 -0
- package/lib/grammar/ast/positions.js +21591 -0
- package/lib/grammar/ast.cjs +98033 -0
- package/lib/grammar/ast.d.ts +11 -0
- package/lib/grammar/ast.d.ts.map +1 -0
- package/lib/grammar/ast.js +98032 -0
- package/lib/grammar/cst/positions.cjs +21592 -0
- package/lib/grammar/cst/positions.d.ts +3 -0
- package/lib/grammar/cst/positions.d.ts.map +1 -0
- package/lib/grammar/cst/positions.js +21591 -0
- package/lib/grammar/cst.cjs +21591 -0
- package/lib/grammar/cst.d.ts +3 -0
- package/lib/grammar/cst.d.ts.map +1 -0
- package/lib/grammar/cst.js +21590 -0
- package/lib/grammar.d.ts +6 -3
- package/lib/grammar.d.ts.map +1 -1
- package/lib/index.cjs +25 -63
- package/lib/index.d.ts +17 -9
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +18 -57
- package/lib/parse-error.cjs +160 -0
- package/lib/parse-error.d.ts +26 -0
- package/lib/parse-error.d.ts.map +1 -1
- package/lib/parse-error.js +152 -0
- package/lib/parse-state.d.ts +39 -0
- package/lib/parse-state.d.ts.map +1 -0
- package/lib/parse-with.d.ts +25 -0
- package/lib/parse-with.d.ts.map +1 -0
- package/lib/positions.cjs +24 -0
- package/lib/positions.d.ts +20 -0
- package/lib/positions.d.ts.map +1 -0
- package/lib/positions.js +14 -0
- package/lib/trivia-labels.d.ts +11 -0
- package/lib/trivia-labels.d.ts.map +1 -0
- package/package.json +43 -13
- package/lib/grammar.cjs +0 -5
- package/lib/grammar.js +0 -2
- package/lib/grammar2.cjs +0 -141792
- package/lib/grammar2.js +0 -141733
package/lib/grammar.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
export declare const lessGrammar: Record<string, import("parseman").
|
|
2
|
-
|
|
1
|
+
export declare const lessGrammar: Record<string, import("parseman").Runnable>;
|
|
2
|
+
/** AST artifact with Parseman line/column tracking enabled. */
|
|
3
|
+
export declare const lessPositionsGrammar: Record<string, import("parseman").Runnable>;
|
|
3
4
|
/** Public Less CST artifact: the same grammar factory compiled in CST mode. */
|
|
4
|
-
export declare const lessCstGrammar: Record<string, import("parseman").
|
|
5
|
+
export declare const lessCstGrammar: Record<string, import("parseman").Runnable>;
|
|
6
|
+
/** CST artifact with Parseman line/column tracking enabled. */
|
|
7
|
+
export declare const lessCstPositionsGrammar: Record<string, import("parseman").Runnable>;
|
|
5
8
|
//# sourceMappingURL=grammar.d.ts.map
|
package/lib/grammar.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grammar.d.ts","sourceRoot":"","sources":["../src/grammar.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"grammar.d.ts","sourceRoot":"","sources":["../src/grammar.ts"],"names":[],"mappings":"AA0qNA,eAAO,MAAM,WAAW,6CAA4L,CAAC;AAErN,+DAA+D;AAC/D,eAAO,MAAM,oBAAoB,6CAA8M,CAAC;AAEhP,+EAA+E;AAC/E,eAAO,MAAM,cAAc,6CAA6M,CAAC;AAEzO,+DAA+D;AAC/D,eAAO,MAAM,uBAAuB,6CAA+N,CAAC"}
|
package/lib/index.cjs
CHANGED
|
@@ -1,72 +1,34 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const
|
|
3
|
-
|
|
4
|
-
let
|
|
5
|
-
let _jesscss_core_ast = require("@jesscss/core/ast");
|
|
2
|
+
const require_parse_with = require("./chunks/parse-with.cjs");
|
|
3
|
+
const require_parse_error = require("./parse-error.cjs");
|
|
4
|
+
let src_grammar_ast_js = require("./grammar/ast.cjs");
|
|
6
5
|
//#region src/index.ts
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
function
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
trivia,
|
|
17
|
-
state: { source: input }
|
|
18
|
-
});
|
|
19
|
-
if (!result.ok) throw new require_grammar.LessParseError(result.span.start, result.expected);
|
|
20
|
-
if (result.unconsumedFrom !== null) {
|
|
21
|
-
if (result.unconsumedFrom > result.span.start) throw new require_grammar.LessParseError(result.unconsumedFrom, [], {
|
|
22
|
-
message: "Unexpected Less input after a complete stylesheet.",
|
|
23
|
-
reason: "The parser consumed a complete Less stylesheet before this token, so the remaining text is not part of any rule, declaration, or at-rule.",
|
|
24
|
-
fix: "Remove the extra input or wrap it in valid Less syntax."
|
|
25
|
-
});
|
|
26
|
-
throw new require_grammar.LessParseError(result.unconsumedFrom, [], {
|
|
27
|
-
message: "Unexpected Less syntax.",
|
|
28
|
-
reason: "The parser could not match this token as the start of a Less rule, declaration, or at-rule.",
|
|
29
|
-
fix: "Remove the token or rewrite it as valid Less syntax."
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
if (!isStylesheet(result.value)) throw new require_grammar.LessParseError(result.span.end, [], {
|
|
33
|
-
message: "Less parser did not produce a stylesheet.",
|
|
34
|
-
reason: "The Less parser matched the input but returned a value that is not a stylesheet document.",
|
|
35
|
-
fix: "Report this as a parser bug with the source that triggered it."
|
|
36
|
-
});
|
|
37
|
-
return (0, _jesscss_core_ast.withTriviaMap)((0, _jesscss_core_ast.withSourceSpan)(result.value, result.span), (0, _jesscss_core_ast.createTriviaMapFromParseman)(input, result.triviaMap));
|
|
6
|
+
/**
|
|
7
|
+
* Parse Less directly into the canonical AST v2 document.
|
|
8
|
+
*
|
|
9
|
+
* Spans carry offsets only. For `startLine`/`startColumn` facts import `parse`
|
|
10
|
+
* from `@jesscss/less-parser/positions` — the same function bound to the
|
|
11
|
+
* line-aware compiled table. This entry never loads that table.
|
|
12
|
+
*/
|
|
13
|
+
function parse(input, options = {}) {
|
|
14
|
+
return require_parse_with.parseWith(src_grammar_ast_js.lessGrammar, input, options);
|
|
38
15
|
}
|
|
39
16
|
/**
|
|
40
|
-
* Parse Less for the product plugin path. Parser packages own recognition
|
|
41
|
-
* this boundary attaches file/source context once and returns
|
|
42
|
-
* diagnostics for compiler and CLI consumers to render.
|
|
17
|
+
* Parse Less for the product plugin path. Parser packages own recognition
|
|
18
|
+
* facts; this boundary attaches file/source context once and returns
|
|
19
|
+
* normalized diagnostics for compiler and CLI consumers to render.
|
|
43
20
|
*/
|
|
44
|
-
function safeParse(filePath, input) {
|
|
45
|
-
|
|
46
|
-
return {
|
|
47
|
-
document: parse(input),
|
|
48
|
-
errors: [],
|
|
49
|
-
warnings: []
|
|
50
|
-
};
|
|
51
|
-
} catch (error) {
|
|
52
|
-
return {
|
|
53
|
-
errors: [(0, _jesscss_core.parserDiagnostic)({
|
|
54
|
-
dialect: "Less",
|
|
55
|
-
error,
|
|
56
|
-
filePath,
|
|
57
|
-
source: input
|
|
58
|
-
})],
|
|
59
|
-
warnings: []
|
|
60
|
-
};
|
|
61
|
-
}
|
|
21
|
+
function safeParse(filePath, input, options = {}) {
|
|
22
|
+
return require_parse_with.safeParseWith(src_grammar_ast_js.lessGrammar, filePath, input, options);
|
|
62
23
|
}
|
|
63
24
|
//#endregion
|
|
64
|
-
exports.LessBareVariableInterpolationError =
|
|
65
|
-
exports.LessDynamicCharsetError =
|
|
66
|
-
exports.
|
|
67
|
-
exports.
|
|
68
|
-
exports.
|
|
69
|
-
exports.
|
|
70
|
-
exports.
|
|
25
|
+
exports.LessBareVariableInterpolationError = require_parse_error.LessBareVariableInterpolationError;
|
|
26
|
+
exports.LessDynamicCharsetError = require_parse_error.LessDynamicCharsetError;
|
|
27
|
+
exports.LessImportPostludeError = require_parse_error.LessImportPostludeError;
|
|
28
|
+
exports.LessInlineJavaScriptError = require_parse_error.LessInlineJavaScriptError;
|
|
29
|
+
exports.LessParseError = require_parse_error.LessParseError;
|
|
30
|
+
exports.LessUnparenthesizedMixinGuardError = require_parse_error.LessUnparenthesizedMixinGuardError;
|
|
31
|
+
exports.LessUnsupportedMixinNameError = require_parse_error.LessUnsupportedMixinNameError;
|
|
32
|
+
exports.LessUnsupportedVariableNameError = require_parse_error.LessUnsupportedVariableNameError;
|
|
71
33
|
exports.parse = parse;
|
|
72
34
|
exports.safeParse = safeParse;
|
package/lib/index.d.ts
CHANGED
|
@@ -1,12 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export
|
|
1
|
+
import type { ISafeParseResult } from '@jesscss/core';
|
|
2
|
+
import type { Stylesheet } from '@jesscss/core/ast';
|
|
3
|
+
import { type LessParseOptions } from './parse-with.js';
|
|
4
|
+
export type { LessParseOptions } from './parse-with.js';
|
|
5
|
+
export { LessBareVariableInterpolationError, LessDynamicCharsetError, LessImportPostludeError, LessInlineJavaScriptError, LessParseError, LessUnparenthesizedMixinGuardError, LessUnsupportedMixinNameError, LessUnsupportedVariableNameError } from './parse-error.js';
|
|
6
6
|
/**
|
|
7
|
-
* Parse Less
|
|
8
|
-
*
|
|
9
|
-
*
|
|
7
|
+
* Parse Less directly into the canonical AST v2 document.
|
|
8
|
+
*
|
|
9
|
+
* Spans carry offsets only. For `startLine`/`startColumn` facts import `parse`
|
|
10
|
+
* from `@jesscss/less-parser/positions` — the same function bound to the
|
|
11
|
+
* line-aware compiled table. This entry never loads that table.
|
|
10
12
|
*/
|
|
11
|
-
export declare function
|
|
13
|
+
export declare function parse(input: string, options?: LessParseOptions): Stylesheet;
|
|
14
|
+
/**
|
|
15
|
+
* Parse Less for the product plugin path. Parser packages own recognition
|
|
16
|
+
* facts; this boundary attaches file/source context once and returns
|
|
17
|
+
* normalized diagnostics for compiler and CLI consumers to render.
|
|
18
|
+
*/
|
|
19
|
+
export declare function safeParse(filePath: string, input: string, options?: LessParseOptions): ISafeParseResult;
|
|
12
20
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEpD,OAAO,EAA4B,KAAK,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAElF,YAAY,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAExD,OAAO,EACL,kCAAkC,EAClC,uBAAuB,EACvB,uBAAuB,EACvB,yBAAyB,EACzB,cAAc,EACd,kCAAkC,EAClC,6BAA6B,EAC7B,gCAAgC,EACjC,MAAM,kBAAkB,CAAC;AAE1B;;;;;;GAMG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,GAAE,gBAAqB,GAAG,UAAU,CAE/E;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CACvB,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,MAAM,EACb,OAAO,GAAE,gBAAqB,GAC7B,gBAAgB,CAElB"}
|
package/lib/index.js
CHANGED
|
@@ -1,63 +1,24 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { createTriviaMapFromParseman, withSourceSpan, withTriviaMap } from "@jesscss/core/ast";
|
|
1
|
+
import { n as safeParseWith, t as parseWith } from "./chunks/parse-with.js";
|
|
2
|
+
import { LessBareVariableInterpolationError, LessDynamicCharsetError, LessImportPostludeError, LessInlineJavaScriptError, LessParseError, LessUnparenthesizedMixinGuardError, LessUnsupportedMixinNameError, LessUnsupportedVariableNameError } from "./parse-error.js";
|
|
3
|
+
import { lessGrammar } from "./grammar/ast.js";
|
|
5
4
|
//#region src/index.ts
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
function
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
trivia,
|
|
16
|
-
state: { source: input }
|
|
17
|
-
});
|
|
18
|
-
if (!result.ok) throw new LessParseError(result.span.start, result.expected);
|
|
19
|
-
if (result.unconsumedFrom !== null) {
|
|
20
|
-
if (result.unconsumedFrom > result.span.start) throw new LessParseError(result.unconsumedFrom, [], {
|
|
21
|
-
message: "Unexpected Less input after a complete stylesheet.",
|
|
22
|
-
reason: "The parser consumed a complete Less stylesheet before this token, so the remaining text is not part of any rule, declaration, or at-rule.",
|
|
23
|
-
fix: "Remove the extra input or wrap it in valid Less syntax."
|
|
24
|
-
});
|
|
25
|
-
throw new LessParseError(result.unconsumedFrom, [], {
|
|
26
|
-
message: "Unexpected Less syntax.",
|
|
27
|
-
reason: "The parser could not match this token as the start of a Less rule, declaration, or at-rule.",
|
|
28
|
-
fix: "Remove the token or rewrite it as valid Less syntax."
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
if (!isStylesheet(result.value)) throw new LessParseError(result.span.end, [], {
|
|
32
|
-
message: "Less parser did not produce a stylesheet.",
|
|
33
|
-
reason: "The Less parser matched the input but returned a value that is not a stylesheet document.",
|
|
34
|
-
fix: "Report this as a parser bug with the source that triggered it."
|
|
35
|
-
});
|
|
36
|
-
return withTriviaMap(withSourceSpan(result.value, result.span), createTriviaMapFromParseman(input, result.triviaMap));
|
|
5
|
+
/**
|
|
6
|
+
* Parse Less directly into the canonical AST v2 document.
|
|
7
|
+
*
|
|
8
|
+
* Spans carry offsets only. For `startLine`/`startColumn` facts import `parse`
|
|
9
|
+
* from `@jesscss/less-parser/positions` — the same function bound to the
|
|
10
|
+
* line-aware compiled table. This entry never loads that table.
|
|
11
|
+
*/
|
|
12
|
+
function parse(input, options = {}) {
|
|
13
|
+
return parseWith(lessGrammar, input, options);
|
|
37
14
|
}
|
|
38
15
|
/**
|
|
39
|
-
* Parse Less for the product plugin path. Parser packages own recognition
|
|
40
|
-
* this boundary attaches file/source context once and returns
|
|
41
|
-
* diagnostics for compiler and CLI consumers to render.
|
|
16
|
+
* Parse Less for the product plugin path. Parser packages own recognition
|
|
17
|
+
* facts; this boundary attaches file/source context once and returns
|
|
18
|
+
* normalized diagnostics for compiler and CLI consumers to render.
|
|
42
19
|
*/
|
|
43
|
-
function safeParse(filePath, input) {
|
|
44
|
-
|
|
45
|
-
return {
|
|
46
|
-
document: parse(input),
|
|
47
|
-
errors: [],
|
|
48
|
-
warnings: []
|
|
49
|
-
};
|
|
50
|
-
} catch (error) {
|
|
51
|
-
return {
|
|
52
|
-
errors: [parserDiagnostic({
|
|
53
|
-
dialect: "Less",
|
|
54
|
-
error,
|
|
55
|
-
filePath,
|
|
56
|
-
source: input
|
|
57
|
-
})],
|
|
58
|
-
warnings: []
|
|
59
|
-
};
|
|
60
|
-
}
|
|
20
|
+
function safeParse(filePath, input, options = {}) {
|
|
21
|
+
return safeParseWith(lessGrammar, filePath, input, options);
|
|
61
22
|
}
|
|
62
23
|
//#endregion
|
|
63
|
-
export { LessBareVariableInterpolationError, LessDynamicCharsetError, LessInlineJavaScriptError, LessParseError, LessUnparenthesizedMixinGuardError, LessUnsupportedMixinNameError, LessUnsupportedVariableNameError, parse, safeParse };
|
|
24
|
+
export { LessBareVariableInterpolationError, LessDynamicCharsetError, LessImportPostludeError, LessInlineJavaScriptError, LessParseError, LessUnparenthesizedMixinGuardError, LessUnsupportedMixinNameError, LessUnsupportedVariableNameError, parse, safeParse };
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
//#region src/parse-error.ts
|
|
3
|
+
function expectedIncludes(expected, value) {
|
|
4
|
+
return expected.has(value);
|
|
5
|
+
}
|
|
6
|
+
function expectedMessage(expected) {
|
|
7
|
+
if (expected.length === 0) return "Unexpected Less syntax.";
|
|
8
|
+
const expectedSet = new Set(expected);
|
|
9
|
+
if (expectedIncludes(expectedSet, "\")\"")) return "Missing closing parenthesis.";
|
|
10
|
+
if (expectedSet.size === 1) {
|
|
11
|
+
if (expectedIncludes(expectedSet, "\"]\"")) return "Missing closing bracket.";
|
|
12
|
+
if (expectedIncludes(expectedSet, "\"}\"")) return "Missing closing brace.";
|
|
13
|
+
}
|
|
14
|
+
if (expectedIncludes(expectedSet, "NumberToken") && expectedIncludes(expectedSet, "DimensionUnit") && expectedIncludes(expectedSet, "not(regex)") && (expectedIncludes(expectedSet, "ValueIdentifier") || expectedIncludes(expectedSet, "HexColor"))) return "Unexpected Less syntax. Expected a Less value.";
|
|
15
|
+
if (expectedIncludes(expectedSet, "\";\"")) return "Missing semicolon.";
|
|
16
|
+
return "Unexpected Less syntax. Expected valid Less syntax here.";
|
|
17
|
+
}
|
|
18
|
+
/** Structured failure from the public direct Less parser. */
|
|
19
|
+
var LessParseError = class extends SyntaxError {
|
|
20
|
+
code = "parse/syntax-error";
|
|
21
|
+
offset;
|
|
22
|
+
expected;
|
|
23
|
+
line;
|
|
24
|
+
column;
|
|
25
|
+
endLine;
|
|
26
|
+
endColumn;
|
|
27
|
+
reason;
|
|
28
|
+
fix;
|
|
29
|
+
constructor(offset, expected, options = {}) {
|
|
30
|
+
super(options.message ?? expectedMessage(expected));
|
|
31
|
+
this.name = "LessParseError";
|
|
32
|
+
this.offset = offset;
|
|
33
|
+
this.expected = expected;
|
|
34
|
+
this.line = options.line;
|
|
35
|
+
this.column = options.column;
|
|
36
|
+
this.endLine = options.endLine;
|
|
37
|
+
this.endColumn = options.endColumn;
|
|
38
|
+
this.reason = options.reason;
|
|
39
|
+
this.fix = options.fix;
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
/** Interpolation is rejected inside the CSS @charset token. */
|
|
43
|
+
var LessDynamicCharsetError = class extends SyntaxError {
|
|
44
|
+
code = "parse/dynamic-charset";
|
|
45
|
+
offset;
|
|
46
|
+
endOffset;
|
|
47
|
+
reason = "Interpolation is not valid inside the CSS @charset token.";
|
|
48
|
+
fix = "Use a static declaration such as @charset \"UTF-8\";";
|
|
49
|
+
constructor(offset, endOffset) {
|
|
50
|
+
super("Interpolation is not valid in @charset.");
|
|
51
|
+
this.name = "LessDynamicCharsetError";
|
|
52
|
+
this.offset = offset;
|
|
53
|
+
this.endOffset = endOffset;
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
/** Executable inline backtick JavaScript is recognized so diagnostics can be precise. */
|
|
57
|
+
var LessInlineJavaScriptError = class extends SyntaxError {
|
|
58
|
+
code = "parse/unsupported-inline-javascript";
|
|
59
|
+
offset;
|
|
60
|
+
endOffset;
|
|
61
|
+
reason = "Backtick JavaScript expressions are not evaluated.";
|
|
62
|
+
fix = "Move the expression into an explicit @from/@-from script import or a plugin function.";
|
|
63
|
+
constructor(offset, endOffset) {
|
|
64
|
+
super("Inline backtick JavaScript is not supported.");
|
|
65
|
+
this.name = "LessInlineJavaScriptError";
|
|
66
|
+
this.offset = offset;
|
|
67
|
+
this.endOffset = endOffset;
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
/** Syntax/prelude slots require explicit @{name} interpolation. */
|
|
71
|
+
var LessBareVariableInterpolationError = class extends SyntaxError {
|
|
72
|
+
code = "parse/unsupported-bare-variable-interpolation";
|
|
73
|
+
offset;
|
|
74
|
+
endOffset;
|
|
75
|
+
reason;
|
|
76
|
+
fix;
|
|
77
|
+
constructor(offset, endOffset, name) {
|
|
78
|
+
super("Bare @variable interpolation is not valid here.");
|
|
79
|
+
this.name = "LessBareVariableInterpolationError";
|
|
80
|
+
this.offset = offset;
|
|
81
|
+
this.endOffset = endOffset;
|
|
82
|
+
this.reason = "Bare @variable references are values; syntax and prelude interpolation must use @{variable}.";
|
|
83
|
+
this.fix = `Use @{${name}} instead of @${name}.`;
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
/** Legacy Less variable names are recognized so diagnostics can be precise. */
|
|
87
|
+
var LessUnsupportedVariableNameError = class extends SyntaxError {
|
|
88
|
+
code = "parse/unsupported-variable-name";
|
|
89
|
+
offset;
|
|
90
|
+
endOffset;
|
|
91
|
+
reason = "Less variable names must not be numeric-leading or dash-only.";
|
|
92
|
+
fix;
|
|
93
|
+
constructor(offset, endOffset, name) {
|
|
94
|
+
super("This Less variable name is not supported.");
|
|
95
|
+
this.name = "LessUnsupportedVariableNameError";
|
|
96
|
+
this.offset = offset;
|
|
97
|
+
this.endOffset = endOffset;
|
|
98
|
+
this.fix = `Rename @${name} to a descriptive variable name and update its references.`;
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
/** Legacy dash-only mixin names are recognized so diagnostics can be precise. */
|
|
102
|
+
var LessUnsupportedMixinNameError = class extends SyntaxError {
|
|
103
|
+
code = "parse/unsupported-mixin-name";
|
|
104
|
+
offset;
|
|
105
|
+
endOffset;
|
|
106
|
+
reason = "Dash-only Less mixin names are not supported.";
|
|
107
|
+
fix = "Rename the mixin to a descriptive selector-like name, for example .mixin().";
|
|
108
|
+
constructor(offset, endOffset) {
|
|
109
|
+
super("This Less mixin name is not supported.");
|
|
110
|
+
this.name = "LessUnsupportedMixinNameError";
|
|
111
|
+
this.offset = offset;
|
|
112
|
+
this.endOffset = endOffset;
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
/** Ungrouped Less mixin guards are recognized so diagnostics can point at the guard. */
|
|
116
|
+
var LessUnparenthesizedMixinGuardError = class extends SyntaxError {
|
|
117
|
+
code = "parse/unparenthesized-mixin-guard";
|
|
118
|
+
offset;
|
|
119
|
+
endOffset;
|
|
120
|
+
reason = "Top-level Less mixin guards require each condition after when to be wrapped in parentheses.";
|
|
121
|
+
fix = "Wrap the guard condition, for example: when (default()).";
|
|
122
|
+
constructor(offset, endOffset) {
|
|
123
|
+
super("Less mixin guard conditions must be parenthesized.");
|
|
124
|
+
this.name = "LessUnparenthesizedMixinGuardError";
|
|
125
|
+
this.offset = offset;
|
|
126
|
+
this.endOffset = endOffset;
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
/**
|
|
130
|
+
* A media/layer/supports postlude belongs to the plain CSS `@import` form only.
|
|
131
|
+
*
|
|
132
|
+
* Once the parser has decided an `@import` is compile-time — it carries options,
|
|
133
|
+
* or its target is a loadable (non-`.css`) path — a trailing query has nothing
|
|
134
|
+
* left to describe: the loaded rules are spliced into this document, not linked
|
|
135
|
+
* as a separate CSS resource. This DIVERGES deliberately from Less 4.x, which
|
|
136
|
+
* accepts `@import "foo.less" screen;` and wraps the loaded rules in
|
|
137
|
+
* `@media screen`.
|
|
138
|
+
*/
|
|
139
|
+
var LessImportPostludeError = class extends SyntaxError {
|
|
140
|
+
code = "parse/import-postlude-on-compile-time-import";
|
|
141
|
+
offset;
|
|
142
|
+
endOffset;
|
|
143
|
+
reason = "A media, layer, or supports query is only valid on a plain CSS @import.";
|
|
144
|
+
fix = "Drop the query, or wrap the import in an explicit @media/@supports/@layer block.";
|
|
145
|
+
constructor(offset, endOffset) {
|
|
146
|
+
super("A compile-time @import cannot carry a media query.");
|
|
147
|
+
this.name = "LessImportPostludeError";
|
|
148
|
+
this.offset = offset;
|
|
149
|
+
this.endOffset = endOffset;
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
//#endregion
|
|
153
|
+
exports.LessBareVariableInterpolationError = LessBareVariableInterpolationError;
|
|
154
|
+
exports.LessDynamicCharsetError = LessDynamicCharsetError;
|
|
155
|
+
exports.LessImportPostludeError = LessImportPostludeError;
|
|
156
|
+
exports.LessInlineJavaScriptError = LessInlineJavaScriptError;
|
|
157
|
+
exports.LessParseError = LessParseError;
|
|
158
|
+
exports.LessUnparenthesizedMixinGuardError = LessUnparenthesizedMixinGuardError;
|
|
159
|
+
exports.LessUnsupportedMixinNameError = LessUnsupportedMixinNameError;
|
|
160
|
+
exports.LessUnsupportedVariableNameError = LessUnsupportedVariableNameError;
|
package/lib/parse-error.d.ts
CHANGED
|
@@ -3,12 +3,20 @@ export declare class LessParseError extends SyntaxError {
|
|
|
3
3
|
readonly code: 'parse/syntax-error';
|
|
4
4
|
readonly offset: number;
|
|
5
5
|
readonly expected: readonly string[];
|
|
6
|
+
readonly line?: number;
|
|
7
|
+
readonly column?: number;
|
|
8
|
+
readonly endLine?: number;
|
|
9
|
+
readonly endColumn?: number;
|
|
6
10
|
readonly reason?: string;
|
|
7
11
|
readonly fix?: string;
|
|
8
12
|
constructor(offset: number, expected: readonly string[], options?: {
|
|
9
13
|
message?: string;
|
|
10
14
|
reason?: string;
|
|
11
15
|
fix?: string;
|
|
16
|
+
line?: number;
|
|
17
|
+
column?: number;
|
|
18
|
+
endLine?: number;
|
|
19
|
+
endColumn?: number;
|
|
12
20
|
});
|
|
13
21
|
}
|
|
14
22
|
/** Interpolation is rejected inside the CSS @charset token. */
|
|
@@ -65,4 +73,22 @@ export declare class LessUnparenthesizedMixinGuardError extends SyntaxError {
|
|
|
65
73
|
readonly fix = "Wrap the guard condition, for example: when (default()).";
|
|
66
74
|
constructor(offset: number, endOffset: number);
|
|
67
75
|
}
|
|
76
|
+
/**
|
|
77
|
+
* A media/layer/supports postlude belongs to the plain CSS `@import` form only.
|
|
78
|
+
*
|
|
79
|
+
* Once the parser has decided an `@import` is compile-time — it carries options,
|
|
80
|
+
* or its target is a loadable (non-`.css`) path — a trailing query has nothing
|
|
81
|
+
* left to describe: the loaded rules are spliced into this document, not linked
|
|
82
|
+
* as a separate CSS resource. This DIVERGES deliberately from Less 4.x, which
|
|
83
|
+
* accepts `@import "foo.less" screen;` and wraps the loaded rules in
|
|
84
|
+
* `@media screen`.
|
|
85
|
+
*/
|
|
86
|
+
export declare class LessImportPostludeError extends SyntaxError {
|
|
87
|
+
readonly code: 'parse/import-postlude-on-compile-time-import';
|
|
88
|
+
readonly offset: number;
|
|
89
|
+
readonly endOffset: number;
|
|
90
|
+
readonly reason = "A media, layer, or supports query is only valid on a plain CSS @import.";
|
|
91
|
+
readonly fix = "Drop the query, or wrap the import in an explicit @media/@supports/@layer block.";
|
|
92
|
+
constructor(offset: number, endOffset: number);
|
|
93
|
+
}
|
|
68
94
|
//# sourceMappingURL=parse-error.d.ts.map
|
package/lib/parse-error.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse-error.d.ts","sourceRoot":"","sources":["../src/parse-error.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"parse-error.d.ts","sourceRoot":"","sources":["../src/parse-error.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
//#region src/parse-error.ts
|
|
2
|
+
function expectedIncludes(expected, value) {
|
|
3
|
+
return expected.has(value);
|
|
4
|
+
}
|
|
5
|
+
function expectedMessage(expected) {
|
|
6
|
+
if (expected.length === 0) return "Unexpected Less syntax.";
|
|
7
|
+
const expectedSet = new Set(expected);
|
|
8
|
+
if (expectedIncludes(expectedSet, "\")\"")) return "Missing closing parenthesis.";
|
|
9
|
+
if (expectedSet.size === 1) {
|
|
10
|
+
if (expectedIncludes(expectedSet, "\"]\"")) return "Missing closing bracket.";
|
|
11
|
+
if (expectedIncludes(expectedSet, "\"}\"")) return "Missing closing brace.";
|
|
12
|
+
}
|
|
13
|
+
if (expectedIncludes(expectedSet, "NumberToken") && expectedIncludes(expectedSet, "DimensionUnit") && expectedIncludes(expectedSet, "not(regex)") && (expectedIncludes(expectedSet, "ValueIdentifier") || expectedIncludes(expectedSet, "HexColor"))) return "Unexpected Less syntax. Expected a Less value.";
|
|
14
|
+
if (expectedIncludes(expectedSet, "\";\"")) return "Missing semicolon.";
|
|
15
|
+
return "Unexpected Less syntax. Expected valid Less syntax here.";
|
|
16
|
+
}
|
|
17
|
+
/** Structured failure from the public direct Less parser. */
|
|
18
|
+
var LessParseError = class extends SyntaxError {
|
|
19
|
+
code = "parse/syntax-error";
|
|
20
|
+
offset;
|
|
21
|
+
expected;
|
|
22
|
+
line;
|
|
23
|
+
column;
|
|
24
|
+
endLine;
|
|
25
|
+
endColumn;
|
|
26
|
+
reason;
|
|
27
|
+
fix;
|
|
28
|
+
constructor(offset, expected, options = {}) {
|
|
29
|
+
super(options.message ?? expectedMessage(expected));
|
|
30
|
+
this.name = "LessParseError";
|
|
31
|
+
this.offset = offset;
|
|
32
|
+
this.expected = expected;
|
|
33
|
+
this.line = options.line;
|
|
34
|
+
this.column = options.column;
|
|
35
|
+
this.endLine = options.endLine;
|
|
36
|
+
this.endColumn = options.endColumn;
|
|
37
|
+
this.reason = options.reason;
|
|
38
|
+
this.fix = options.fix;
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
/** Interpolation is rejected inside the CSS @charset token. */
|
|
42
|
+
var LessDynamicCharsetError = class extends SyntaxError {
|
|
43
|
+
code = "parse/dynamic-charset";
|
|
44
|
+
offset;
|
|
45
|
+
endOffset;
|
|
46
|
+
reason = "Interpolation is not valid inside the CSS @charset token.";
|
|
47
|
+
fix = "Use a static declaration such as @charset \"UTF-8\";";
|
|
48
|
+
constructor(offset, endOffset) {
|
|
49
|
+
super("Interpolation is not valid in @charset.");
|
|
50
|
+
this.name = "LessDynamicCharsetError";
|
|
51
|
+
this.offset = offset;
|
|
52
|
+
this.endOffset = endOffset;
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
/** Executable inline backtick JavaScript is recognized so diagnostics can be precise. */
|
|
56
|
+
var LessInlineJavaScriptError = class extends SyntaxError {
|
|
57
|
+
code = "parse/unsupported-inline-javascript";
|
|
58
|
+
offset;
|
|
59
|
+
endOffset;
|
|
60
|
+
reason = "Backtick JavaScript expressions are not evaluated.";
|
|
61
|
+
fix = "Move the expression into an explicit @from/@-from script import or a plugin function.";
|
|
62
|
+
constructor(offset, endOffset) {
|
|
63
|
+
super("Inline backtick JavaScript is not supported.");
|
|
64
|
+
this.name = "LessInlineJavaScriptError";
|
|
65
|
+
this.offset = offset;
|
|
66
|
+
this.endOffset = endOffset;
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
/** Syntax/prelude slots require explicit @{name} interpolation. */
|
|
70
|
+
var LessBareVariableInterpolationError = class extends SyntaxError {
|
|
71
|
+
code = "parse/unsupported-bare-variable-interpolation";
|
|
72
|
+
offset;
|
|
73
|
+
endOffset;
|
|
74
|
+
reason;
|
|
75
|
+
fix;
|
|
76
|
+
constructor(offset, endOffset, name) {
|
|
77
|
+
super("Bare @variable interpolation is not valid here.");
|
|
78
|
+
this.name = "LessBareVariableInterpolationError";
|
|
79
|
+
this.offset = offset;
|
|
80
|
+
this.endOffset = endOffset;
|
|
81
|
+
this.reason = "Bare @variable references are values; syntax and prelude interpolation must use @{variable}.";
|
|
82
|
+
this.fix = `Use @{${name}} instead of @${name}.`;
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
/** Legacy Less variable names are recognized so diagnostics can be precise. */
|
|
86
|
+
var LessUnsupportedVariableNameError = class extends SyntaxError {
|
|
87
|
+
code = "parse/unsupported-variable-name";
|
|
88
|
+
offset;
|
|
89
|
+
endOffset;
|
|
90
|
+
reason = "Less variable names must not be numeric-leading or dash-only.";
|
|
91
|
+
fix;
|
|
92
|
+
constructor(offset, endOffset, name) {
|
|
93
|
+
super("This Less variable name is not supported.");
|
|
94
|
+
this.name = "LessUnsupportedVariableNameError";
|
|
95
|
+
this.offset = offset;
|
|
96
|
+
this.endOffset = endOffset;
|
|
97
|
+
this.fix = `Rename @${name} to a descriptive variable name and update its references.`;
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
/** Legacy dash-only mixin names are recognized so diagnostics can be precise. */
|
|
101
|
+
var LessUnsupportedMixinNameError = class extends SyntaxError {
|
|
102
|
+
code = "parse/unsupported-mixin-name";
|
|
103
|
+
offset;
|
|
104
|
+
endOffset;
|
|
105
|
+
reason = "Dash-only Less mixin names are not supported.";
|
|
106
|
+
fix = "Rename the mixin to a descriptive selector-like name, for example .mixin().";
|
|
107
|
+
constructor(offset, endOffset) {
|
|
108
|
+
super("This Less mixin name is not supported.");
|
|
109
|
+
this.name = "LessUnsupportedMixinNameError";
|
|
110
|
+
this.offset = offset;
|
|
111
|
+
this.endOffset = endOffset;
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
/** Ungrouped Less mixin guards are recognized so diagnostics can point at the guard. */
|
|
115
|
+
var LessUnparenthesizedMixinGuardError = class extends SyntaxError {
|
|
116
|
+
code = "parse/unparenthesized-mixin-guard";
|
|
117
|
+
offset;
|
|
118
|
+
endOffset;
|
|
119
|
+
reason = "Top-level Less mixin guards require each condition after when to be wrapped in parentheses.";
|
|
120
|
+
fix = "Wrap the guard condition, for example: when (default()).";
|
|
121
|
+
constructor(offset, endOffset) {
|
|
122
|
+
super("Less mixin guard conditions must be parenthesized.");
|
|
123
|
+
this.name = "LessUnparenthesizedMixinGuardError";
|
|
124
|
+
this.offset = offset;
|
|
125
|
+
this.endOffset = endOffset;
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
/**
|
|
129
|
+
* A media/layer/supports postlude belongs to the plain CSS `@import` form only.
|
|
130
|
+
*
|
|
131
|
+
* Once the parser has decided an `@import` is compile-time — it carries options,
|
|
132
|
+
* or its target is a loadable (non-`.css`) path — a trailing query has nothing
|
|
133
|
+
* left to describe: the loaded rules are spliced into this document, not linked
|
|
134
|
+
* as a separate CSS resource. This DIVERGES deliberately from Less 4.x, which
|
|
135
|
+
* accepts `@import "foo.less" screen;` and wraps the loaded rules in
|
|
136
|
+
* `@media screen`.
|
|
137
|
+
*/
|
|
138
|
+
var LessImportPostludeError = class extends SyntaxError {
|
|
139
|
+
code = "parse/import-postlude-on-compile-time-import";
|
|
140
|
+
offset;
|
|
141
|
+
endOffset;
|
|
142
|
+
reason = "A media, layer, or supports query is only valid on a plain CSS @import.";
|
|
143
|
+
fix = "Drop the query, or wrap the import in an explicit @media/@supports/@layer block.";
|
|
144
|
+
constructor(offset, endOffset) {
|
|
145
|
+
super("A compile-time @import cannot carry a media query.");
|
|
146
|
+
this.name = "LessImportPostludeError";
|
|
147
|
+
this.offset = offset;
|
|
148
|
+
this.endOffset = endOffset;
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
//#endregion
|
|
152
|
+
export { LessBareVariableInterpolationError, LessDynamicCharsetError, LessImportPostludeError, LessInlineJavaScriptError, LessParseError, LessUnparenthesizedMixinGuardError, LessUnsupportedMixinNameError, LessUnsupportedVariableNameError };
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The parseman `ctx.state` the Less grammar reads, and its one validator.
|
|
3
|
+
*
|
|
4
|
+
* It lives in its own module because BOTH ends need it and neither may import
|
|
5
|
+
* the other: `parse-with.ts` constructs the state and names the compiled grammar
|
|
6
|
+
* table only as a type, while `grammar.ts` consumes it inside reducers. A shared
|
|
7
|
+
* third module keeps that a straight line rather than a cycle.
|
|
8
|
+
*/
|
|
9
|
+
import type { MathMode } from '@jesscss/core';
|
|
10
|
+
export interface LessParseState {
|
|
11
|
+
/**
|
|
12
|
+
* The input text, the trivia machinery's back-reference for slicing.
|
|
13
|
+
*
|
|
14
|
+
* OPTIONAL, because the grammar already treats it so — `sourceFromState`
|
|
15
|
+
* returns `undefined` when it is absent and the trivia helpers fall back to
|
|
16
|
+
* structural layout. A caller that only wants grammar facts (the AST-grammar
|
|
17
|
+
* tests drive `run()` directly) may omit it. `mathMode` remains required on
|
|
18
|
+
* this resolved internal shape; raw callers are normalized by
|
|
19
|
+
* `requireLessParseState` below.
|
|
20
|
+
*/
|
|
21
|
+
readonly source?: string;
|
|
22
|
+
/**
|
|
23
|
+
* Less's `math:` policy, a PARSE-TIME input (ledger P1). The grammar resolves
|
|
24
|
+
* it per operation and writes the answer onto `Operation.mathOutsideParens`;
|
|
25
|
+
* the evaluator never sees the mode.
|
|
26
|
+
*/
|
|
27
|
+
readonly mathMode: MathMode;
|
|
28
|
+
}
|
|
29
|
+
/** The public Less default, shared by wrapper and raw-grammar entry points. */
|
|
30
|
+
export declare const DEFAULT_LESS_MATH_MODE: MathMode;
|
|
31
|
+
/**
|
|
32
|
+
* Recover the typed state parseman hands reducers as `unknown`.
|
|
33
|
+
*
|
|
34
|
+
* Missing state uses the same public default as `parseWith`, so the exported
|
|
35
|
+
* AST/CST grammars remain directly runnable. An explicitly supplied invalid
|
|
36
|
+
* mode still throws instead of hiding a broken threading path.
|
|
37
|
+
*/
|
|
38
|
+
export declare function requireLessParseState(state: unknown): LessParseState;
|
|
39
|
+
//# sourceMappingURL=parse-state.d.ts.map
|