Skip to content

Commit

Permalink
Merge pull request #501 from xiaoxustudio/dev1
Browse files Browse the repository at this point in the history
处理两处Issue
  • Loading branch information
MakinoharaShoko authored Jun 12, 2024
2 parents 3d479f4 + c1634a1 commit 771a384
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
16 changes: 12 additions & 4 deletions packages/parser/src/scriptParser/scriptParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,11 @@ export const scriptParser = (
// 没有command,说明这是一条连续对话或单条语句
if (getCommandResult === null) {
commandRaw = newSentenceRaw;
parsedCommand = commandParser(commandRaw, ADD_NEXT_ARG_LIST, SCRIPT_CONFIG_MAP);
parsedCommand = commandParser(
commandRaw,
ADD_NEXT_ARG_LIST,
SCRIPT_CONFIG_MAP,
);
command = parsedCommand.type;
for (const e of parsedCommand.additionalArgs) {
// 由于是连续对话,所以我们去除 speaker 参数。
Expand All @@ -72,7 +76,11 @@ export const scriptParser = (
getCommandResult.index + 1,
newSentenceRaw.length,
);
parsedCommand = commandParser(commandRaw, ADD_NEXT_ARG_LIST, SCRIPT_CONFIG_MAP);
parsedCommand = commandParser(
commandRaw,
ADD_NEXT_ARG_LIST,
SCRIPT_CONFIG_MAP,
);
command = parsedCommand.type;
for (const e of parsedCommand.additionalArgs) {
args.push(e);
Expand All @@ -91,12 +99,12 @@ export const scriptParser = (
args.push(e);
}
}
content = contentParser(newSentenceRaw, command, assetSetter); // 将语句内容里的文件名转为相对或绝对路径
content = contentParser(newSentenceRaw.trim(), command, assetSetter); // 将语句内容里的文件名转为相对或绝对路径
sentenceAssets = assetsScanner(command, content, args); // 扫描语句携带资源
subScene = subSceneScanner(command, content); // 扫描语句携带子场景
return {
command: command, // 语句类型
commandRaw: commandRaw, // 命令原始内容,方便调试
commandRaw: commandRaw.trim(), // 命令原始内容,方便调试
content: content, // 语句内容
args: args, // 参数列表
sentenceAssets: sentenceAssets, // 语句携带的资源列表
Expand Down
6 changes: 6 additions & 0 deletions packages/parser/test/test-resources/var.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
setVar:a=1;
WebGAL:a=1? -when=a==1;

;正常解析
WebGAL:test;

; : 异常测试
WebGAL : test;
8 changes: 6 additions & 2 deletions packages/webgal/src/Core/controller/gamePlay/strIf.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { compile } from 'angular-expressions';

export function strIf(s: string) {
const res = compile(s);
return res();
try {
const res = compile(s);
return res();
} catch {
return false;
}
}

0 comments on commit 771a384

Please sign in to comment.