@puruslang/prettier-plugin-purus 0.7.0 → 0.8.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 CHANGED
@@ -25,6 +25,13 @@ Purus — _/ˈpuː.rus/_ _**ラテン語で 純粋✨**_ — は、美しく、
25
25
 
26
26
  Purusは、 _Shiftキー_ をほとんど押さずにプログラミングできます。
27
27
 
28
+ ```purus
29
+ let name
30
+ name be ///Purus///
31
+ const message be ///Welcome to [name]!///
32
+ console.log[message] -- Welcome to Purus!
33
+ ```
34
+
28
35
  ## インストール
29
36
 
30
37
  ```sh
package/README.md CHANGED
@@ -25,6 +25,13 @@ Purus - _/ˈpuː.rus/_ _**means pure✨ in Latin**_ - is a beautiful, simple, an
25
25
 
26
26
  With Purus, you can write code almost without pressing the _Shift key_.
27
27
 
28
+ ```purus
29
+ let name
30
+ name be ///Purus///
31
+ const message be ///Welcome to [name]!///
32
+ console.log[message] -- Welcome to Purus!
33
+ ```
34
+
28
35
  ## Install
29
36
 
30
37
  ```sh
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@puruslang/prettier-plugin-purus",
3
- "version": "0.7.0",
3
+ "version": "0.8.0",
4
4
  "description": "Prettier plugin for the Purus language",
5
5
  "license": "Apache-2.0",
6
6
  "main": "src/index.js",
package/src/index.js CHANGED
@@ -4,25 +4,28 @@ const KEYWORDS = new Set([
4
4
  "const", "let", "var", "be",
5
5
  "fn", "async", "return", "to", "gives",
6
6
  "if", "elif", "else", "unless", "then",
7
- "while", "until", "for", "in", "range",
8
- "match", "when", "witch", "case",
7
+ "while", "until", "do", "for", "in", "range",
8
+ "match", "when", "switch", "case",
9
9
  "try", "catch", "finally", "throw",
10
10
  "import", "from", "export", "default", "require", "use", "namespace", "public", "all", "with",
11
- "add", "sub", "mul", "div", "mod", "neg", "pow",
11
+ "add", "sub", "mul", "div", "fdiv", "mod", "neg", "pow",
12
12
  "eq", "neq", "lt", "gt", "le", "ge",
13
13
  "and", "or", "not", "pipe", "coal",
14
- "is", "as", "of", "typeof", "instanceof", "type",
15
- "new", "delete", "this", "await",
16
- "class", "extends", "super", "static", "private", "get", "set",
17
- "true", "false", "null", "nil", "undefined", "nan",
14
+ "band", "bor", "bxor", "bnot", "shl", "shr", "ushr",
15
+ "as", "of", "typeof", "instanceof", "type",
16
+ "new", "delete", "this", "await", "yield", "void",
17
+ "class", "extends", "super", "static", "private", "protected", "get", "set",
18
+ "true", "false", "null", "nil", "undefined", "nan", "infinity",
18
19
  "break", "continue",
19
20
  "list", "object",
21
+ "function",
20
22
  ]);
21
23
 
22
24
  const BLOCK_STARTERS = new Set([
23
25
  "fn", "if", "elif", "else", "unless",
24
- "while", "until", "for",
25
- "match", "when", "witch", "case",
26
+ "while", "until", "do", "for",
27
+ "match", "when", "switch", "case",
28
+ "try", "catch", "finally", "class",
26
29
  ]);
27
30
 
28
31
  function tokenize(source) {
@@ -136,13 +139,25 @@ function tokenize(source) {
136
139
  continue;
137
140
  }
138
141
 
139
- // Number
142
+ // Number (decimal, 0b binary, 0x hex, BigInt n-suffix)
140
143
  if (/[0-9]/.test(source[i])) {
141
144
  let start = i;
142
- while (i < len && /[0-9]/.test(source[i])) i++;
143
- if (i < len && source[i] === "." && i + 1 < len && /[0-9]/.test(source[i + 1])) {
144
- i++;
145
+ if (source[i] === "0" && i + 1 < len && (source[i + 1] === "b" || source[i + 1] === "B")) {
146
+ i += 2;
147
+ while (i < len && /[01]/.test(source[i])) i++;
148
+ } else if (source[i] === "0" && i + 1 < len && (source[i + 1] === "x" || source[i + 1] === "X")) {
149
+ i += 2;
150
+ while (i < len && /[0-9a-fA-F]/.test(source[i])) i++;
151
+ } else {
145
152
  while (i < len && /[0-9]/.test(source[i])) i++;
153
+ if (i < len && source[i] === "." && i + 1 < len && /[0-9]/.test(source[i + 1])) {
154
+ i++;
155
+ while (i < len && /[0-9]/.test(source[i])) i++;
156
+ }
157
+ }
158
+ // BigInt suffix: n
159
+ if (i < len && source[i] === "n" && (i + 1 >= len || !/[a-zA-Z0-9_]/.test(source[i + 1]))) {
160
+ i++;
146
161
  }
147
162
  tokens.push({ type: "number", value: source.slice(start, i) });
148
163
  continue;