@jesscss/scss-parser 2.0.0-alpha.7 → 2.0.0-alpha.9
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 +54 -12
- package/lib/ast/grammar.cjs +36610 -0
- package/lib/ast/grammar.d.ts +1 -0
- package/lib/ast/grammar.js +36609 -0
- package/lib/ast/lower-user-function-calls.d.ts +6 -0
- package/lib/cst.cjs +1 -1
- package/lib/cst.js +1 -1
- package/lib/grammar.cjs +2 -55568
- package/lib/grammar.js +1 -55567
- package/lib/grammar2.cjs +88858 -0
- package/lib/grammar2.js +88853 -0
- package/lib/index.cjs +108 -11
- package/lib/index.d.ts +10 -7
- package/lib/index.js +107 -5
- package/package.json +10 -20
- package/lib/builders.d.ts +0 -154
- package/lib/functional-parser.cjs +0 -2872
- package/lib/functional-parser.d.ts +0 -46
- package/lib/functional-parser.js +0 -2855
- package/lib/interp.d.ts +0 -26
- package/lib/jess.cjs +0 -6
- package/lib/jess.d.ts +0 -2
- package/lib/jess.js +0 -2
- package/lib/scss-atroot-helpers.d.ts +0 -4
- package/lib/scss-atrule-helpers.d.ts +0 -36
- package/lib/scss-value-helpers.d.ts +0 -11
- package/src/builders.ts +0 -1408
- package/src/cst.ts +0 -25
- package/src/functional-parser.ts +0 -135
- package/src/grammar.ts +0 -621
- package/src/index.ts +0 -14
- package/src/interp.ts +0 -158
- package/src/jess.ts +0 -11
- package/src/scss-atroot-helpers.ts +0 -105
- package/src/scss-atrule-helpers.ts +0 -191
- package/src/scss-value-helpers.ts +0 -105
package/README.md
CHANGED
|
@@ -1,13 +1,40 @@
|
|
|
1
1
|
# @jesscss/scss-parser
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
3
|
+
An SCSS grammar for Jess, layered on the CSS base parser — **experimental, and not the focus of the Less alpha.**
|
|
4
|
+
|
|
5
|
+
> **Status: experimental / roadmap.** Part of
|
|
6
|
+
> [Jess](https://github.com/jesscss/jess). The current alpha ships through
|
|
7
|
+
> `.less`; SCSS is **not a goal of this phase**. This parser is early and exists
|
|
8
|
+
> to seed the future **"Sass+"** dialect. Don't rely on it for production;
|
|
9
|
+
> prefer [`@jesscss/css-parser`](https://www.npmjs.com/package/@jesscss/css-parser)
|
|
10
|
+
> / [`@jesscss/less-parser`](https://www.npmjs.com/package/@jesscss/less-parser).
|
|
11
|
+
> [Report bugs](https://github.com/jesscss/jess/issues); docs live at
|
|
12
|
+
> [jesscss.github.io](https://jesscss.github.io/).
|
|
13
|
+
|
|
14
|
+
## What it is
|
|
15
|
+
|
|
16
|
+
The SCSS grammar is the shared CSS grammar plus an SCSS delta:
|
|
17
|
+
`scssGrammar = compose([cssGrammar, <SCSS delta>])`, layered on the spec-aligned
|
|
18
|
+
CSS base in `@jesscss/css-parser` and built on
|
|
19
|
+
[parseman](https://www.npmjs.com/package/parseman) — **the fastest
|
|
20
|
+
general-purpose JavaScript parser** in its
|
|
21
|
+
[published benchmarks](https://matthew-dean.github.io/parseman/guide/benchmarks)
|
|
22
|
+
(see `@jesscss/css-parser` for figures and engineering details).
|
|
23
|
+
|
|
24
|
+
The current goal is **parse coverage**: the surface `$`-variable / SCSS syntax
|
|
25
|
+
should parse into a tree, but not every Sass/SCSS feature is necessarily
|
|
26
|
+
*evaluated*. This is the least-mature of the Jess parsers (the `.jess` parser
|
|
27
|
+
trails it), and the seed for the roadmap "Sass+" dialect rather than a shipped
|
|
28
|
+
Sass replacement. The language roadmap is ordered: **Now Less.js → Next Sass+ →
|
|
29
|
+
Final `.jess`.**
|
|
30
|
+
|
|
31
|
+
Two parser representations are available:
|
|
32
|
+
|
|
33
|
+
- **Canonical AST v2** — the default `parse()` entry constructs a `Stylesheet`
|
|
34
|
+
directly through parser-local Parseman reductions.
|
|
35
|
+
- **Explicit CST** — the `./cst` entry has **no dependency on
|
|
36
|
+
`@jesscss/core`** and parses SCSS source text into a concrete syntax tree for
|
|
37
|
+
language-service/document consumers.
|
|
11
38
|
|
|
12
39
|
## Install
|
|
13
40
|
|
|
@@ -15,7 +42,20 @@ Two ways to use it:
|
|
|
15
42
|
npm install @jesscss/scss-parser
|
|
16
43
|
```
|
|
17
44
|
|
|
18
|
-
`@jesscss/core` is an **optional** peer dependency — needed
|
|
45
|
+
`@jesscss/core` is an **optional** peer dependency — needed for the default
|
|
46
|
+
AST v2 `parse()` entry, not for `./cst` or `./grammar`.
|
|
47
|
+
Those explicit entries expose Parseman types and grammar values, so consumers
|
|
48
|
+
of them must also provide the package's `parseman` peer.
|
|
49
|
+
|
|
50
|
+
## Canonical AST parsing
|
|
51
|
+
|
|
52
|
+
```js
|
|
53
|
+
import { parse } from '@jesscss/scss-parser'
|
|
54
|
+
|
|
55
|
+
const stylesheet = parse('$c: red;\n.foo { color: $c; }')
|
|
56
|
+
|
|
57
|
+
stylesheet.type // 'Stylesheet'
|
|
58
|
+
```
|
|
19
59
|
|
|
20
60
|
## Standalone usage (core-free)
|
|
21
61
|
|
|
@@ -45,8 +85,7 @@ Pass a different `startRule` (any capitalized grammar rule) to parse a fragment.
|
|
|
45
85
|
| `@jesscss/scss-parser/cst` | `parseScssCst` | Core-free parse of an SCSS string to a CST. |
|
|
46
86
|
| `@jesscss/scss-parser/cst` | `ScssCstNode`, `ScssCstLeaf`, `ScssCstError`, `ScssCstChild`, `ScssCstParseResult`, `ScssCstType` (types) | CST type definitions (aliases of the shared `@jesscss/css-parser/cst` types). |
|
|
47
87
|
| `@jesscss/scss-parser/grammar` | `scssGrammar` | The compiled SCSS grammar (a rule map). Extend it with `compose()` or drive it directly with parseman's `run`. |
|
|
48
|
-
| `@jesscss/scss-parser` (`.`) | `
|
|
49
|
-
| `@jesscss/scss-parser/jess` | `ScssParser`, `ScssGrammar`, `parseScssFn`, … | Internal Jess-facing surface. |
|
|
88
|
+
| `@jesscss/scss-parser` (`.`) | `parse` | Parse SCSS directly to canonical AST v2 `Stylesheet`. It does not load the CST grammar. |
|
|
50
89
|
|
|
51
90
|
## Default CST shape
|
|
52
91
|
|
|
@@ -129,4 +168,7 @@ type BuildHost = (
|
|
|
129
168
|
|
|
130
169
|
## Part of Jess
|
|
131
170
|
|
|
132
|
-
This package is developed as part of [Jess](https://github.com/jesscss/jess).
|
|
171
|
+
This package is developed as part of [Jess](https://github.com/jesscss/jess).
|
|
172
|
+
SCSS is the least-mature Jess dialect and is not the focus of the current
|
|
173
|
+
alpha; it seeds the roadmap "Sass+" dialect. For production use, prefer
|
|
174
|
+
`@jesscss/css-parser` / `@jesscss/less-parser`. Licensed MIT.
|