-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
增加【以NAVM指令作为输入,输出JSON式NAVM输出】的「原生」CIN转译器支持;基于「原生」转译器,示例性支持NAVM所开发的「原生IL-1」运行时(仅能跑通「简单演绎推理」)
- Loading branch information
1 parent
3c3f3f7
commit 527dd89
Showing
9 changed files
with
98 additions
and
5 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
//! NAVM原生的虚拟机(转译器) | ||
//! * ✨Cmd输入转译:直接将[`Cmd`]转换为字符串形式 | ||
//! * ✨NAVM_JSON输出转译:基于[`serde_json`]直接从JSON字符串读取[`Output`] | ||
//! * 📌没有固定的启动器:仅通过「命令行启动器」即可启动 | ||
util::mods! { | ||
// 输入输出转译 | ||
pub pub translators; | ||
} |
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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
//! 输入输出转译 | ||
//! * ✨Cmd输入转译:直接将[`Cmd`]转换为字符串形式 | ||
//! * ✨NAVM_JSON输出转译:基于[`serde_json`]直接从JSON字符串读取[`Output`] | ||
use anyhow::Result; | ||
use navm::{cmd::Cmd, output::Output}; | ||
extern crate serde_json; | ||
|
||
/// Cmd输入转译 | ||
/// * 🚩直接将[`Cmd`]转换为字符串形式 | ||
/// * 📌总是成功 | ||
pub fn input_translate(cmd: Cmd) -> Result<String> { | ||
Ok(cmd.to_string()) | ||
} | ||
|
||
/// NAVM_JSON输出转译 | ||
/// * 🚩基于[`serde_json`]直接从JSON字符串读取[`Output`] | ||
pub fn output_translate(content_raw: String) -> Result<Output> { | ||
match serde_json::from_str(&content_raw) { | ||
// 解析成功⇒返回 | ||
Ok(output) => Ok(output), | ||
// 解析失败⇒转为`OTHER` | ||
Err(..) => Ok(Output::OTHER { | ||
content: content_raw, | ||
}), | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#hjson | ||
// * 🎯用于测试原生「IL-1」运行时 | ||
// * ✨基于NAVM,纯Rust编写 | ||
{ | ||
// 使用「原生」输入输出转译器 | ||
translators: native | ||
command: { | ||
// * ⚠️必须前缀`./`以指定是「启动当前工作目录下的exe文件」 | ||
cmd: ./native-IL-1.exe | ||
cmdArgs: [] | ||
// * 🚩现在基于「固定位置的CIN程序包」运行测试 | ||
// * 回溯路径:config(`./`) => cli => tests => src => BabelNAR.rs / executables | ||
currentDir: ./../../../../executables | ||
} | ||
autoRestart: true | ||
} |