@fluixi/template-parser 0.1.0-alpha.3 → 0.1.0-alpha.4
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 +9 -7
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -3,9 +3,11 @@
|
|
|
3
3
|
The parser for Fluixi `` html`...` `` templates: a dependency-free tokenizer +
|
|
4
4
|
recursive-descent parser that produces a **located, recoverable Template AST**.
|
|
5
5
|
|
|
6
|
-
It is the shared foundation for everything that needs to understand a template
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
It is the shared foundation for everything that needs to understand a template. Today that
|
|
7
|
+
is [`@fluixi/compiler`](../compiler) and [`@fluixi/ts-plugin`](../ts-plugin); the point of
|
|
8
|
+
splitting it out is that they agree on one grammar, one node model and one set of
|
|
9
|
+
diagnostics, and that a formatter or a language server can join later without a second
|
|
10
|
+
grammar appearing.
|
|
9
11
|
|
|
10
12
|
## Why a separate parser
|
|
11
13
|
|
|
@@ -17,14 +19,14 @@ parse layer split out so every tool can reuse it:
|
|
|
17
19
|
```
|
|
18
20
|
pieces → Reader (lexing + holes) → parseTemplate → Template AST
|
|
19
21
|
│
|
|
20
|
-
|
|
21
|
-
|
|
22
|
+
┌─────────────────────────────────┴──────┐
|
|
23
|
+
compiler (→ IR) TS plugin
|
|
22
24
|
```
|
|
23
25
|
|
|
24
26
|
The parser never resolves the JavaScript inside `${…}`. Each hole is recorded as
|
|
25
27
|
an **opaque slot** (an index + a source span). Downstream, each tool binds slots
|
|
26
|
-
to its own representation — a Babel node in the compiler, a `ts.Expression` in the
|
|
27
|
-
|
|
28
|
+
to its own representation — a Babel node in the compiler, a `ts.Expression` in the TS
|
|
29
|
+
plugin, raw text in a formatter. That single seam is what keeps the parser host-agnostic.
|
|
28
30
|
|
|
29
31
|
## Usage
|
|
30
32
|
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluixi/template-parser",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.4",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"private": false,
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"registry": "https://registry.npmjs.org/",
|
|
8
8
|
"access": "public"
|
|
9
9
|
},
|
|
10
|
-
"description": "
|
|
10
|
+
"description": "dependency-free tokenizer and recursive-descent parser for html`` templates, producing a located, recoverable AST; shared by the compiler and the TypeScript plugin",
|
|
11
11
|
"type": "module",
|
|
12
12
|
"files": [
|
|
13
13
|
"dist",
|