@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 CHANGED
@@ -1,13 +1,40 @@
1
1
  # @jesscss/scss-parser
2
2
 
3
- A [SCSS/Sass](https://sass-lang.com/) parser built on [parseman](https://www.npmjs.com/package/parseman). The grammar is the CSS grammar plus an SCSS delta: `scssGrammar = compose([cssGrammar, <SCSS delta>])`, layered on the shared CSS base in `@jesscss/css-parser`.
4
-
5
- The goal is **parse coverage**: not every Sass/SCSS feature is necessarily *evaluated*, but the surface syntax should parse. This is the earliest-stage of the four Jess parsers (`2.0.0-alpha.1`).
6
-
7
- Two ways to use it:
8
-
9
- - **As part of Jess** — the default `.` entry is wired into `@jesscss/core` and produces the core AST the Jess compiler evaluates. This is the internal, core-coupled path.
10
- - **As a standalone CST parser** — the `./cst` entry has **no dependency on `@jesscss/core`**. Install just this package and parse SCSS 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.
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 only for the core-coupled `.` entry, not for `./cst` or `./grammar`.
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` (`.`) | `ScssParser` (also `Parser`), `parseScssFn`, `scssGrammar`, tokens, | The Jess-internal barrel. **Core-coupled** (the functional parser builds the core AST). Prefer `./cst` if you don't need `@jesscss/core`. |
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). The core-coupled `.` entry integrates with `@jesscss/core`; the `./cst` and `./grammar` entries are usable on their own. SCSS is the least-mature of the Jess dialects — prefer `@jesscss/css-parser` / `@jesscss/less-parser` for production use.
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.