Skip to content

Commit fabe36f

Browse files
committed
feat: add XOR operator support and update related documentation
1 parent 369cc0c commit fabe36f

19 files changed

Lines changed: 60 additions & 33 deletions

File tree

README-ja.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
| `^8` | `(` | | `^,` | `<` |
4040
| `^9` | `)` | | `^.` | `>` |
4141
| `^-` | `=` | | `^/` | `?` |
42+
| `^0` | `^` (XOR) | | | |
4243

4344
テンプレート式: `^4^[``${`
4445

@@ -57,8 +58,8 @@ nsc create
5758

5859
```nsjs
5960
// src/index.nsjs
60-
const name ^- ^2NoShift.js^2;
61-
console.log^8^2Hello from ^2 ^; name ^; ^2!^2^9;
61+
const name ^- ^2^3no^3shift.js^2;
62+
console.log^8^2^3hello from ^2 ^; name ^; ^2!^2^9;
6263
```
6364

6465
コンパイル後:

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ Typing shifted symbols (`!`, `"`, `(`, `)`, `{`, `}` …) is tiring.
4040
| `^8` | `(` | | `^,` | `<` |
4141
| `^9` | `)` | | `^.` | `>` |
4242
| `^-` | `=` | | `^/` | `?` |
43+
| `^0` | `^` (XOR) | | | |
4344

4445
Template expression: `^4^[``${`
4546

@@ -58,8 +59,8 @@ nsc create
5859

5960
```nsjs
6061
// src/index.nsjs
61-
const name ^- ^2NoShift.js^2;
62-
console.log^8^2Hello from ^2 ^; name ^; ^2!^2^9;
62+
const name ^- ^2^3no^3shift.js^2;
63+
console.log^8^2^3hello from ^2 ^; name ^; ^2!^2^9;
6364
```
6465

6566
Compiles to:

npm/README-ja.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ nsc init
9999
| `^8` | `(` | | `^,` | `<` |
100100
| `^9` | `)` | | `^.` | `>` |
101101
| `^-` | `=` | | `^/` | `?` |
102+
| `^0` | `^` (XOR) | | | |
102103

103104
テンプレート式: `^4^[``${`
104105

@@ -109,7 +110,7 @@ nsc init
109110
### Hello World
110111

111112
```nsjs
112-
console.log^8^2Hello, World!^2^9;
113+
console.log^8^2^3hello, ^3world!^2^9;
113114
```
114115

115116
```js
@@ -174,10 +175,10 @@ console.log(result); // 8
174175

175176
```nsjs
176177
// ダブルクォート文字列
177-
const s1 ^- ^2Hello^2;
178+
const s1 ^- ^2^3hello^2;
178179
179180
// シングルクォート文字列
180-
const s2 ^- ^7World^7;
181+
const s2 ^- ^7^3world^7;
181182
182183
// テンプレートリテラル
183184
const s3 ^- ^@^4^[s1^] ^4^[s2^]^@;
@@ -189,7 +190,7 @@ const s4 ^- ^2quote: \^2^2;
189190
```js
190191
const s1 = "Hello";
191192
const s2 = 'World';
192-
const s3 = `Hello World`;
193+
const s3 = `${s1} ${s2}`;
193194
const s4 = "quote: ^2";
194195
```
195196

@@ -228,7 +229,7 @@ class ^3animal ^[
228229
^]
229230
^]
230231
231-
const dog ^- new ^3animal^8^2Dog^2^9;
232+
const dog ^- new ^3animal^8^2^3dog^2^9;
232233
dog.speak^8^9;
233234
```
234235

npm/README.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ Generated automatically by `nsc init` or `nsc create`.
100100
| `^8` | `(` | | `^,` | `<` |
101101
| `^9` | `)` | | `^.` | `>` |
102102
| `^-` | `=` | | `^/` | `?` |
103+
| `^0` | `^` (XOR) | | | |
103104

104105
Template expression: `^4^[``${`
105106

@@ -110,7 +111,7 @@ Template expression: `^4^[` → `${`
110111
### Hello World
111112

112113
```nsjs
113-
console.log^8^2Hello, World!^2^9;
114+
console.log^8^2^3hello, ^3world!^2^9;
114115
```
115116

116117
```js
@@ -175,10 +176,10 @@ console.log(result); // 8
175176

176177
```nsjs
177178
// Double-quote string
178-
const s1 ^- ^2Hello^2;
179+
const s1 ^- ^2^3hello^2;
179180
180181
// Single-quote string
181-
const s2 ^- ^7World^7;
182+
const s2 ^- ^7^3world^7;
182183
183184
// Template literal
184185
const s3 ^- ^@^4^[s1^] ^4^[s2^]^@;
@@ -190,7 +191,7 @@ const s4 ^- ^2quote: \^2^2;
190191
```js
191192
const s1 = "Hello";
192193
const s2 = 'World';
193-
const s3 = `Hello World`;
194+
const s3 = `${s1} ${s2}`;
194195
const s4 = "quote: ^2";
195196
```
196197

@@ -229,7 +230,7 @@ class ^3animal ^[
229230
^]
230231
^]
231232
232-
const dog ^- new ^3animal^8^2Dog^2^9;
233+
const dog ^- new ^3animal^8^2^3dog^2^9;
233234
dog.speak^8^9;
234235
```
235236

npm/commands/create.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ export default async function create(projectNameArg, options = {}) {
9797
await fs.mkdir("src", { recursive: true });
9898
await fs.writeFile(
9999
"src/index.nsjs",
100-
"console.log^8^2^3hello, ^3world^1^2^9;\n",
100+
"console.log^8^2^3hello, ^3world!^2^9;\n",
101101
);
102102

103103
// .gitignore

npm/package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

npm/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "noshift.js",
3-
"version": "0.7.0",
3+
"version": "0.8.0",
44
"description": "Joke language.",
55
"bin": {
66
"nsc": "./bin/cli.js"

npm/src/convert.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
const noShiftMap = {
55
// "^@^@^@": "```", // マルチバックチック
66
"^4^[": "${", // テンプレート式展開開始
7+
"^0": "^",
78
"^1": "!",
89
"^2": '"',
910
"^4": "$",

pages/src/data/symbols.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export const symbolMap = [
88
{ shifted: "'", noshift: "^7" },
99
{ shifted: "(", noshift: "^8" },
1010
{ shifted: ")", noshift: "^9" },
11+
{ shifted: "^ (Caret/XOR)", noshift: "^0", special: true },
1112
{ shifted: "=", noshift: "^-" },
1213
{ shifted: "~", noshift: "^^" },
1314
{ shifted: "|", noshift: "^\\" },

pages/src/i18n/translations.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,9 @@ export const ui = {
116116
"syntax.helloTitle": "Hello World",
117117
"syntax.helloInput": "Input:",
118118
"syntax.helloOutput": "Output:",
119+
"syntax.bitwiseTitle": "Bitwise & Shift Operations",
120+
"syntax.bitwiseDesc":
121+
"JavaScript's bitwise operators work in NoShift.js using existing <code>^</code> sequences. The XOR operator (<code>^</code>) uses <code>^0</code> since the caret character is the NoShift.js prefix:",
119122

120123
// Capitalize
121124
"cap.title": "Capitalize Modifier (^3)",
@@ -378,6 +381,9 @@ export const ui = {
378381
"syntax.helloTitle": "Hello World",
379382
"syntax.helloInput": "入力:",
380383
"syntax.helloOutput": "出力:",
384+
"syntax.bitwiseTitle": "ビット演算・シフト演算",
385+
"syntax.bitwiseDesc":
386+
"JavaScript のビット演算子は NoShift.js の既存の <code>^</code> シーケンスで記述できます。XOR 演算子(<code>^</code>)は <code>^0</code> を使います(キャレットは NoShift.js のプレフィックスであるため):",
381387

382388
// Capitalize
383389
"cap.title": "大文字化修飾子 (^3)",

0 commit comments

Comments
 (0)