@jesscss/less-parser 2.0.0-alpha.8 → 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.
Files changed (58) hide show
  1. package/README.md +27 -10
  2. package/lib/ast/grammar.d.ts +2 -0
  3. package/lib/ast/grammar.d.ts.map +1 -0
  4. package/lib/grammar.cjs +39855 -31054
  5. package/lib/grammar.d.ts.map +1 -1
  6. package/lib/grammar.js +39855 -31054
  7. package/lib/index.cjs +49609 -15
  8. package/lib/index.d.ts +4 -9
  9. package/lib/index.d.ts.map +1 -1
  10. package/lib/index.js +49607 -5
  11. package/lib/parse-error.d.ts +15 -0
  12. package/lib/parse-error.d.ts.map +1 -0
  13. package/package.json +9 -24
  14. package/lib/builders.d.ts +0 -381
  15. package/lib/builders.d.ts.map +0 -1
  16. package/lib/functional-parser.cjs +0 -2654
  17. package/lib/functional-parser.d.ts +0 -18
  18. package/lib/functional-parser.d.ts.map +0 -1
  19. package/lib/functional-parser.js +0 -2589
  20. package/lib/jess.cjs +0 -3968
  21. package/lib/jess.d.ts +0 -7
  22. package/lib/jess.d.ts.map +0 -1
  23. package/lib/jess.js +0 -3962
  24. package/lib/lessParser.d.ts +0 -38
  25. package/lib/lessParser.d.ts.map +0 -1
  26. package/lib/lessRecursiveParser.d.ts +0 -99
  27. package/lib/lessRecursiveParser.d.ts.map +0 -1
  28. package/lib/lessTokens.d.ts +0 -23
  29. package/lib/lessTokens.d.ts.map +0 -1
  30. package/lib/productions/guards.d.ts +0 -113
  31. package/lib/productions/guards.d.ts.map +0 -1
  32. package/lib/productions/index.d.ts +0 -5
  33. package/lib/productions/index.d.ts.map +0 -1
  34. package/lib/productions/root.d.ts +0 -38
  35. package/lib/productions/root.d.ts.map +0 -1
  36. package/lib/productions/selectors.d.ts +0 -41
  37. package/lib/productions/selectors.d.ts.map +0 -1
  38. package/lib/productions/values.d.ts +0 -35
  39. package/lib/productions/values.d.ts.map +0 -1
  40. package/lib/utils.d.ts +0 -9
  41. package/lib/utils.d.ts.map +0 -1
  42. package/src/__tests__/debug-log.ts +0 -35
  43. package/src/__tests__/wall5-parse.test.ts +0 -67
  44. package/src/builders.ts +0 -3190
  45. package/src/cst.ts +0 -25
  46. package/src/functional-parser.ts +0 -162
  47. package/src/grammar.ts +0 -870
  48. package/src/index.ts +0 -19
  49. package/src/jess.ts +0 -6
  50. package/src/lessParser.ts +0 -120
  51. package/src/lessRecursiveParser.ts +0 -279
  52. package/src/lessTokens.ts +0 -350
  53. package/src/productions/guards.ts +0 -1066
  54. package/src/productions/index.ts +0 -29
  55. package/src/productions/root.ts +0 -1613
  56. package/src/productions/selectors.ts +0 -1309
  57. package/src/productions/values.ts +0 -1449
  58. package/src/utils.ts +0 -178
package/README.md CHANGED
@@ -1,8 +1,11 @@
1
1
  # @jesscss/less-parser
2
2
 
3
- The Less grammar, layered on the CSS base parser the parser behind the language Jess ships today.
3
+ The Less grammar, layered on the CSS base parser, with core-free CST entry points.
4
4
 
5
- > **Status: alpha.** Part of [Jess](https://github.com/jesscss/jess), which *is* Less.js v5. Rendering `.less` is the one surface shipping today; everything else is roadmap. Expect gaps and [report bugs](https://github.com/jesscss/jess/issues). Docs live at [jesscss.github.io](https://jesscss.github.io/).
5
+ > **Status: alpha.** Part of [Jess](https://github.com/jesscss/jess). The broader
6
+ > language/tooling picture is still early. Expect gaps and
7
+ > [report bugs](https://github.com/jesscss/jess/issues). Docs live at
8
+ > [jesscss.github.io](https://jesscss.github.io/).
6
9
 
7
10
  ## What it is
8
11
 
@@ -17,10 +20,10 @@ general-purpose JavaScript parser** in its
17
20
  Jess uses when it compiles `.less` — the "Now" tier of the language roadmap, and
18
21
  the one dialect shipping in the alpha.
19
22
 
20
- Two ways to use it:
21
-
22
- - **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.
23
- - **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.
23
+ The default `parse()` operation constructs canonical AST v2 `Stylesheet` directly
24
+ through parser-local Parseman reductions. Use the explicit `./cst` entry when a
25
+ language-service or document consumer needs a CST. The package has no
26
+ core-owned parser driver or AST construction host.
24
27
 
25
28
  ## Install
26
29
 
@@ -28,7 +31,20 @@ Two ways to use it:
28
31
  npm install @jesscss/less-parser
29
32
  ```
30
33
 
31
- `@jesscss/core` is an **optional** peer dependency needed only for the core-coupled `.` entry, not for `./cst` or `./grammar`.
34
+ `@jesscss/core` is an optional peer for consumers using the default AST v2
35
+ `parse()` result. The explicit CST and grammar subpaths remain core-free.
36
+ Those explicit entries expose Parseman types and grammar values, so consumers
37
+ of them must also provide the package's `parseman` peer.
38
+
39
+ ## Canonical AST parsing
40
+
41
+ ```js
42
+ import { parse } from '@jesscss/less-parser'
43
+
44
+ const stylesheet = parse('@c: red;\n.foo { color: @c; }')
45
+
46
+ stylesheet.type // 'Stylesheet'
47
+ ```
32
48
 
33
49
  ## Standalone usage (core-free)
34
50
 
@@ -58,8 +74,7 @@ Pass a different `startRule` (any capitalized grammar rule, e.g. `'SelectorList'
58
74
  | `@jesscss/less-parser/cst` | `parseLessCst` | Core-free parse of a Less string to a CST. |
59
75
  | `@jesscss/less-parser/cst` | `LessCstNode`, `LessCstLeaf`, `LessCstError`, `LessCstChild`, `LessCstParseResult`, `LessCstType` (types) | CST type definitions (aliases of the shared `@jesscss/css-parser/cst` types). |
60
76
  | `@jesscss/less-parser/grammar` | `lessGrammar` | The compiled Less grammar (a rule map). Extend it with `compose()` or drive it directly with parseman's `run`. |
61
- | `@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`. |
62
- | `@jesscss/less-parser/jess` | `LessParser`, `LessGrammar`, `parseLessFn`, … | Internal Jess-facing surface. |
77
+ | `@jesscss/less-parser` (`.`) | `parse` | Parse Less directly to canonical AST v2 `Stylesheet`. It does not load the CST grammar. |
63
78
 
64
79
  ## Default CST shape
65
80
 
@@ -146,4 +161,6 @@ type BuildHost = (
146
161
 
147
162
  ## Part of Jess
148
163
 
149
- This package is developed as part of [Jess](https://github.com/jesscss/jess), the Less.js v5 rewrite. Jess translates a Less string into the core Jess AST, which the compiler then evaluates and renders to CSS. Licensed MIT.
164
+ This package is developed as part of [Jess](https://github.com/jesscss/jess).
165
+ Jess translates a Less string into the core Jess AST, which the compiler then
166
+ evaluates and renders to CSS. Licensed MIT.
@@ -0,0 +1,2 @@
1
+ export declare const lessAstGrammar: Record<string, import("parseman").FusedRule>;
2
+ //# sourceMappingURL=grammar.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"grammar.d.ts","sourceRoot":"","sources":["../../src/ast/grammar.ts"],"names":[],"mappings":"AA49CA,eAAO,MAAM,cAAc,8CAuhGvB,CAAC"}