@jesscss/less-parser 2.0.0-alpha.5 → 2.0.0-alpha.7
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 +133 -5
- package/lib/builders.d.ts +381 -0
- package/lib/builders.d.ts.map +1 -0
- package/lib/cst.cjs +14 -0
- package/lib/cst.d.ts +6 -0
- package/lib/cst.d.ts.map +1 -0
- package/lib/cst.js +12 -0
- package/lib/functional-parser.cjs +2653 -0
- package/lib/functional-parser.d.ts +18 -0
- package/lib/functional-parser.d.ts.map +1 -0
- package/lib/functional-parser.js +2588 -0
- package/lib/grammar.cjs +30621 -0
- package/lib/grammar.d.ts +2 -0
- package/lib/grammar.d.ts.map +1 -0
- package/lib/grammar.js +30620 -0
- package/lib/index.cjs +18 -0
- package/lib/index.d.ts +9 -32
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +7 -75
- package/lib/jess.cjs +3968 -0
- package/lib/jess.d.ts +7 -0
- package/lib/jess.d.ts.map +1 -0
- package/lib/jess.js +3962 -0
- package/lib/lessParser.d.ts +38 -0
- package/lib/lessParser.d.ts.map +1 -0
- package/lib/lessRecursiveParser.d.ts +99 -0
- package/lib/lessRecursiveParser.d.ts.map +1 -0
- package/lib/lessTokens.d.ts +4 -3
- package/lib/lessTokens.d.ts.map +1 -0
- package/lib/productions/guards.d.ts +113 -0
- package/lib/productions/guards.d.ts.map +1 -0
- package/lib/productions/index.d.ts +5 -0
- package/lib/productions/index.d.ts.map +1 -0
- package/lib/productions/root.d.ts +38 -0
- package/lib/productions/root.d.ts.map +1 -0
- package/lib/productions/selectors.d.ts +41 -0
- package/lib/productions/selectors.d.ts.map +1 -0
- package/lib/productions/values.d.ts +35 -0
- package/lib/productions/values.d.ts.map +1 -0
- package/lib/utils.d.ts +8 -1
- package/lib/utils.d.ts.map +1 -0
- package/package.json +49 -16
- package/{lib/__tests__/debug-log.js → src/__tests__/debug-log.ts} +20 -19
- package/src/__tests__/wall5-parse.test.ts +67 -0
- package/src/builders.ts +3183 -0
- package/src/cst.ts +25 -0
- package/src/functional-parser.ts +162 -0
- package/src/grammar.ts +869 -0
- package/src/index.ts +19 -0
- package/src/jess.ts +6 -0
- package/src/lessParser.ts +120 -0
- package/src/lessRecursiveParser.ts +279 -0
- package/src/lessTokens.ts +350 -0
- package/src/productions/guards.ts +1066 -0
- package/src/productions/index.ts +29 -0
- package/src/productions/root.ts +1613 -0
- package/src/productions/selectors.ts +1309 -0
- package/src/productions/values.ts +1449 -0
- package/src/utils.ts +178 -0
- package/lib/__tests__/debug-log.d.ts +0 -1
- package/lib/__tests__/debug-log.js.map +0 -1
- package/lib/index.js.map +0 -1
- package/lib/lessActionsParser.d.ts +0 -156
- package/lib/lessActionsParser.js +0 -145
- package/lib/lessActionsParser.js.map +0 -1
- package/lib/lessErrorMessageProvider.d.ts +0 -3
- package/lib/lessErrorMessageProvider.js +0 -4
- package/lib/lessErrorMessageProvider.js.map +0 -1
- package/lib/lessTokens.js +0 -249
- package/lib/lessTokens.js.map +0 -1
- package/lib/productions.d.ts +0 -181
- package/lib/productions.js +0 -3521
- package/lib/productions.js.map +0 -1
- package/lib/utils.js +0 -88
- package/lib/utils.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,8 +1,137 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @jesscss/less-parser
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A [Less](https://lesscss.org/) parser built on [parseman](https://www.npmjs.com/package/parseman). The grammar is the CSS grammar plus a Less delta: `lessGrammar = compose([cssGrammar, <Less delta>])`. It adds `@variable` / `@{interpolation}`, mixins, and the rest of Less on top of the shared CSS base in `@jesscss/css-parser`.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Two ways to use it:
|
|
6
|
+
|
|
7
|
+
- **As part of Jess** — the default `.` entry is wired into `@jesscss/core` and produces the core AST the Jess compiler evaluates (this is what runs when Jess compiles Less). This is the internal, core-coupled path.
|
|
8
|
+
- **As a standalone CST parser** — the `./cst` entry has **no dependency on `@jesscss/core`**. Install just this package and parse Less source text into a concrete syntax tree (CST). You can also plug your own builders onto the grammar to produce your own AST instead of the default CST.
|
|
9
|
+
|
|
10
|
+
## Install
|
|
11
|
+
|
|
12
|
+
```sh
|
|
13
|
+
npm install @jesscss/less-parser
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
`@jesscss/core` is an **optional** peer dependency — needed only for the core-coupled `.` entry, not for `./cst` or `./grammar`.
|
|
17
|
+
|
|
18
|
+
## Standalone usage (core-free)
|
|
19
|
+
|
|
20
|
+
```js
|
|
21
|
+
import { parseLessCst } from '@jesscss/less-parser/cst'
|
|
22
|
+
|
|
23
|
+
const result = parseLessCst('@c: red;\n.foo { color: @c; }')
|
|
24
|
+
|
|
25
|
+
result.ok // true
|
|
26
|
+
result.errors // ParseError[] (empty when ok)
|
|
27
|
+
result.unconsumedFrom // index of first unparsed char, or null
|
|
28
|
+
result.tree // the CST root (a StyleSheet node)
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Signature:
|
|
32
|
+
|
|
33
|
+
```ts
|
|
34
|
+
parseLessCst(input: string, startRule = 'Stylesheet', options?: { collapse?: boolean }): LessCstParseResult
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Pass a different `startRule` (any capitalized grammar rule, e.g. `'SelectorList'`, `'Declaration'`) to parse a fragment.
|
|
38
|
+
|
|
39
|
+
## Public API
|
|
40
|
+
|
|
41
|
+
| Entry | Export | Purpose |
|
|
42
|
+
| --- | --- | --- |
|
|
43
|
+
| `@jesscss/less-parser/cst` | `parseLessCst` | Core-free parse of a Less string to a CST. |
|
|
44
|
+
| `@jesscss/less-parser/cst` | `LessCstNode`, `LessCstLeaf`, `LessCstError`, `LessCstChild`, `LessCstParseResult`, `LessCstType` (types) | CST type definitions (aliases of the shared `@jesscss/css-parser/cst` types). |
|
|
45
|
+
| `@jesscss/less-parser/grammar` | `lessGrammar` | The compiled Less grammar (a rule map). Extend it with `compose()` or drive it directly with parseman's `run`. |
|
|
46
|
+
| `@jesscss/less-parser` (`.`) | `LessParser` (also `Parser`), `parseLessFn`, `lessGrammar`, tokens, … | The Jess-internal barrel. **Core-coupled** (the functional parser builds the core AST). Prefer `./cst` if you don't need `@jesscss/core`. |
|
|
47
|
+
| `@jesscss/less-parser/jess` | `LessParser`, `LessGrammar`, `parseLessFn`, … | Internal Jess-facing surface. |
|
|
48
|
+
|
|
49
|
+
## Default CST shape
|
|
50
|
+
|
|
51
|
+
The CST is parseman's, produced by the shared `cssCstBuildHost`. Three kinds of node:
|
|
52
|
+
|
|
53
|
+
- **node** — `{ _tag: 'node', type, grammarType, span: { start, end }, state, children }` (`grammarType` = raw rule name; `type` = friendly public name).
|
|
54
|
+
- **leaf** — `{ _tag: 'leaf', value, span }` for terminals.
|
|
55
|
+
- **error** — `{ _tag: 'error', type, span, expected, children, state }` where recovery happened.
|
|
56
|
+
|
|
57
|
+
Spans are `[start, end)` offsets; whitespace, block comments, **and Less line comments (`//`)** are trivia and do not appear as children.
|
|
58
|
+
|
|
59
|
+
Parsing `@c: red;\n.foo { color: @c; }` yields (abridged):
|
|
60
|
+
|
|
61
|
+
```jsonc
|
|
62
|
+
{
|
|
63
|
+
"_tag": "node", "type": "StyleSheet", "grammarType": "Stylesheet",
|
|
64
|
+
"children": [
|
|
65
|
+
{ "_tag": "node", "type": "VarDeclaration", "grammarType": "VarDeclaration", "span": { "start": 0, "end": 8 },
|
|
66
|
+
"children": [
|
|
67
|
+
{ "_tag": "leaf", "value": "@c" }, { "_tag": "leaf", "value": ":" },
|
|
68
|
+
{ "_tag": "node", "type": "NamedColor", "grammarType": "NamedColor",
|
|
69
|
+
"children": [ { "_tag": "leaf", "value": "red" } ] },
|
|
70
|
+
{ "_tag": "leaf", "value": ";" }
|
|
71
|
+
] },
|
|
72
|
+
{ "_tag": "node", "type": "QualifiedRule", "grammarType": "Ruleset", "span": { "start": 9, "end": 28 },
|
|
73
|
+
"children": [
|
|
74
|
+
{ "_tag": "leaf", "value": ".foo" }, { "_tag": "leaf", "value": "{" },
|
|
75
|
+
{ "_tag": "node", "type": "Declaration", "grammarType": "Declaration",
|
|
76
|
+
"children": [
|
|
77
|
+
{ "_tag": "leaf", "value": "color" }, { "_tag": "leaf", "value": ":" },
|
|
78
|
+
{ "_tag": "node", "type": "Reference", "grammarType": "Reference",
|
|
79
|
+
"children": [ { "_tag": "leaf", "value": "@c" } ] },
|
|
80
|
+
{ "_tag": "leaf", "value": ";" }
|
|
81
|
+
] },
|
|
82
|
+
{ "_tag": "leaf", "value": "}" }
|
|
83
|
+
] }
|
|
84
|
+
]
|
|
85
|
+
}
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Note the Less-specific nodes: a top-level `@c: …` becomes a `VarDeclaration`, a `@c` value becomes a `Reference`, and the color keyword `red` parses as `NamedColor` (the CSS-only grammar has no such rule — see `@jesscss/css-parser`).
|
|
89
|
+
|
|
90
|
+
Pass `{ collapse: true }` to unwrap single-child wrapper types (`Reference`, `NamedColor`, `InterpolatedSelector`) into their child.
|
|
91
|
+
|
|
92
|
+
### Name-independent condition arguments
|
|
93
|
+
|
|
94
|
+
A top-level condition operator (`> < >= <= = and or not`) inside **any** call's argument parses as a `Condition` node — there is **no** parse-time name-dispatch on `if`/`boolean`. `if(@a > 5, 1, 2)`, `boolean(not(2 < 1))`, `#ns.if(@a > 5)`, and `foo(@a > 5 and @b < 2)` all route through the ordinary function/mixin `Call` production; the shared call-arg rule (`ArgCondition` → `CondArgOr`/`CondArgAnd`/`CondArgTerm`) layers the condition-operator precedence chain on top of the normal value production. The layer is structurally gated: it only matches when a real operator is present, so a plain value / space-list argument (and mixin-definition params) fall through to the unchanged `valueSequence` byte-identically. Eval treats `if`/`boolean` as ordinary registered functions that consume the parsed `Condition`, so this is a parse-only unification (a deliberate v5 loosening vs Less 4.x, which name-dispatched and errored on the namespaced/generic forms).
|
|
95
|
+
|
|
96
|
+
One known gap: a namespace/accessor call in **value** position (`b: #ns.if(@a > 5)`, `b: .if(@a > 5)`) is reassembled from a raw permissive-paren capture (`_buildRefCallArgs`), a separate shallow path that does not run the condition layer — its args stay a value list. Statement-position (`#ns.if(@a > 5) { }` / bare `#ns.if(@a > 5)`) and all function-call forms are covered.
|
|
97
|
+
|
|
98
|
+
## Extending with your own builders
|
|
99
|
+
|
|
100
|
+
The grammar is decoupled from the tree it builds. Every capitalized rule is a parseman `node()`; when you drive a grammar with a `build` host, each `node()` calls your host instead of constructing the default CST. Use parseman's `run` with your own host and the grammar's trivia rule:
|
|
101
|
+
|
|
102
|
+
```js
|
|
103
|
+
import { run } from 'parseman'
|
|
104
|
+
import { lessGrammar } from '@jesscss/less-parser/grammar'
|
|
105
|
+
|
|
106
|
+
const myHost = (type, children, fields, span) => ({ type, span, children: children.filter(Boolean) })
|
|
107
|
+
|
|
108
|
+
const result = run(lessGrammar.Stylesheet, '@c: red; .foo { color: @c; }', {
|
|
109
|
+
build: myHost,
|
|
110
|
+
trivia: lessGrammar.rw // Less trivia = whitespace + block + line comments
|
|
111
|
+
})
|
|
112
|
+
|
|
113
|
+
result.value // the root node your host returned
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
The `BuildHost` signature (from parseman):
|
|
117
|
+
|
|
118
|
+
```ts
|
|
119
|
+
type BuildHost = (
|
|
120
|
+
type: string,
|
|
121
|
+
children: readonly unknown[],
|
|
122
|
+
fields: FieldMap | undefined,
|
|
123
|
+
span: { start: number; end: number },
|
|
124
|
+
rawChildren: readonly unknown[],
|
|
125
|
+
triviaLog: readonly number[],
|
|
126
|
+
state: unknown
|
|
127
|
+
) => unknown
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
`parseLessCst(...)` is this pattern with the shared `cssCstBuildHost` (see `@jesscss/css-parser`, `src/cst.ts`) as a reference host.
|
|
131
|
+
|
|
132
|
+
## Part of Jess
|
|
133
|
+
|
|
134
|
+
This package is developed as part of [Jess](https://github.com/jesscss/jess). Jess translates a Less string into a Jess AST; the sections below track the migration rules that entails.
|
|
6
135
|
|
|
7
136
|
### Converting Less 1.x-5.x to Less 6
|
|
8
137
|
|
|
@@ -19,7 +148,6 @@ Translates a Less string to a Jess AST.
|
|
|
19
148
|
11. Don't allow `.class` as a value in a declaration. Convert to `\.class` e.g. `@foo: .class` should be converted to `@foo: \.class` (or `selector(.class)`?).
|
|
20
149
|
12. In a custom property value, convert `@variable` to `@{variable}`.
|
|
21
150
|
|
|
22
|
-
|
|
23
151
|
### Converting Less 1.x-4.x to Jess
|
|
24
152
|
|
|
25
153
|
1. Auto-wrap expressions (like math) with `$()`
|
|
@@ -33,4 +161,4 @@ Translates a Less string to a Jess AST.
|
|
|
33
161
|
8. Convert color names in expressions to hex values (or wrapped in `color()`?) (because Jess doesn't support color keywords in expressions). Alternatively, should Jess allow `keyword` to denote keywords?
|
|
34
162
|
9. Convert `@rest...` to `...rest`
|
|
35
163
|
10. Convert `.rules()` to `@include .rules()` if `.rules` is a selector. What if it's a selector and mixin? Maybe something like `@include .rules, $rules();`? This might change the execution order from Less though.
|
|
36
|
-
11. Convert `@foo: extract(@bar, 1)` to `@let foo: $bar[0];`?
|
|
164
|
+
11. Convert `@foo: extract(@bar, 1)` to `@let foo: $bar[0];`?
|
|
@@ -0,0 +1,381 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LessGrammar — builder methods for the Less grammar.
|
|
3
|
+
*
|
|
4
|
+
* Builder-only class: no grammar rules, no Parséman Parser base.
|
|
5
|
+
* Grammar rules live in grammar-fn.ts (macro-compiled functional grammar),
|
|
6
|
+
* which uses LessGrammar via a thin BuilderHost subclass.
|
|
7
|
+
* Extends CssParser to inherit the shared CSS builder methods.
|
|
8
|
+
*/
|
|
9
|
+
import type { FieldMap, Span } from 'parseman';
|
|
10
|
+
import type { CSTLeaf, CSTError } from 'parseman';
|
|
11
|
+
import { CssParser, type Spanned, type Component } from '@jesscss/css-parser/jess';
|
|
12
|
+
import { type Node, type LocationInfo, Ruleset, type MathMode, Quoted } from '@jesscss/core';
|
|
13
|
+
type JessNode = Node<any, any>;
|
|
14
|
+
type Child = JessNode | CSTLeaf | CSTError;
|
|
15
|
+
export declare class LessGrammar extends CssParser {
|
|
16
|
+
/** Math mode governing when arithmetic operates / when `/` divides. Less default. */
|
|
17
|
+
mathMode: MathMode;
|
|
18
|
+
/** Bare ident/keyword token in value or guard position. */
|
|
19
|
+
private _lessKeyword;
|
|
20
|
+
private _isKeywordLike;
|
|
21
|
+
private _isEmptyKeywordLike;
|
|
22
|
+
protected buildNode(type: string, span: Span, children: ReadonlyArray<JessNode | CSTLeaf | CSTError>, _state: unknown, _rawChildren: ReadonlyArray<{
|
|
23
|
+
_tag: string;
|
|
24
|
+
}>, fields?: FieldMap, triviaLog?: readonly number[]): JessNode;
|
|
25
|
+
/**
|
|
26
|
+
* The operand of a `Negative` (`-value`). The grammar emits the leading `-`
|
|
27
|
+
* as a leaf followed by the operand, which may itself be a node or a bare
|
|
28
|
+
* string terminal (e.g. `-@color` → `var(--color)`'s inner `-color-accent`).
|
|
29
|
+
* Prefer a node child; otherwise take the operand leaf's text so `Negative`
|
|
30
|
+
* coerces it to the canonical node form rather than receiving `undefined`.
|
|
31
|
+
*/
|
|
32
|
+
private _negativeOperand;
|
|
33
|
+
private _buildVarDeclaration;
|
|
34
|
+
/**
|
|
35
|
+
* Build a Less variable reference and its accessor/call chain. Faithful 1:1
|
|
36
|
+
* port of the Chevrotain `varReference` + `lookupOrCall` productions
|
|
37
|
+
* (productions/values.ts, productions/guards.ts): a `@var` base glued to a
|
|
38
|
+
* left-folded chain of `[index]` accessors and `(call)`s. The grammar's
|
|
39
|
+
* noTrivia() guarantees the chain is adjacent (no whitespace between segments).
|
|
40
|
+
*/
|
|
41
|
+
private _buildReference;
|
|
42
|
+
/**
|
|
43
|
+
* Build a namespace INDEXED-accessor value: a `.`/`#` selector-path head glued to
|
|
44
|
+
* a `[accessor]` (and any further `[accessor]`/`(call)` chain), e.g.
|
|
45
|
+
* `#ns.options[val1]`. The grammar (NsAccessor) captures this as ONE value operand
|
|
46
|
+
* so it survives arithmetic folding; here we reassemble it into the mixin-ruleset
|
|
47
|
+
* name Reference + accessor chain — the SAME shape the declaration-value
|
|
48
|
+
* _assembleSegment path produces for a lone `#ns.options[val1]`. Call-headed forms
|
|
49
|
+
* (`.mixin()`, `.mixin()[k]`) do NOT reach here (they keep the GluedParen path).
|
|
50
|
+
* Leaves: [ headText, '[', key?, ']', '(', content?, ')' … ].
|
|
51
|
+
*/
|
|
52
|
+
private _buildNsAccessor;
|
|
53
|
+
/**
|
|
54
|
+
* Apply one `[key]` accessor to `base`, reproducing lookupOrCall's key logic:
|
|
55
|
+
* type is `variable` when the key token starts with `@`, else `index`; the key
|
|
56
|
+
* text runs through getInterpolatedOrString (handling `$@x`/`@{x}` interpolation),
|
|
57
|
+
* and index keys are wrapped in a Quoted.
|
|
58
|
+
*/
|
|
59
|
+
private _applyReferenceAccessor;
|
|
60
|
+
/**
|
|
61
|
+
* Build mixin-call args for a `(…)` segment in a reference chain from the raw
|
|
62
|
+
* captured content. Comma-separated values become a List; an empty segment
|
|
63
|
+
* yields null (no args). Sub-structure here is intentionally shallow — the
|
|
64
|
+
* accessor-chain call form is rare and no consumer inspects nested arg shape.
|
|
65
|
+
*/
|
|
66
|
+
private _buildRefCallArgs;
|
|
67
|
+
private _buildNamedColor;
|
|
68
|
+
private _normalizeCompareOp;
|
|
69
|
+
/** A guard comparison operator leaf (`=`, `<`, `>=`, `=<`, `=~`, …). */
|
|
70
|
+
private _isCompareOpLeaf;
|
|
71
|
+
/**
|
|
72
|
+
* Split a guard term's ordered components into `left [op right]`. A bare-keyword
|
|
73
|
+
* operand (`foo`, `true`) is a leaf string — not a node — so `nodeChildren`
|
|
74
|
+
* alone drops it; walk the ordered stream so string operands become real
|
|
75
|
+
* keyword nodes (their guard truthiness is decided at eval by `Condition`).
|
|
76
|
+
*/
|
|
77
|
+
private _guardComparison;
|
|
78
|
+
private _buildComparison;
|
|
79
|
+
/**
|
|
80
|
+
* Coerce a `_assembleValue` result — a single Component or a raw space-group
|
|
81
|
+
* array — into ONE Node, so it can be a Condition operand. A single string
|
|
82
|
+
* becomes a keyword; a space-group array becomes a `Sequence` (the same coercion
|
|
83
|
+
* the List serializer applies to a raw group).
|
|
84
|
+
*/
|
|
85
|
+
private _condOperandNode;
|
|
86
|
+
/**
|
|
87
|
+
* `CondArgTerm` — a name-independent condition-argument term: optional leading
|
|
88
|
+
* `not`, a bounded value operand, and an optional `<op> right` comparison. Builds
|
|
89
|
+
* a `Condition` (comparison → `[left, op, right]`; bare `not` → `{negate:true}`)
|
|
90
|
+
* or, when neither a `not` nor a `compareOp` is present, the plain operand value
|
|
91
|
+
* (byte-identical to an ordinary value arg). Multi-token operands (`1px solid`)
|
|
92
|
+
* survive as a `Sequence`, unlike the single-operand guard path.
|
|
93
|
+
*/
|
|
94
|
+
private _buildCondArgTerm;
|
|
95
|
+
/**
|
|
96
|
+
* Fold a left-associative `and`/`or` chain of condition-arg terms into Conditions.
|
|
97
|
+
*
|
|
98
|
+
* Less accepts a bare `and`/`or` join in value-position condition args (`if(@a > 5
|
|
99
|
+
* and @b < 2, …)`) — verified against less@4.6.7 (`if`/`boolean` route their arg
|
|
100
|
+
* through `condition()` with no `needsParens`, so bare comparisons split on `and`/
|
|
101
|
+
* `or`). We keep accepting the bare form for Less parity, but NORMALIZE the AST so
|
|
102
|
+
* each join operand is `Paren`-wrapped: `@a > 5 and @b < 2` builds the SAME tree as
|
|
103
|
+
* the explicitly-parenthesised `(@a > 5) and (@b < 2)`. This is a structural
|
|
104
|
+
* normalisation only — `Paren(Condition)` evaluates to the same boolean as the bare
|
|
105
|
+
* `Condition`, so rendered CSS is byte-identical. A single unjoined operand (one
|
|
106
|
+
* node) is untouched (no synthetic Paren).
|
|
107
|
+
*/
|
|
108
|
+
private _buildCondArgJoin;
|
|
109
|
+
/** Coerce a default() call/reference into a DefaultGuard, mirroring isDefaultGuardCall. */
|
|
110
|
+
private _maybeDefaultGuard;
|
|
111
|
+
/** guardInParens: `(` guardOr `)` → Paren, or a bare default() → Paren(DefaultGuard). */
|
|
112
|
+
private _buildGuardInParens;
|
|
113
|
+
/** A single guard term: optional `not`, then a paren-guard or a comparison/value. */
|
|
114
|
+
private _buildGuardTerm;
|
|
115
|
+
/** Fold a left-associative chain of terms joined by `and` / `or`. */
|
|
116
|
+
private _buildGuardJoin;
|
|
117
|
+
/** guard: `when` guardOr — returns the single guardOr child. */
|
|
118
|
+
private _buildGuard;
|
|
119
|
+
/**
|
|
120
|
+
* Deprecated Less `%(format, args…)` string formatting, LOWERED at build time.
|
|
121
|
+
*
|
|
122
|
+
* Jess already has full string interpolation, so `%()` is redundant Less-4 legacy —
|
|
123
|
+
* we emit a `percent-format` deprecation warning and, when the format is a string
|
|
124
|
+
* literal, splice its `%[sda]` directives into the canonical `Interpolated` node
|
|
125
|
+
* (the same one `@{var}` string interpolation builds), wrapped in a `Quoted` that
|
|
126
|
+
* preserves the literal's quote char / escaped flag:
|
|
127
|
+
* - `%s` → bare interpolation slot (a Quoted arg inserts with its quotes stripped);
|
|
128
|
+
* - `%d`/`%a` → identical bare slot (d/a are the same in Less);
|
|
129
|
+
* - `%S`/`%D`/`%A` → the arg WRAPPED in `escape(…)` (URL-encode);
|
|
130
|
+
* - `%%` → a literal `%`.
|
|
131
|
+
* A dynamic (non-literal) format (`%(hello)`, `%(e("…"), …)`) can't be lowered at
|
|
132
|
+
* parse time, so it falls back to a best-effort runtime `%` Call with the same warning.
|
|
133
|
+
*/
|
|
134
|
+
private _buildFormatCall;
|
|
135
|
+
/**
|
|
136
|
+
* Turn a printf-style format string into an `Interpolated` source + replacements.
|
|
137
|
+
* `%[sda]` → one `INTERPOLATION_PLACEHOLDER` slot consuming the next positional arg
|
|
138
|
+
* (uppercase → wrapped in `escape(…)` to URL-encode); `%%` → a literal `%`.
|
|
139
|
+
*/
|
|
140
|
+
private _lowerFormatString;
|
|
141
|
+
private _buildInterpolatedSelector;
|
|
142
|
+
private _buildLessPseudo;
|
|
143
|
+
private _buildLessDeclaration;
|
|
144
|
+
/**
|
|
145
|
+
* Port of `processLegacyMSFilterToken` (lessRecursiveParser.ts): a `progid:…`
|
|
146
|
+
* filter value string → Interpolated(role=any) with `@var` runs templated out,
|
|
147
|
+
* or a plain Keyword when the run has no variables.
|
|
148
|
+
*/
|
|
149
|
+
private _buildLegacyMSFilter;
|
|
150
|
+
private _buildAmpersand;
|
|
151
|
+
/** The append value of a `&`-led ampersand token: the suffix after `&` (`&-bar` →
|
|
152
|
+
* `-bar`, `&1` → `1`), or undefined for a bare `&`. */
|
|
153
|
+
private _ampersandTemplateValue;
|
|
154
|
+
/**
|
|
155
|
+
* A single extend target inside `extend( … )`: a complex selector plus its
|
|
156
|
+
* optional `all` / `!all` flag (selectors.ts `complexSelector`'s OPTION2 flag).
|
|
157
|
+
* Produced as an `Extend` carrier the surrounding pseudo/statement groups.
|
|
158
|
+
*/
|
|
159
|
+
private _buildExtendTarget;
|
|
160
|
+
/**
|
|
161
|
+
* `:extend( … )` pseudo form (selectors.ts `extend`): groups its ExtendTarget
|
|
162
|
+
* children. Targets sharing one flag collapse to a single Extend whose target is
|
|
163
|
+
* a SelectorList (or the lone selector); mixed flags stay as one Extend each,
|
|
164
|
+
* returned in a List. Mirrors mergeExtends' target-and-flag grouping.
|
|
165
|
+
*/
|
|
166
|
+
private _buildExtendPseudo;
|
|
167
|
+
/**
|
|
168
|
+
* `&:extend( … );` (or bare `:extend( … );`) statement form (selectors.ts
|
|
169
|
+
* `ampersandExtend`). The ExtendPseudo child already carries the grouped
|
|
170
|
+
* Extend(s); the leading `&` is just the statement marker.
|
|
171
|
+
*/
|
|
172
|
+
private _buildExtendStatement;
|
|
173
|
+
/**
|
|
174
|
+
* Decode a single `[key]` accessor into its Less lookup-key AST — the ONE shared
|
|
175
|
+
* decoder for every accessor-chain builder path (var-decl value, declaration value,
|
|
176
|
+
* at-rule prelude, namespace ref). Accepts either a raw authored key STRING (the
|
|
177
|
+
* text inside the brackets, e.g. `@@foo`, `$@x`, `bar`, ``), or a SquareParen `Paren`
|
|
178
|
+
* node whose inner content the grammar already parsed (a raw string or a `@var`
|
|
179
|
+
* Reference). Returns the key exactly as the reference lookupOrCall production would:
|
|
180
|
+
*
|
|
181
|
+
* `[]` → -1 (index, empty)
|
|
182
|
+
* `[@@name]` → Reference{type:variable,key:name} (dynamic variable lookup)
|
|
183
|
+
* `[$@name]` / `[@$name]` → Quoted(Interpolated(@name)) (dynamic property lookup)
|
|
184
|
+
* `[@name]` → 'name' (static variable lookup; bare string key)
|
|
185
|
+
* `[$name]` → Quoted('name') (property lookup; `$` marker dropped)
|
|
186
|
+
* `[name]` → Quoted('name') (index)
|
|
187
|
+
*
|
|
188
|
+
* Exactly one `@`/`$` marker is the lookup marker and is never kept.
|
|
189
|
+
*/
|
|
190
|
+
private _decodeAccessorKey;
|
|
191
|
+
protected _assembleSegment(seg: Spanned[], loc: LocationInfo): Component;
|
|
192
|
+
private _buildEscapedValue;
|
|
193
|
+
private _buildInterpValue;
|
|
194
|
+
/**
|
|
195
|
+
* A quoted string value. Unlike plain CSS, Less interpolates `@{var}` / `${prop}`
|
|
196
|
+
* inside quoted (and escaped `~"…"`) strings and inside `@import` paths. When the
|
|
197
|
+
* raw content holds an interpolation, split it into an `Interpolated` value the same
|
|
198
|
+
* way the reference parser's `processStringInterpolation` does (source with
|
|
199
|
+
* INTERPOLATION_PLACEHOLDER, `@var`/`$prop` references in `replacements`); otherwise
|
|
200
|
+
* fall through to the plain CSS builder (bare-string value).
|
|
201
|
+
*/
|
|
202
|
+
/**
|
|
203
|
+
* The Less `Url` grammar tokenizes the inner string as bare leaves (no child
|
|
204
|
+
* node), so the css base builder wraps a quoted url body in a raw-string
|
|
205
|
+
* `Quoted` — which never interpolates `@{var}`/`${prop}`. Less 4.x DOES resolve
|
|
206
|
+
* interpolation inside a QUOTED url body (`url("@{base}/@{i}.svg")`), the same as
|
|
207
|
+
* any other quoted string, so route the quoted inner through the same
|
|
208
|
+
* interpolation-aware construction `_buildQuoted` uses. Unquoted url bodies stay
|
|
209
|
+
* verbatim (Less 4.x leaves `url(@{x})` literal), as does a quoted body with no
|
|
210
|
+
* interpolation.
|
|
211
|
+
*/
|
|
212
|
+
protected _buildUrl(children: ReadonlyArray<Child>, loc: LocationInfo): JessNode;
|
|
213
|
+
protected _buildQuoted(children: ReadonlyArray<Child>, loc: LocationInfo): JessNode | Quoted;
|
|
214
|
+
/**
|
|
215
|
+
* Build an escaped `~'…'` Quoted (at-rule prelude position), interpolating any
|
|
216
|
+
* `@{var}` / `${prop}` in its body the same way `_buildQuoted` does — so
|
|
217
|
+
* `~'@{a} / @{b}'` renders its substituted values instead of literal text.
|
|
218
|
+
*/
|
|
219
|
+
private _buildEscapedQuoted;
|
|
220
|
+
/**
|
|
221
|
+
* Split a quoted-string body on `@{…}` / `${…}` interpolations into an
|
|
222
|
+
* `Interpolated` (source + reference replacements). Port of the reference parser's
|
|
223
|
+
* `processStringInterpolation`/`findInterpolations` (productions/values.ts): brace
|
|
224
|
+
* matching is nesting-aware, and a nested-interpolated name resolves through a
|
|
225
|
+
* variable Reference wrapped in an Expression.
|
|
226
|
+
*/
|
|
227
|
+
private _buildStringInterpolation;
|
|
228
|
+
/**
|
|
229
|
+
* Locate `@{…}` / `${…}` interpolation runs in a string, counting nested braces so
|
|
230
|
+
* `@{@{x}}` and `@{fn(a, b)}` are matched whole. Returns start/end/prefix/content.
|
|
231
|
+
*/
|
|
232
|
+
private _findInterpolations;
|
|
233
|
+
protected _buildCall(rawChildren: ReadonlyArray<{
|
|
234
|
+
_tag: string;
|
|
235
|
+
}>, loc: LocationInfo): JessNode;
|
|
236
|
+
private _buildLessCustomDecl;
|
|
237
|
+
/**
|
|
238
|
+
* `--foo: { color: @a; }` — a curly-brace custom-property value whose body
|
|
239
|
+
* opportunistically structured as a declaration list (customCurlyBlock in the
|
|
240
|
+
* grammar), so nested `@var`/calls evaluate normally instead of staying opaque
|
|
241
|
+
* text. Wrapped in a Block(type: 'curly') so `{`/`}` re-render around it.
|
|
242
|
+
*/
|
|
243
|
+
private _buildLessCustomBlock;
|
|
244
|
+
private _warnDeprecatedValue;
|
|
245
|
+
private _warnCustomPropVars;
|
|
246
|
+
private _warnAtRulePreludeVars;
|
|
247
|
+
/**
|
|
248
|
+
* The first bare `@ident` reference in an at-rule prelude that is deprecated
|
|
249
|
+
* under Less 4.x PR #4462 (`variable-in-at-rule-prelude`), or null when there
|
|
250
|
+
* is none. A bare `@var` in a *structural* (top-level) prelude position still
|
|
251
|
+
* resolves but is deprecated in favour of `@{var}` interpolation; the scan
|
|
252
|
+
* therefore ignores, mirroring `hasTopLevelBareVariable` / `warnBareAtRuleVariable`:
|
|
253
|
+
* - the leading at-rule name itself (`@media`, `@-moz-document`, …);
|
|
254
|
+
* - `@{ident}` interpolation — the supported migration target;
|
|
255
|
+
* - a `@var` inside `(...)` — a declaration/feature value (e.g. the `@size`
|
|
256
|
+
* in `@media (min-width: @size)`), which stays valid;
|
|
257
|
+
* - `@`/`(` characters inside string literals, which are not structural.
|
|
258
|
+
*/
|
|
259
|
+
private _firstTopLevelBareAtVar;
|
|
260
|
+
private _buildMixinCall;
|
|
261
|
+
/**
|
|
262
|
+
* `@name(...)` (no `:`) → a detached-ruleset variable CALL. Faithful port of
|
|
263
|
+
* `varDeclarationOrCall`'s LParen branch (selectors.ts): build a `Reference`
|
|
264
|
+
* over the var name (`type: 'variable', role: 'name'`), wrap in a `Call` with
|
|
265
|
+
* the (optional) args, and wrap THAT in an `Expression` (a top-level variable
|
|
266
|
+
* call is an expression, not a parenthesized one). `!important` sets
|
|
267
|
+
* `markImportant` on the Call, mirroring the production.
|
|
268
|
+
*/
|
|
269
|
+
private _buildVarCall;
|
|
270
|
+
/** `...` or `@name...` variadic arg → `Rest`. Definition-shape (string name); a
|
|
271
|
+
* CALL turns it into `Rest(Reference)` via `_convertArgsForCall`. */
|
|
272
|
+
private _buildRest;
|
|
273
|
+
/** `@name: value` named arg/param → `VarDeclaration`. The value is assembled by the
|
|
274
|
+
* shared value builder (`_assembleValue`) — the same machinery as a declaration
|
|
275
|
+
* value, so trivia and Keyword-ification are handled and no manual trimming is
|
|
276
|
+
* needed. Named args flow through function calls too; the runtime decides whether
|
|
277
|
+
* the target accepts them. */
|
|
278
|
+
private _buildNamedArg;
|
|
279
|
+
/** Mixin-call args are assembled by the SAME builder as function-call args
|
|
280
|
+
* (`_assembleArgs` via `_betweenParens`) — identical comma/semicolon and value
|
|
281
|
+
* handling. Named args are `VarDeclaration`s and variadic args `Rest`, which pass
|
|
282
|
+
* through as single components. A bare `@name` is a `Reference` (the call shape);
|
|
283
|
+
* the mixin-DEFINITION builder reinterprets a lone `@name` as a param. */
|
|
284
|
+
private _buildMixinArgs;
|
|
285
|
+
/** Less forbids mixing the COMMA and SEMICOLON argument separators: once a
|
|
286
|
+
* semicolon separates args, a comma is a value-list separator, so a semicolon-group
|
|
287
|
+
* may not hold 2+ named params (`@a: 1, @b: 2`). `_assembleArgs` renders such a group
|
|
288
|
+
* as a List of ≥2 VarDeclarations. (This is purely about the `,` vs `;` argument
|
|
289
|
+
* separators — a `/` inside a value is unrelated and never checked.) Applies to BOTH
|
|
290
|
+
* mixin and function calls (args are unified). */
|
|
291
|
+
private _checkMixedArgDelimiters;
|
|
292
|
+
/**
|
|
293
|
+
* Lower Less `;`-separated call args to the unified Jess representation: the outer
|
|
294
|
+
* args `List{ sep: ';' }` becomes comma-separated, and each element that is itself
|
|
295
|
+
* a comma-`List` (a `;`-group that held a comma-list) is wrapped in an escaped
|
|
296
|
+
* `Paren` — the same shape Jess authors write as `~(1, 2)`. So
|
|
297
|
+
* `.mixin(1, 2; 3, 4)` and Jess `mixin(~(1, 2), ~(3, 4))` converge on one AST.
|
|
298
|
+
*
|
|
299
|
+
* The escaped `Paren` evaluates to its inner value STRIPPED (paren.ts §escaped),
|
|
300
|
+
* so `~(1, 2)` binds/renders identically to the bare list `1, 2` — representation
|
|
301
|
+
* only, semantics unchanged. Scalar (non-List) elements pass through untouched.
|
|
302
|
+
*
|
|
303
|
+
* MUST run AFTER `_checkMixedArgDelimiters` (which inspects the `;`-List).
|
|
304
|
+
*/
|
|
305
|
+
private _lowerSemiArgs;
|
|
306
|
+
/**
|
|
307
|
+
* Mixin-DEFINITION param conversion. With combinator-composed args a bare `@name`
|
|
308
|
+
* value parses as a `Reference{variable}` (the CALL shape); in a DEFINITION it is a
|
|
309
|
+
* param, so convert it to `VarDeclaration(name, Nil)`. Named params (`@a: 1`),
|
|
310
|
+
* variadic (`Rest`) and pattern-match values stay as-is. Returns a NEW List (the
|
|
311
|
+
* def/call split must not mutate a shared node).
|
|
312
|
+
*/
|
|
313
|
+
private _convertArgsForDefinition;
|
|
314
|
+
/**
|
|
315
|
+
* Mixin-CALL argument conversion (reference `convertArgsForCall`, root.ts).
|
|
316
|
+
* `_buildMixinArgs` builds bare `@name` args as definition-style VarDeclarations
|
|
317
|
+
* (Nil value) — correct for a DEFINITION param, but in a CALL a bare `@name` is a
|
|
318
|
+
* variable being PASSED, i.e. a `Reference{type:variable}`. Named args (`@a: 1`)
|
|
319
|
+
* and value args stay as-is; a `Rest('name')` becomes `Rest(Reference{variable})`.
|
|
320
|
+
* Returns a NEW List (the def/call split must not mutate a shared node).
|
|
321
|
+
*/
|
|
322
|
+
private _convertArgsForCall;
|
|
323
|
+
private _buildAnonMixin;
|
|
324
|
+
/**
|
|
325
|
+
* `each(<iterable>, { … })` → a `For` control node (the $for shape), not a Call.
|
|
326
|
+
* The value(s) before the comma are the iterable; the callback block's body becomes
|
|
327
|
+
* the loop rules. A literal block callback carries no captured params here, so the
|
|
328
|
+
* pattern defaults to the Less `[value, key, index]` triple.
|
|
329
|
+
*/
|
|
330
|
+
/** A bare detached ruleset `{ … }` in value / argument position → a Mixin holding
|
|
331
|
+
* its rules (same shape `@var: { … }` produces in `_buildVarDeclaration`). */
|
|
332
|
+
private _buildDetachedRuleset;
|
|
333
|
+
private _buildEachFor;
|
|
334
|
+
private _eachPattern;
|
|
335
|
+
private _buildMixinOrQualified;
|
|
336
|
+
private _extractExtendsFromSelectorText;
|
|
337
|
+
private _selectorHasNestedExtend;
|
|
338
|
+
private _treeHasExtend;
|
|
339
|
+
/**
|
|
340
|
+
* A guarded ruleset (`sel when …`) is parsed by the shared CSS builder, which
|
|
341
|
+
* has no `when` concept, so the Guard CST child folds into the body as the
|
|
342
|
+
* first rule — always a Paren/Condition/DefaultGuard. Lift it into the
|
|
343
|
+
* ruleset's `guard` field (rebuilt through the canonical Ruleset ctor so the
|
|
344
|
+
* guard is adopted) so it gates output instead of rendering as a `{ true }`
|
|
345
|
+
* body. Non-guarded rulesets never begin their body with one of these node
|
|
346
|
+
* types, so the leading-node check is unambiguous.
|
|
347
|
+
*/
|
|
348
|
+
private _liftRulesetGuard;
|
|
349
|
+
protected _buildRuleset(children: ReadonlyArray<Child>, rawChildren: ReadonlyArray<{
|
|
350
|
+
_tag: string;
|
|
351
|
+
}>, loc: LocationInfo): Ruleset;
|
|
352
|
+
private _extractExtendsFromSelector;
|
|
353
|
+
private static _isCssUrl;
|
|
354
|
+
private _buildImportAtRuleFromPrelude;
|
|
355
|
+
protected _buildAtRuleBlock(children: ReadonlyArray<Child>, loc: LocationInfo): JessNode;
|
|
356
|
+
/**
|
|
357
|
+
* Shared AtRule assembly used by both the flat `AtRuleBlock` builder and the
|
|
358
|
+
* structured, committed `QueryAtRuleBlock` builder. `preludeText` is the raw
|
|
359
|
+
* prelude source (already `{`/`}` stripped); routing it through
|
|
360
|
+
* `_buildAtRulePrelude` keeps the emitted AST identical regardless of which
|
|
361
|
+
* grammar rule matched.
|
|
362
|
+
*/
|
|
363
|
+
private _buildAtRuleFromParts;
|
|
364
|
+
/**
|
|
365
|
+
* Builder for the structured, committed `@media`/`@container`/`@supports`
|
|
366
|
+
* query block. The grammar rule parses the prelude with real query structure
|
|
367
|
+
* (so a stray/unbalanced bracket is rejected instead of swallowed) and commits
|
|
368
|
+
* on `expect('{')`, but the AST is reconstructed from the prelude source text
|
|
369
|
+
* via the shared `_buildAtRuleFromParts` path — so well-formed queries emit the
|
|
370
|
+
* exact same AtRule the flat `AtRuleBlock` builder would.
|
|
371
|
+
*/
|
|
372
|
+
private _buildLessQueryAtRuleBlock;
|
|
373
|
+
private _buildAtRulePrelude;
|
|
374
|
+
protected _buildAtRuleStatement(children: ReadonlyArray<Child>, loc: LocationInfo): JessNode;
|
|
375
|
+
private _buildUseAtRuleFromPrelude;
|
|
376
|
+
private _parenToArgs;
|
|
377
|
+
private _tryParseNamespaceRef;
|
|
378
|
+
private _assembleLessValue;
|
|
379
|
+
}
|
|
380
|
+
export {};
|
|
381
|
+
//# sourceMappingURL=builders.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"builders.d.ts","sourceRoot":"","sources":["../src/builders.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAC/C,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAClD,OAAO,EACL,SAAS,EACU,KAAK,OAAO,EAAE,KAAK,SAAS,EAChD,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EACL,KAAK,IAAI,EACT,KAAK,YAAY,EACI,OAAO,EAeC,KAAK,QAAQ,EAK1C,MAAM,EAOP,MAAM,eAAe,CAAC;AAMvB,KAAK,QAAQ,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AAC/B,KAAK,KAAK,GAAG,QAAQ,GAAG,OAAO,GAAG,QAAQ,CAAC;AAwB3C,qBAAa,WAAY,SAAQ,SAAS;IACxC,qFAAqF;IACrF,QAAQ,EAAE,QAAQ,CAAqB;IAEvC,2DAA2D;IAC3D,OAAO,CAAC,YAAY;IAIpB,OAAO,CAAC,cAAc;IAKtB,OAAO,CAAC,mBAAmB;IAQ3B,UAAmB,SAAS,CAC1B,IAAI,EAAE,MAAM,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,CAAC,YAAY;IAqEpB,OAAO,CAAC,qBAAqB;IAqN7B,OAAO,CAAC,kBAAkB;CAyB3B"}
|
package/lib/cst.cjs
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_grammar = require("./grammar.cjs");
|
|
3
|
+
let _jesscss_css_parser_cst = require("@jesscss/css-parser/cst");
|
|
4
|
+
//#region src/cst.ts
|
|
5
|
+
function parseLessCst(input, startRule = "Stylesheet", options) {
|
|
6
|
+
return (0, _jesscss_css_parser_cst.parseCst)(require_grammar.lessGrammar, input, startRule, options);
|
|
7
|
+
}
|
|
8
|
+
/** Incremental (`.edit()`-able) Less document — see `parseDocCst`. */
|
|
9
|
+
function parseLessDoc(input, startRule = "Stylesheet") {
|
|
10
|
+
return (0, _jesscss_css_parser_cst.parseDocCst)(require_grammar.lessGrammar, input, startRule);
|
|
11
|
+
}
|
|
12
|
+
//#endregion
|
|
13
|
+
exports.parseLessCst = parseLessCst;
|
|
14
|
+
exports.parseLessDoc = parseLessDoc;
|
package/lib/cst.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type CssCstNode, type CssCstParseOptions, type CssCstParseResult, type ParseDoc } from '@jesscss/css-parser/cst';
|
|
2
|
+
export declare function parseLessCst(input: string, startRule?: string, options?: CssCstParseOptions): CssCstParseResult;
|
|
3
|
+
/** Incremental (`.edit()`-able) Less document — see `parseDocCst`. */
|
|
4
|
+
export declare function parseLessDoc(input: string, startRule?: string): ParseDoc<CssCstNode>;
|
|
5
|
+
export type { CssCstChild as LessCstChild, CssCstError as LessCstError, CssCstLeaf as LessCstLeaf, CssCstNode as LessCstNode, CssCstParseOptions as LessCstParseOptions, CssCstParseResult as LessCstParseResult, CssCstType as LessCstType } from '@jesscss/css-parser/cst';
|
|
6
|
+
//# sourceMappingURL=cst.d.ts.map
|
package/lib/cst.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cst.d.ts","sourceRoot":"","sources":["../src/cst.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyB,KAAK,UAAU,EAAE,KAAK,kBAAkB,EAAE,KAAK,iBAAiB,EAAE,KAAK,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAGjJ,wBAAgB,YAAY,CAC1B,KAAK,EAAE,MAAM,EACb,SAAS,SAAe,EACxB,OAAO,CAAC,EAAE,kBAAkB,GAC3B,iBAAiB,CAEnB;AAED,sEAAsE;AACtE,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,SAAe,GAAG,QAAQ,CAAC,UAAU,CAAC,CAE1F;AAED,YAAY,EACV,WAAW,IAAI,YAAY,EAC3B,WAAW,IAAI,YAAY,EAC3B,UAAU,IAAI,WAAW,EACzB,UAAU,IAAI,WAAW,EACzB,kBAAkB,IAAI,mBAAmB,EACzC,iBAAiB,IAAI,kBAAkB,EACvC,UAAU,IAAI,WAAW,EAC1B,MAAM,yBAAyB,CAAC"}
|
package/lib/cst.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { lessGrammar } from "./grammar.js";
|
|
2
|
+
import { parseCst, parseDocCst } from "@jesscss/css-parser/cst";
|
|
3
|
+
//#region src/cst.ts
|
|
4
|
+
function parseLessCst(input, startRule = "Stylesheet", options) {
|
|
5
|
+
return parseCst(lessGrammar, input, startRule, options);
|
|
6
|
+
}
|
|
7
|
+
/** Incremental (`.edit()`-able) Less document — see `parseDocCst`. */
|
|
8
|
+
function parseLessDoc(input, startRule = "Stylesheet") {
|
|
9
|
+
return parseDocCst(lessGrammar, input, startRule);
|
|
10
|
+
}
|
|
11
|
+
//#endregion
|
|
12
|
+
export { parseLessCst, parseLessDoc };
|