nadesiko3 3.4.27 → 3.5.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/core/.github/workflows/nodejs.yml +1 -1
- package/core/package.json +1 -1
- package/core/src/nako3.mjs +2 -4
- package/core/src/nako3.mts +2 -4
- package/core/src/nako_core_version.mjs +3 -3
- package/core/src/nako_core_version.mts +3 -3
- package/core/src/nako_gen.mjs +0 -45
- package/core/src/nako_gen.mts +0 -48
- package/core/src/nako_josi_list.mjs +10 -3
- package/core/src/nako_josi_list.mts +11 -3
- package/core/src/nako_lex_rules.mjs +14 -6
- package/core/src/nako_lex_rules.mts +14 -6
- package/core/src/nako_lexer.mjs +6 -1
- package/core/src/nako_lexer.mts +6 -1
- package/core/src/nako_parser3.mjs +16 -78
- package/core/src/nako_parser3.mts +12 -64
- package/core/src/nako_reserved_words.mjs +1 -1
- package/core/src/nako_reserved_words.mts +1 -1
- package/core/src/nako_types.mts +0 -2
- package/core/test/array_test.mjs +4 -0
- package/core/test/basic_test.mjs +4 -0
- package/package.json +4 -6
- package/release/_hash.txt +16 -16
- package/release/_script-tags.txt +13 -13
- package/release/josi.json +12 -12
- package/release/plugin_markup.js +1 -1
- package/release/plugin_markup.js.map +1 -1
- package/release/stats.json +1 -1
- package/release/version.js +1 -1
- package/release/version.js.map +1 -1
- package/release/wnako3.js +1 -1
- package/release/wnako3.js.map +1 -1
- package/release/wnako3webworker.js +1 -1
- package/release/wnako3webworker.js.map +1 -1
- package/src/nako_version.mjs +3 -3
- package/src/nako_version.mts +3 -3
- package/core/src/nako_gen_async.mjs +0 -1659
- package/core/src/nako_gen_async.mts +0 -1732
package/core/package.json
CHANGED
package/core/src/nako3.mjs
CHANGED
|
@@ -3,7 +3,6 @@ import { NakoParser } from './nako_parser3.mjs';
|
|
|
3
3
|
import { NakoLexer } from './nako_lexer.mjs';
|
|
4
4
|
import { NakoPrepare } from './nako_prepare.mjs';
|
|
5
5
|
import { generateJS, NakoGenOptions } from './nako_gen.mjs';
|
|
6
|
-
import { NakoGenASync } from './nako_gen_async.mjs';
|
|
7
6
|
import { convertInlineIndent, convertIndentSyntax } from './nako_indent_inline.mjs';
|
|
8
7
|
import { convertDNCL } from './nako_from_dncl.mjs';
|
|
9
8
|
import { convertDNCL2 } from './nako_from_dncl2.mjs';
|
|
@@ -646,10 +645,9 @@ export class NakoCompiler {
|
|
|
646
645
|
if (mode === 'sync') {
|
|
647
646
|
return generateJS(this, ast, opt);
|
|
648
647
|
}
|
|
649
|
-
//
|
|
648
|
+
// 廃止の非同期モード #1164
|
|
650
649
|
if (mode === '非同期モード') {
|
|
651
|
-
this.logger.
|
|
652
|
-
return NakoGenASync.generate(this, ast, opt.isTest);
|
|
650
|
+
this.logger.error('『!非同期モード』は廃止されました。[詳細](https://github.com/kujirahand/nadesiko3/issues/1164)');
|
|
653
651
|
}
|
|
654
652
|
// その他のコードジェネレータ(PHPなど)
|
|
655
653
|
const genObj = this.codeGenerateor[mode];
|
package/core/src/nako3.mts
CHANGED
|
@@ -8,7 +8,6 @@ import { NakoParser } from './nako_parser3.mjs'
|
|
|
8
8
|
import { NakoLexer } from './nako_lexer.mjs'
|
|
9
9
|
import { NakoPrepare } from './nako_prepare.mjs'
|
|
10
10
|
import { NakoGen, generateJS, NakoGenOptions, NakoGenResult } from './nako_gen.mjs'
|
|
11
|
-
import { NakoGenASync } from './nako_gen_async.mjs'
|
|
12
11
|
import { convertInlineIndent, convertIndentSyntax } from './nako_indent_inline.mjs'
|
|
13
12
|
import { convertDNCL } from './nako_from_dncl.mjs'
|
|
14
13
|
import { convertDNCL2 } from './nako_from_dncl2.mjs'
|
|
@@ -753,10 +752,9 @@ export class NakoCompiler {
|
|
|
753
752
|
if (mode === 'sync') {
|
|
754
753
|
return generateJS(this, ast, opt)
|
|
755
754
|
}
|
|
756
|
-
//
|
|
755
|
+
// 廃止の非同期モード #1164
|
|
757
756
|
if (mode === '非同期モード') {
|
|
758
|
-
this.logger.
|
|
759
|
-
return NakoGenASync.generate(this, ast, opt.isTest)
|
|
757
|
+
this.logger.error('『!非同期モード』は廃止されました。[詳細](https://github.com/kujirahand/nadesiko3/issues/1164)')
|
|
760
758
|
}
|
|
761
759
|
// その他のコードジェネレータ(PHPなど)
|
|
762
760
|
const genObj: any|undefined = this.codeGenerateor[mode]
|
|
@@ -11,9 +11,9 @@ export interface NakoCoreVersion {
|
|
|
11
11
|
}
|
|
12
12
|
// 実際のバージョン定義 (自動生成されるので以下を編集しない)
|
|
13
13
|
const coreVersion: NakoCoreVersion = {
|
|
14
|
-
version: '3.
|
|
14
|
+
version: '3.5.0',
|
|
15
15
|
major: 3,
|
|
16
|
-
minor:
|
|
17
|
-
patch:
|
|
16
|
+
minor: 5,
|
|
17
|
+
patch: 0
|
|
18
18
|
}
|
|
19
19
|
export default coreVersion
|
package/core/src/nako_gen.mjs
CHANGED
|
@@ -473,9 +473,6 @@ export class NakoGen {
|
|
|
473
473
|
case 'if':
|
|
474
474
|
code += this.convIf(node);
|
|
475
475
|
break;
|
|
476
|
-
case 'tikuji':
|
|
477
|
-
code += this.convTikuji(node);
|
|
478
|
-
break;
|
|
479
476
|
case 'for':
|
|
480
477
|
code += this.convFor(node);
|
|
481
478
|
break;
|
|
@@ -1120,48 +1117,6 @@ export class NakoGen {
|
|
|
1120
1117
|
return this.convLineno(node, false) +
|
|
1121
1118
|
`if (${expr}) {\n ${block}\n}` + falseBlock + ';\n';
|
|
1122
1119
|
}
|
|
1123
|
-
convTikuji(node) {
|
|
1124
|
-
// #1164 により「逐次実行」構文は近いうちに廃止する
|
|
1125
|
-
const pid = this.loopId++;
|
|
1126
|
-
// gen tikuji blocks
|
|
1127
|
-
const curName = `__tikuji${pid}`;
|
|
1128
|
-
let code = `const ${curName} = []\n`;
|
|
1129
|
-
const blocks = (node.blocks) ? node.blocks : [];
|
|
1130
|
-
for (let i = 0; i < blocks.length; i++) {
|
|
1131
|
-
const block = this._convGen(blocks[i], false).replace(/\s+$/, '') + '\n';
|
|
1132
|
-
const blockLineNo = this.convLineno(blocks[i], true);
|
|
1133
|
-
const blockCode = `${curName}.push(async function(resolve, reject) {\n` +
|
|
1134
|
-
' __self.resolve = resolve;\n' +
|
|
1135
|
-
' __self.reject = reject;\n' +
|
|
1136
|
-
' __self.resolveCount = 0;\n' +
|
|
1137
|
-
` ${blockLineNo}\n` +
|
|
1138
|
-
` ${block}` +
|
|
1139
|
-
' if (__self.resolveCount === 0) resolve();\n' +
|
|
1140
|
-
// eslint-disable-next-line no-template-curly-in-string
|
|
1141
|
-
'}); // end of tikuji__${pid}[{$i}]\n';
|
|
1142
|
-
code += blockCode;
|
|
1143
|
-
}
|
|
1144
|
-
code += `// end of ${curName} \n`;
|
|
1145
|
-
// gen error block
|
|
1146
|
-
let errorCode = ` ${curName}.splice(0);\n` + // clear
|
|
1147
|
-
' __v0["エラーメッセージ"]=errMsg;\n';
|
|
1148
|
-
if (node.errorBlock != null) {
|
|
1149
|
-
const errBlock = this._convGen(node.errorBlock, false).replace(/\s+$/, '') + '\n';
|
|
1150
|
-
errorCode += errBlock;
|
|
1151
|
-
}
|
|
1152
|
-
code += `const ${curName}__reject = function(errMsg){\n${errorCode}};\n`;
|
|
1153
|
-
// gen run block
|
|
1154
|
-
code += '__self.resolve = undefined;\n';
|
|
1155
|
-
code += `const ${curName}__resolve = function(){\n`;
|
|
1156
|
-
code += ' setTimeout(async function(){\n';
|
|
1157
|
-
code += ` if (${curName}.length == 0) {return}\n`;
|
|
1158
|
-
code += ` const f = ${curName}.shift()\n`;
|
|
1159
|
-
code += ` await f(${curName}__resolve, ${curName}__reject);\n`;
|
|
1160
|
-
code += ' }, 0);\n';
|
|
1161
|
-
code += '};\n';
|
|
1162
|
-
code += `${curName}__resolve()\n`;
|
|
1163
|
-
return this.convLineno(node, false) + code;
|
|
1164
|
-
}
|
|
1165
1120
|
convFuncGetArgsCalcType(_funcName, _func, node) {
|
|
1166
1121
|
const args = [];
|
|
1167
1122
|
const opts = {};
|
package/core/src/nako_gen.mts
CHANGED
|
@@ -535,9 +535,6 @@ export class NakoGen {
|
|
|
535
535
|
case 'if':
|
|
536
536
|
code += this.convIf(node)
|
|
537
537
|
break
|
|
538
|
-
case 'tikuji':
|
|
539
|
-
code += this.convTikuji(node)
|
|
540
|
-
break
|
|
541
538
|
case 'for':
|
|
542
539
|
code += this.convFor(node)
|
|
543
540
|
break
|
|
@@ -1190,51 +1187,6 @@ export class NakoGen {
|
|
|
1190
1187
|
`if (${expr}) {\n ${block}\n}` + falseBlock + ';\n'
|
|
1191
1188
|
}
|
|
1192
1189
|
|
|
1193
|
-
convTikuji (node: Ast): string {
|
|
1194
|
-
// #1164 により「逐次実行」構文は近いうちに廃止する
|
|
1195
|
-
const pid = this.loopId++
|
|
1196
|
-
// gen tikuji blocks
|
|
1197
|
-
const curName = `__tikuji${pid}`
|
|
1198
|
-
let code = `const ${curName} = []\n`
|
|
1199
|
-
const blocks: Ast[] = (node.blocks) ? node.blocks : []
|
|
1200
|
-
for (let i = 0; i < blocks.length; i++) {
|
|
1201
|
-
const block = this._convGen(blocks[i], false).replace(/\s+$/, '') + '\n'
|
|
1202
|
-
const blockLineNo = this.convLineno(blocks[i], true)
|
|
1203
|
-
const blockCode =
|
|
1204
|
-
`${curName}.push(async function(resolve, reject) {\n` +
|
|
1205
|
-
' __self.resolve = resolve;\n' +
|
|
1206
|
-
' __self.reject = reject;\n' +
|
|
1207
|
-
' __self.resolveCount = 0;\n' +
|
|
1208
|
-
` ${blockLineNo}\n` +
|
|
1209
|
-
` ${block}` +
|
|
1210
|
-
' if (__self.resolveCount === 0) resolve();\n' +
|
|
1211
|
-
// eslint-disable-next-line no-template-curly-in-string
|
|
1212
|
-
'}); // end of tikuji__${pid}[{$i}]\n'
|
|
1213
|
-
code += blockCode
|
|
1214
|
-
}
|
|
1215
|
-
code += `// end of ${curName} \n`
|
|
1216
|
-
// gen error block
|
|
1217
|
-
let errorCode =
|
|
1218
|
-
` ${curName}.splice(0);\n` + // clear
|
|
1219
|
-
' __v0["エラーメッセージ"]=errMsg;\n'
|
|
1220
|
-
if (node.errorBlock != null) {
|
|
1221
|
-
const errBlock = this._convGen(node.errorBlock as Ast, false).replace(/\s+$/, '') + '\n'
|
|
1222
|
-
errorCode += errBlock
|
|
1223
|
-
}
|
|
1224
|
-
code += `const ${curName}__reject = function(errMsg){\n${errorCode}};\n`
|
|
1225
|
-
// gen run block
|
|
1226
|
-
code += '__self.resolve = undefined;\n'
|
|
1227
|
-
code += `const ${curName}__resolve = function(){\n`
|
|
1228
|
-
code += ' setTimeout(async function(){\n'
|
|
1229
|
-
code += ` if (${curName}.length == 0) {return}\n`
|
|
1230
|
-
code += ` const f = ${curName}.shift()\n`
|
|
1231
|
-
code += ` await f(${curName}__resolve, ${curName}__reject);\n`
|
|
1232
|
-
code += ' }, 0);\n'
|
|
1233
|
-
code += '};\n'
|
|
1234
|
-
code += `${curName}__resolve()\n`
|
|
1235
|
-
return this.convLineno(node, false) + code
|
|
1236
|
-
}
|
|
1237
|
-
|
|
1238
1190
|
convFuncGetArgsCalcType (_funcName: string, _func: any, node: Ast): [any, any] {
|
|
1239
1191
|
const args = []
|
|
1240
1192
|
const opts: {[key: string]: boolean} = {}
|
|
@@ -14,7 +14,7 @@ export const tararebaJosiList = [
|
|
|
14
14
|
];
|
|
15
15
|
// 意味のない助詞(削除する) #936 #939 #974
|
|
16
16
|
export const removeJosiList = [
|
|
17
|
-
'こと', 'である', 'です', 'します', 'でした'
|
|
17
|
+
'こと', 'である', 'です', 'します', 'でした',
|
|
18
18
|
];
|
|
19
19
|
/**
|
|
20
20
|
* 「もし」文で使う「たら」「れば」などの一覧をプログラムで扱いやすいようマップに変換したもの
|
|
@@ -32,7 +32,14 @@ removeJosiList.forEach(josi => {
|
|
|
32
32
|
josiList.push(josi);
|
|
33
33
|
removeJosiMap[josi] = true;
|
|
34
34
|
});
|
|
35
|
+
// 「もの」構文 (#1614)
|
|
36
|
+
const josiListMono = [];
|
|
37
|
+
for (const jo of josiList) {
|
|
38
|
+
josiListMono.push('もの' + jo);
|
|
39
|
+
josiListMono.push(jo);
|
|
40
|
+
}
|
|
35
41
|
// 文字数の長い順に並び替え
|
|
36
|
-
|
|
42
|
+
josiListMono.sort((a, b) => b.length - a.length);
|
|
37
43
|
// 正規表現で助詞をマッチできるようにする
|
|
38
|
-
|
|
44
|
+
const pat = '^[\\t ]*(' + josiListMono.join('|') + ')';
|
|
45
|
+
export const josiRE = new RegExp(pat);
|
|
@@ -17,7 +17,7 @@ export const tararebaJosiList: string[] = [
|
|
|
17
17
|
|
|
18
18
|
// 意味のない助詞(削除する) #936 #939 #974
|
|
19
19
|
export const removeJosiList: string[] = [
|
|
20
|
-
'こと', 'である', 'です', 'します', 'でした'
|
|
20
|
+
'こと', 'である', 'です', 'します', 'でした',
|
|
21
21
|
]
|
|
22
22
|
|
|
23
23
|
/**
|
|
@@ -38,8 +38,16 @@ removeJosiList.forEach(josi => {
|
|
|
38
38
|
removeJosiMap[josi] = true
|
|
39
39
|
})
|
|
40
40
|
|
|
41
|
+
// 「もの」構文 (#1614)
|
|
42
|
+
const josiListMono = []
|
|
43
|
+
for (const jo of josiList) {
|
|
44
|
+
josiListMono.push('もの' + jo)
|
|
45
|
+
josiListMono.push(jo)
|
|
46
|
+
}
|
|
47
|
+
|
|
41
48
|
// 文字数の長い順に並び替え
|
|
42
|
-
|
|
49
|
+
josiListMono.sort((a, b) => b.length - a.length)
|
|
43
50
|
|
|
44
51
|
// 正規表現で助詞をマッチできるようにする
|
|
45
|
-
|
|
52
|
+
const pat = '^[\\t ]*(' + josiListMono.join('|') + ')'
|
|
53
|
+
export const josiRE = new RegExp(pat)
|
|
@@ -169,7 +169,7 @@ function cbWordParser(src, isTrimOkurigana = true) {
|
|
|
169
169
|
src = src.substring(j[0].length);
|
|
170
170
|
// 助詞の直後にある「,」を飛ばす #877
|
|
171
171
|
if (src.charAt(0) === ',') {
|
|
172
|
-
src = src.
|
|
172
|
+
src = src.substring(1);
|
|
173
173
|
}
|
|
174
174
|
break;
|
|
175
175
|
}
|
|
@@ -204,6 +204,10 @@ function cbWordParser(src, isTrimOkurigana = true) {
|
|
|
204
204
|
josi = '';
|
|
205
205
|
res = res.substring(0, res.length - ii[1].length);
|
|
206
206
|
}
|
|
207
|
+
// 「もの」構文 #1614
|
|
208
|
+
if (josi.substring(0, 2) === 'もの') {
|
|
209
|
+
josi = josi.substring(2);
|
|
210
|
+
}
|
|
207
211
|
// 助詞「こと」「である」「です」などは「**すること」のように使うので削除 #936 #939 #974
|
|
208
212
|
if (removeJosiMap[josi]) {
|
|
209
213
|
josi = '';
|
|
@@ -224,15 +228,15 @@ function cbString(beginTag, closeTag, src) {
|
|
|
224
228
|
let res = '';
|
|
225
229
|
let josi = '';
|
|
226
230
|
let numEOL = 0;
|
|
227
|
-
src = src.
|
|
231
|
+
src = src.substring(beginTag.length); // skip beginTag
|
|
228
232
|
const i = src.indexOf(closeTag);
|
|
229
233
|
if (i < 0) { // not found
|
|
230
234
|
res = src;
|
|
231
235
|
src = '';
|
|
232
236
|
}
|
|
233
237
|
else {
|
|
234
|
-
res = src.
|
|
235
|
-
src = src.
|
|
238
|
+
res = src.substring(0, i);
|
|
239
|
+
src = src.substring(i + closeTag.length);
|
|
236
240
|
// res の中に beginTag があればエラーにする #953
|
|
237
241
|
if (res.indexOf(beginTag) >= 0) {
|
|
238
242
|
if (beginTag === '『') {
|
|
@@ -247,16 +251,20 @@ function cbString(beginTag, closeTag, src) {
|
|
|
247
251
|
const j = josiRE.exec(src);
|
|
248
252
|
if (j) {
|
|
249
253
|
josi = j[0].replace(/^\s+/, '');
|
|
250
|
-
src = src.
|
|
254
|
+
src = src.substring(j[0].length);
|
|
251
255
|
// 助詞の後のカンマ #877
|
|
252
256
|
if (src.charAt(0) === ',') {
|
|
253
|
-
src = src.
|
|
257
|
+
src = src.substring(1);
|
|
254
258
|
}
|
|
255
259
|
}
|
|
256
260
|
// 助詞「こと」「である」「です」などは「**すること」のように使うので削除 #936 #939 #974
|
|
257
261
|
if (removeJosiMap[josi]) {
|
|
258
262
|
josi = '';
|
|
259
263
|
}
|
|
264
|
+
// 「もの」構文 (#1614)
|
|
265
|
+
if (josi.substring(0, 2) === 'もの') {
|
|
266
|
+
josi = josi.substring(2);
|
|
267
|
+
}
|
|
260
268
|
// 改行を数える
|
|
261
269
|
for (let i = 0; i < res.length; i++) {
|
|
262
270
|
if (res.charAt(i) === '\n') {
|
|
@@ -182,7 +182,7 @@ function cbWordParser (src: string, isTrimOkurigana = true): NakoLexParseResult
|
|
|
182
182
|
josi = j[0].replace(/^\s+/, '')
|
|
183
183
|
src = src.substring(j[0].length)
|
|
184
184
|
// 助詞の直後にある「,」を飛ばす #877
|
|
185
|
-
if (src.charAt(0) === ',') { src = src.
|
|
185
|
+
if (src.charAt(0) === ',') { src = src.substring(1) }
|
|
186
186
|
break
|
|
187
187
|
}
|
|
188
188
|
}
|
|
@@ -216,6 +216,10 @@ function cbWordParser (src: string, isTrimOkurigana = true): NakoLexParseResult
|
|
|
216
216
|
josi = ''
|
|
217
217
|
res = res.substring(0, res.length - ii[1].length)
|
|
218
218
|
}
|
|
219
|
+
// 「もの」構文 #1614
|
|
220
|
+
if (josi.substring(0, 2) === 'もの') {
|
|
221
|
+
josi = josi.substring(2)
|
|
222
|
+
}
|
|
219
223
|
// 助詞「こと」「である」「です」などは「**すること」のように使うので削除 #936 #939 #974
|
|
220
224
|
if (removeJosiMap[josi]) { josi = '' }
|
|
221
225
|
|
|
@@ -236,14 +240,14 @@ function cbString (beginTag: string, closeTag: string, src: string): NakoLexPars
|
|
|
236
240
|
let res = ''
|
|
237
241
|
let josi = ''
|
|
238
242
|
let numEOL = 0
|
|
239
|
-
src = src.
|
|
243
|
+
src = src.substring(beginTag.length) // skip beginTag
|
|
240
244
|
const i = src.indexOf(closeTag)
|
|
241
245
|
if (i < 0) { // not found
|
|
242
246
|
res = src
|
|
243
247
|
src = ''
|
|
244
248
|
} else {
|
|
245
|
-
res = src.
|
|
246
|
-
src = src.
|
|
249
|
+
res = src.substring(0, i)
|
|
250
|
+
src = src.substring(i + closeTag.length)
|
|
247
251
|
// res の中に beginTag があればエラーにする #953
|
|
248
252
|
if (res.indexOf(beginTag) >= 0) {
|
|
249
253
|
if (beginTag === '『') {
|
|
@@ -257,12 +261,16 @@ function cbString (beginTag: string, closeTag: string, src: string): NakoLexPars
|
|
|
257
261
|
const j = josiRE.exec(src)
|
|
258
262
|
if (j) {
|
|
259
263
|
josi = j[0].replace(/^\s+/, '')
|
|
260
|
-
src = src.
|
|
264
|
+
src = src.substring(j[0].length)
|
|
261
265
|
// 助詞の後のカンマ #877
|
|
262
|
-
if (src.charAt(0) === ',') { src = src.
|
|
266
|
+
if (src.charAt(0) === ',') { src = src.substring(1) }
|
|
263
267
|
}
|
|
264
268
|
// 助詞「こと」「である」「です」などは「**すること」のように使うので削除 #936 #939 #974
|
|
265
269
|
if (removeJosiMap[josi]) { josi = '' }
|
|
270
|
+
// 「もの」構文 (#1614)
|
|
271
|
+
if (josi.substring(0, 2) === 'もの') {
|
|
272
|
+
josi = josi.substring(2)
|
|
273
|
+
}
|
|
266
274
|
|
|
267
275
|
// 改行を数える
|
|
268
276
|
for (let i = 0; i < res.length; i++) { if (res.charAt(i) === '\n') { numEOL++ } }
|
package/core/src/nako_lexer.mjs
CHANGED
|
@@ -632,10 +632,11 @@ export class NakoLexer {
|
|
|
632
632
|
}
|
|
633
633
|
let josi = '';
|
|
634
634
|
if (rule.readJosi) {
|
|
635
|
+
// 正規表現で助詞があるか読み取る
|
|
635
636
|
const j = josiRE.exec(src);
|
|
636
637
|
if (j) {
|
|
637
|
-
josi = j[0].replace(/^\s+/, '');
|
|
638
638
|
column += j[0].length;
|
|
639
|
+
josi = j[0].replace(/^\s+/, '');
|
|
639
640
|
src = src.substring(j[0].length);
|
|
640
641
|
// 助詞の直後にあるカンマを無視 #877
|
|
641
642
|
if (src.charAt(0) === ',') {
|
|
@@ -645,6 +646,10 @@ export class NakoLexer {
|
|
|
645
646
|
if (removeJosiMap[josi]) {
|
|
646
647
|
josi = '';
|
|
647
648
|
}
|
|
649
|
+
// 「もの」構文 (#1614)
|
|
650
|
+
if (josi.substring(0, 2) === 'もの') {
|
|
651
|
+
josi = josi.substring(2);
|
|
652
|
+
}
|
|
648
653
|
}
|
|
649
654
|
}
|
|
650
655
|
switch (rule.name) {
|
package/core/src/nako_lexer.mts
CHANGED
|
@@ -615,10 +615,11 @@ export class NakoLexer {
|
|
|
615
615
|
|
|
616
616
|
let josi = ''
|
|
617
617
|
if (rule.readJosi) {
|
|
618
|
+
// 正規表現で助詞があるか読み取る
|
|
618
619
|
const j = josiRE.exec(src)
|
|
619
620
|
if (j) {
|
|
620
|
-
josi = j[0].replace(/^\s+/, '')
|
|
621
621
|
column += j[0].length
|
|
622
|
+
josi = j[0].replace(/^\s+/, '')
|
|
622
623
|
src = src.substring(j[0].length)
|
|
623
624
|
// 助詞の直後にあるカンマを無視 #877
|
|
624
625
|
if (src.charAt(0) === ',') {
|
|
@@ -626,6 +627,10 @@ export class NakoLexer {
|
|
|
626
627
|
}
|
|
627
628
|
// 「**である」なら削除 #939 #974
|
|
628
629
|
if (removeJosiMap[josi]) { josi = '' }
|
|
630
|
+
// 「もの」構文 (#1614)
|
|
631
|
+
if (josi.substring(0, 2) === 'もの') {
|
|
632
|
+
josi = josi.substring(2)
|
|
633
|
+
}
|
|
629
634
|
}
|
|
630
635
|
}
|
|
631
636
|
|
|
@@ -119,18 +119,12 @@ export class NakoParser extends NakoParserBase {
|
|
|
119
119
|
if (this.check('エラー監視')) {
|
|
120
120
|
return this.yTryExcept();
|
|
121
121
|
}
|
|
122
|
-
if (this.check('逐次実行')) {
|
|
123
|
-
return this.yTikuji();
|
|
124
|
-
}
|
|
125
122
|
if (this.accept(['抜ける'])) {
|
|
126
123
|
return { type: 'break', josi: '', ...map, end: this.peekSourceMap() };
|
|
127
124
|
}
|
|
128
125
|
if (this.accept(['続ける'])) {
|
|
129
126
|
return { type: 'continue', josi: '', ...map, end: this.peekSourceMap() };
|
|
130
127
|
}
|
|
131
|
-
if (this.accept(['not', '非同期モード'])) {
|
|
132
|
-
return this.yASyncMode();
|
|
133
|
-
}
|
|
134
128
|
if (this.accept(['DNCLモード'])) {
|
|
135
129
|
return this.yDNCLMode(1);
|
|
136
130
|
}
|
|
@@ -145,6 +139,13 @@ export class NakoParser extends NakoParserBase {
|
|
|
145
139
|
}
|
|
146
140
|
// (memo) 現状「取込」はプリプロセス段階(NakoCompiler.listRequireStatements)で処理される
|
|
147
141
|
// if (this.accept(['require', 'string', '取込'])) { return this.yRequire() }
|
|
142
|
+
// 廃止された構文 #1611
|
|
143
|
+
if (this.check('逐次実行')) {
|
|
144
|
+
return this.yTikuji();
|
|
145
|
+
}
|
|
146
|
+
if (this.accept(['not', '非同期モード'])) {
|
|
147
|
+
return this.yASyncMode();
|
|
148
|
+
}
|
|
148
149
|
if (this.check2(['func', 'eq'])) {
|
|
149
150
|
const word = this.get() || NewEmptyToken();
|
|
150
151
|
throw NakoSyntaxError.fromNode(`関数『${word.value}』に代入できません。`, word);
|
|
@@ -196,10 +197,10 @@ export class NakoParser extends NakoParserBase {
|
|
|
196
197
|
}
|
|
197
198
|
return null;
|
|
198
199
|
}
|
|
199
|
-
/** @returns {Ast} */
|
|
200
|
+
/** [廃止] 非同期モード @returns {Ast} */
|
|
200
201
|
yASyncMode() {
|
|
202
|
+
this.logger.error('『非同期モード』構文は廃止されました(https://nadesi.com/v3/doc/go.php?1028)。', this.peek());
|
|
201
203
|
const map = this.peekSourceMap();
|
|
202
|
-
this.genMode = '非同期モード';
|
|
203
204
|
return { type: 'eol', ...map, end: this.peekSourceMap() };
|
|
204
205
|
}
|
|
205
206
|
/** set DNCL mode */
|
|
@@ -669,77 +670,14 @@ export class NakoParser extends NakoParserBase {
|
|
|
669
670
|
...map
|
|
670
671
|
};
|
|
671
672
|
}
|
|
672
|
-
/**
|
|
673
|
+
/** [廃止] #1611 「逐次実行」構文 @returns {Ast | null} */
|
|
673
674
|
yTikuji() {
|
|
674
|
-
const map = this.peekSourceMap();
|
|
675
675
|
if (!this.check('逐次実行')) {
|
|
676
676
|
return null;
|
|
677
677
|
}
|
|
678
|
-
const tikuji = this.getCur(); // skip
|
|
679
|
-
this.logger.
|
|
680
|
-
|
|
681
|
-
let errorBlock = null;
|
|
682
|
-
if (!tikuji || !this.check('eol')) {
|
|
683
|
-
throw NakoSyntaxError.fromNode('『逐次実行』の直後は改行が必要です。', tikuji);
|
|
684
|
-
}
|
|
685
|
-
// ブロックを読む
|
|
686
|
-
for (;;) {
|
|
687
|
-
if (this.check('ここまで')) {
|
|
688
|
-
break;
|
|
689
|
-
}
|
|
690
|
-
if (this.check('eol')) {
|
|
691
|
-
this.get(); // skip EOL
|
|
692
|
-
continue;
|
|
693
|
-
}
|
|
694
|
-
if (this.check2(['エラー', 'ならば'])) {
|
|
695
|
-
this.get(); // skip エラー
|
|
696
|
-
this.get(); // skip ならば
|
|
697
|
-
errorBlock = this.yBlock();
|
|
698
|
-
break;
|
|
699
|
-
}
|
|
700
|
-
let block = null;
|
|
701
|
-
// 「先に」「次に」句はブロック宣言 #717 (ただしブロック以外も可能)
|
|
702
|
-
if (this.check('先に') || this.check('次に')) {
|
|
703
|
-
const tugini = this.get(); // skip 先に | 次に
|
|
704
|
-
if (this.check('comma')) {
|
|
705
|
-
this.get();
|
|
706
|
-
}
|
|
707
|
-
if (this.check('eol')) { // block
|
|
708
|
-
block = this.yBlock();
|
|
709
|
-
if (!this.check('ここまで')) {
|
|
710
|
-
let tuginiType = '次に';
|
|
711
|
-
if (tugini != null) {
|
|
712
|
-
tuginiType = tugini.type;
|
|
713
|
-
}
|
|
714
|
-
throw NakoSyntaxError.fromNode(`『${tuginiType}』...『ここまで』を対応させてください。`, map);
|
|
715
|
-
}
|
|
716
|
-
this.get(); // skip 'ここまで'
|
|
717
|
-
}
|
|
718
|
-
else { // line
|
|
719
|
-
block = this.ySentence();
|
|
720
|
-
}
|
|
721
|
-
}
|
|
722
|
-
else {
|
|
723
|
-
block = this.ySentence();
|
|
724
|
-
}
|
|
725
|
-
// add block
|
|
726
|
-
if (block != null) {
|
|
727
|
-
blocks.push(block);
|
|
728
|
-
}
|
|
729
|
-
}
|
|
730
|
-
if (!this.check('ここまで')) {
|
|
731
|
-
console.log(blocks, this.peek());
|
|
732
|
-
throw NakoSyntaxError.fromNode('『逐次実行』...『ここまで』を対応させてください。', tikuji);
|
|
733
|
-
}
|
|
734
|
-
this.get(); // skip 'ここまで'
|
|
735
|
-
return {
|
|
736
|
-
type: 'tikuji',
|
|
737
|
-
blocks: blocks || [],
|
|
738
|
-
errorBlock: errorBlock || [],
|
|
739
|
-
josi: '',
|
|
740
|
-
...map,
|
|
741
|
-
end: this.peekSourceMap()
|
|
742
|
-
};
|
|
678
|
+
const tikuji = this.getCur(); // skip
|
|
679
|
+
this.logger.error('『逐次実行』構文は廃止されました(https://nadesi.com/v3/doc/go.php?944)。', tikuji);
|
|
680
|
+
return { type: 'eol', ...this.peekSourceMap(), end: this.peekSourceMap() };
|
|
743
681
|
}
|
|
744
682
|
/**
|
|
745
683
|
* 1つ目の値を与え、その後に続く計算式を取得し、優先規則に沿って並び替えして戻す
|
|
@@ -2330,7 +2268,7 @@ export class NakoParser extends NakoParserBase {
|
|
|
2330
2268
|
if (this.accept(['[', this.yCalc, ']'])) {
|
|
2331
2269
|
ast.index.push(this.checkArrayIndex(this.y[1]));
|
|
2332
2270
|
ast.josi = this.y[2].josi;
|
|
2333
|
-
return
|
|
2271
|
+
return this.y[2].josi === ''; // 助詞があればそこで終了(false)を返す (#1627)
|
|
2334
2272
|
}
|
|
2335
2273
|
}
|
|
2336
2274
|
if (this.check('[')) {
|
|
@@ -2341,7 +2279,7 @@ export class NakoParser extends NakoParserBase {
|
|
|
2341
2279
|
];
|
|
2342
2280
|
ast.index = this.checkArrayReverse(index);
|
|
2343
2281
|
ast.josi = this.y[4].josi;
|
|
2344
|
-
return
|
|
2282
|
+
return this.y[4].josi === ''; // 助詞があればそこで終了(false)を返す
|
|
2345
2283
|
}
|
|
2346
2284
|
}
|
|
2347
2285
|
if (this.check('[')) {
|
|
@@ -2353,7 +2291,7 @@ export class NakoParser extends NakoParserBase {
|
|
|
2353
2291
|
];
|
|
2354
2292
|
ast.index = this.checkArrayReverse(index);
|
|
2355
2293
|
ast.josi = this.y[6].josi;
|
|
2356
|
-
return
|
|
2294
|
+
return this.y[6].josi === ''; // 助詞があればそこで終了(false)を返す
|
|
2357
2295
|
}
|
|
2358
2296
|
}
|
|
2359
2297
|
return false;
|