@puruslang/prettier-plugin-purus 0.3.0 → 0.4.0
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-ja.md +14 -0
- package/README.md +14 -0
- package/package.json +2 -3
- package/src/index.js +25 -4
package/README-ja.md
CHANGED
|
@@ -8,8 +8,12 @@
|
|
|
8
8
|
|
|
9
9
|
---
|
|
10
10
|
|
|
11
|
+
[](https://github.com/otoneko1102/purus/actions/workflows/ci.yml)
|
|
11
12
|
[](https://www.npmjs.com/package/purus)
|
|
12
13
|
[](https://www.npmjs.com/package/purus)
|
|
14
|
+
[](https://github.com/otoneko1102/purus/blob/main/LICENSE)
|
|
15
|
+
[](https://nodejs.org/)
|
|
16
|
+
[](https://marketplace.visualstudio.com/items?itemName=otoneko1102.purus)
|
|
13
17
|
[](https://github.com/otoneko1102/purus/pulse)
|
|
14
18
|
[](https://github.com/otoneko1102/purus/commits/main)
|
|
15
19
|

|
|
@@ -49,6 +53,16 @@ npm install -D purus
|
|
|
49
53
|
|
|
50
54
|
ドキュメントは [purus.work](https://purus.work) で確認できます。
|
|
51
55
|
|
|
56
|
+
## 貢献
|
|
57
|
+
|
|
58
|
+
ガイドは [コチラ](https://github.com/otoneko1102/purus/blob/main/CONTRIBUTING-ja.md) !
|
|
59
|
+
|
|
60
|
+
<a href="https://github.com/otoneko1102/purus/graphs/contributors">
|
|
61
|
+
<img src="https://contrib.rocks/image?repo=otoneko1102/purus" />
|
|
62
|
+
</a>
|
|
63
|
+
|
|
64
|
+
Made with [contrib.rocks](https://contrib.rocks).
|
|
65
|
+
|
|
52
66
|
## 著者
|
|
53
67
|
|
|
54
68
|
otoneko. https://github.com/otoneko1102
|
package/README.md
CHANGED
|
@@ -8,8 +8,12 @@
|
|
|
8
8
|
|
|
9
9
|
---
|
|
10
10
|
|
|
11
|
+
[](https://github.com/otoneko1102/purus/actions/workflows/ci.yml)
|
|
11
12
|
[](https://www.npmjs.com/package/purus)
|
|
12
13
|
[](https://www.npmjs.com/package/purus)
|
|
14
|
+
[](https://github.com/otoneko1102/purus/blob/main/LICENSE)
|
|
15
|
+
[](https://nodejs.org/)
|
|
16
|
+
[](https://marketplace.visualstudio.com/items?itemName=otoneko1102.purus)
|
|
13
17
|
[](https://github.com/otoneko1102/purus/pulse)
|
|
14
18
|
[](https://github.com/otoneko1102/purus/commits/main)
|
|
15
19
|

|
|
@@ -49,6 +53,16 @@ npm install -D purus
|
|
|
49
53
|
|
|
50
54
|
The documentation is available on [purus.work](https://purus.work).
|
|
51
55
|
|
|
56
|
+
## Contribute
|
|
57
|
+
|
|
58
|
+
The guide is [here](https://github.com/otoneko1102/purus/blob/main/CONTRIBUTING.md)!
|
|
59
|
+
|
|
60
|
+
<a href="https://github.com/otoneko1102/purus/graphs/contributors">
|
|
61
|
+
<img src="https://contrib.rocks/image?repo=otoneko1102/purus" />
|
|
62
|
+
</a>
|
|
63
|
+
|
|
64
|
+
Made with [contrib.rocks](https://contrib.rocks).
|
|
65
|
+
|
|
52
66
|
## Author
|
|
53
67
|
|
|
54
68
|
otoneko. https://github.com/otoneko1102
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@puruslang/prettier-plugin-purus",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Prettier plugin for the Purus language",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "src/index.js",
|
|
@@ -11,8 +11,7 @@
|
|
|
11
11
|
"altjs",
|
|
12
12
|
"lang",
|
|
13
13
|
"language",
|
|
14
|
-
"noshift"
|
|
15
|
-
"noshift.js"
|
|
14
|
+
"noshift"
|
|
16
15
|
],
|
|
17
16
|
"peerDependencies": {
|
|
18
17
|
"prettier": "^3.0.0"
|
package/src/index.js
CHANGED
|
@@ -10,7 +10,7 @@ const KEYWORDS = new Set([
|
|
|
10
10
|
"import", "from", "export", "default", "require", "use", "namespace", "pub", "all",
|
|
11
11
|
"add", "sub", "mul", "div", "mod", "neg", "pow",
|
|
12
12
|
"eq", "neq", "lt", "gt", "le", "ge",
|
|
13
|
-
"and", "or", "not", "pipe",
|
|
13
|
+
"and", "or", "not", "pipe", "coal",
|
|
14
14
|
"is", "as", "of", "typeof", "instanceof", "type",
|
|
15
15
|
"new", "delete", "this", "await",
|
|
16
16
|
"true", "false", "null", "nil", "undefined",
|
|
@@ -101,16 +101,37 @@ function tokenize(source) {
|
|
|
101
101
|
}
|
|
102
102
|
|
|
103
103
|
// Punctuation
|
|
104
|
-
if ("[]
|
|
104
|
+
if ("[],;".includes(source[i])) {
|
|
105
|
+
tokens.push({ type: "punct", value: source[i] });
|
|
106
|
+
i++;
|
|
107
|
+
continue;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// Optional chaining \.
|
|
111
|
+
if (source[i] === "\\" && source[i + 1] === ".") {
|
|
112
|
+
tokens.push({ type: "punct", value: "\\." });
|
|
113
|
+
i += 2;
|
|
114
|
+
continue;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// Backslash (computed access prefix)
|
|
118
|
+
if (source[i] === "\\") {
|
|
119
|
+
tokens.push({ type: "punct", value: "\\" });
|
|
120
|
+
i++;
|
|
121
|
+
continue;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// Dot
|
|
125
|
+
if (source[i] === ".") {
|
|
105
126
|
tokens.push({ type: "punct", value: source[i] });
|
|
106
127
|
i++;
|
|
107
128
|
continue;
|
|
108
129
|
}
|
|
109
130
|
|
|
110
131
|
// Word (identifier or keyword)
|
|
111
|
-
if (/[a-zA-
|
|
132
|
+
if (/[a-zA-Z_]/.test(source[i])) {
|
|
112
133
|
let start = i;
|
|
113
|
-
while (i < len && /[a-zA-Z0-
|
|
134
|
+
while (i < len && /[a-zA-Z0-9_-]/.test(source[i])) i++;
|
|
114
135
|
const word = source.slice(start, i);
|
|
115
136
|
tokens.push({ type: KEYWORDS.has(word) ? "keyword" : "ident", value: word });
|
|
116
137
|
continue;
|