-
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.
feat: ✨ 引入
anyhow
,首个命令行CIN启动器示例,拟引用pest
做方言解析
1. 引入`anyhow`包,规范错误类型并弃用`util::ResultS` 2. 测试用「CIN启动器」:首个交互式终端跑通(🚧后续添加「CIN选择」与「自动CIN路径查找」) 3. 为各个CIN实现设置独立的feature,并对OpenNARS、ONA引入`pest`库(🚧后续做方言解析)
- Loading branch information
1 parent
176b452
commit 40f8432
Showing
20 changed files
with
511 additions
and
121 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
//! 所有对接CIN实现的共用模块 | ||
// 平铺导出元素 | ||
util::pub_mod_and_pub_use! { | ||
java | ||
python | ||
|
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,24 @@ | ||
//! ONA方言 | ||
//! * 🎯解析ONA输出,如 | ||
//! * 📄以空格分隔的词项:`(* {SELF})` | ||
//! * 📄`({SELF} * x)` | ||
//! | ||
//! TODO: 完成语法解析 | ||
use narsese::conversion::string::impl_lexical::{ | ||
format_instances::FORMAT_ASCII, structs::ParseResult, | ||
}; | ||
|
||
/// 使用[`pest`]将输入的「ONA方言」转换为「词法Narsese」 | ||
/// 以ONA的语法解析出Narsese | ||
/// * 🚩【2024-03-25 21:08:34】目前是直接调用ASCII解析器 | ||
/// | ||
/// TODO: 兼容ONA的方言语法 | ||
/// * 📌重点在「用空格分隔乘积词项/中缀情形」的语法 | ||
/// * 📄`(* {SELF})` | ||
/// * 📄`({SELF} * x)` | ||
pub fn parse(input: &str) -> ParseResult { | ||
FORMAT_ASCII.parse(input) | ||
// #![allow(unused)] | ||
// todo!("ONA方言!") | ||
} |
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,17 @@ | ||
// TODO: 有待替换 | ||
num = @{ int ~ ("." ~ ASCII_DIGIT*)? ~ (^"e" ~ int)? } | ||
int = { ("+" | "-")? ~ ASCII_DIGIT+ } | ||
|
||
operation = _{ add | subtract | multiply | divide | power } | ||
add = { "+" } | ||
subtract = { "-" } | ||
multiply = { "*" } | ||
divide = { "/" } | ||
power = { "^" } | ||
|
||
expr = { term ~ (operation ~ term)* } | ||
term = _{ num | "(" ~ expr ~ ")" } | ||
|
||
calculation = _{ SOI ~ expr ~ EOI } | ||
|
||
WHITESPACE = _{ " " | "\t" } |
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.