-
-
Notifications
You must be signed in to change notification settings - Fork 235
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #381 from MakinoharaShoko/dev
4.4.5
- Loading branch information
Showing
114 changed files
with
1,659 additions
and
1,021 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,60 @@ | ||
export function configParser(configText:string){ | ||
// TODO | ||
return configText | ||
import {argsParser} from "../scriptParser/argsParser"; | ||
|
||
interface IOptionItem{ | ||
key:string; | ||
value:string | number | boolean; | ||
} | ||
interface IConfigItem{ | ||
command:string; | ||
args:string[] | ||
options:IOptionItem[]; | ||
} | ||
|
||
export type WebgalConfig = IConfigItem[] | ||
|
||
|
||
function configLineParser(inputLine:string):IConfigItem{ | ||
const options:Array<IOptionItem> = []; | ||
let command: string; | ||
|
||
let newSentenceRaw = inputLine.split(";")[0]; | ||
if (newSentenceRaw === "") { | ||
// 注释提前返回 | ||
return { | ||
command:'', | ||
args:[], | ||
options:[] | ||
}; | ||
} | ||
// 截取命令 | ||
const getCommandResult = /:/.exec(newSentenceRaw); | ||
|
||
// 没有command | ||
if (getCommandResult === null) { | ||
command = ''; | ||
} else { | ||
command = newSentenceRaw.substring(0, getCommandResult.index); | ||
// 划分命令区域和content区域 | ||
newSentenceRaw = newSentenceRaw.substring(getCommandResult.index + 1, newSentenceRaw.length); | ||
} | ||
// 截取 Options 区域 | ||
const getOptionsResult = / -/.exec(newSentenceRaw); | ||
// 获取到参数 | ||
if (getOptionsResult) { | ||
const optionsRaw = newSentenceRaw.substring(getOptionsResult.index, newSentenceRaw.length); | ||
newSentenceRaw = newSentenceRaw.substring(0, getOptionsResult.index); | ||
for (const e of argsParser(optionsRaw, (name,_)=>{return name})) { | ||
options.push(e); | ||
} | ||
} | ||
return { | ||
command, | ||
args:newSentenceRaw.split('|').map(e=>e.trim()).filter(e=>e!==''), | ||
options | ||
}; | ||
} | ||
|
||
export function configParser(configText:string):WebgalConfig{ | ||
const configLines = configText.replaceAll(`\r`,'').split('\n'); | ||
return configLines.map(e=>configLineParser(e)).filter(e=>e.command!==''); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.