diff --git a/.run/Test All.run.xml b/.run/Test All.run.xml
index 0022d1f5..b47561bd 100644
--- a/.run/Test All.run.xml
+++ b/.run/Test All.run.xml
@@ -5,7 +5,7 @@
-
+
diff --git a/projects/valkyrie-ast/readme.md b/projects/valkyrie-ast/readme.md
index ed1abdce..5445b28e 100644
--- a/projects/valkyrie-ast/readme.md
+++ b/projects/valkyrie-ast/readme.md
@@ -19,7 +19,7 @@ class B(A) { }
这个语言中这样定义代数效应
-```
+```vk
class Logging {
level: Integer
message: String
@@ -40,7 +40,7 @@ class Logging {
使用 raise 激发代数效应, 使用 try catch 语句处理代数效应.
-```
+```vk
try {
raise Logging::debug("hello")
}
diff --git a/projects/valkyrie-ast/src/control_flow/loop_while/readme.md b/projects/valkyrie-ast/src/control_flow/loop_while/readme.md
index 6fc33170..7e1de6ec 100644
--- a/projects/valkyrie-ast/src/control_flow/loop_while/readme.md
+++ b/projects/valkyrie-ast/src/control_flow/loop_while/readme.md
@@ -40,7 +40,7 @@ outer: loop {
-```
+```vk
// promotion local variable here!!
let outer_continue = || {
if c1 {
@@ -82,7 +82,7 @@ let outer_break = || {
-```
+```vk
// promotion local variable here!!
let outer_continue = || {
if c1 {
diff --git a/projects/valkyrie-parser/tests/declaration/class.ron b/projects/valkyrie-parser/tests/declaration/class.ron
index 0f054a39..015917e6 100644
--- a/projects/valkyrie-parser/tests/declaration/class.ron
+++ b/projects/valkyrie-parser/tests/declaration/class.ron
@@ -52,6 +52,7 @@ DefineClass {
],
},
name: base1,
+ type: Base1,
},
Field {
annotations: Annotation {
@@ -60,6 +61,7 @@ DefineClass {
],
},
name: base2,
+ type: Base2,
},
Field {
annotations: Annotation {
@@ -68,6 +70,7 @@ DefineClass {
],
},
name: base3,
+ type: Base3,
},
],
span: 219..329,
@@ -77,9 +80,17 @@ DefineClass {
terms: [
Field {
name: item1,
+ type: UnaryNode {
+ prefix: !,
+ base: T,
+ },
},
Field {
name: item2,
+ type: UnaryNode {
+ prefix: !,
+ base: U,
+ },
},
],
span: 329..392,
@@ -289,6 +300,7 @@ DefineClass {
],
},
name: x_base,
+ type: XBase,
},
Field {
name: private,
@@ -303,6 +315,7 @@ DefineClass {
],
},
name: _y_base,
+ type: YBase,
},
Method {
name: constructor,
@@ -379,15 +392,19 @@ DefineClass {
],
},
name: type,
+ type: String,
+ default: 'item',
},
Field {
name: unknown_all,
},
Field {
name: default_value,
+ type: A,
},
Field {
name: infer_type,
+ default: null,
},
Method {
annotations: Annotation {
@@ -564,6 +581,7 @@ DefineClass {
],
},
name: field1,
+ type: u32,
},
Field {
annotations: Annotation {
@@ -572,6 +590,7 @@ DefineClass {
],
},
name: field 2,
+ type: f64,
},
Field {
annotations: Annotation {
@@ -590,6 +609,7 @@ DefineClass {
],
},
name: fields,
+ type: T,
},
Method {
annotations: Annotation {
diff --git a/projects/valkyrie-parser/tests/declaration/trait.ron b/projects/valkyrie-parser/tests/declaration/trait.ron
index bc2ad6e4..e665693b 100644
--- a/projects/valkyrie-parser/tests/declaration/trait.ron
+++ b/projects/valkyrie-parser/tests/declaration/trait.ron
@@ -49,6 +49,7 @@ Trait {
body: [
Field {
name: unit,
+ type: T,
},
],
}
diff --git a/projects/valkyrie-parser/tests/declaration/union.ron b/projects/valkyrie-parser/tests/declaration/union.ron
index e73f310c..68a692ad 100644
--- a/projects/valkyrie-parser/tests/declaration/union.ron
+++ b/projects/valkyrie-parser/tests/declaration/union.ron
@@ -180,6 +180,7 @@ Union {
body: [
Field {
name: value,
+ type: T,
},
],
},
@@ -197,6 +198,7 @@ Union {
body: [
Field {
name: value,
+ type: V,
},
],
},
@@ -205,6 +207,7 @@ Union {
body: [
Field {
name: error,
+ type: E,
},
],
},
@@ -219,9 +222,21 @@ Union {
body: [
Field {
name: value,
+ type: T,
},
Field {
name: errors,
+ type: GenericCallNode {
+ monadic: false,
+ base: List,
+ term: [
+ ArgumentTerm {
+ key: Nothing,
+ value: E,
+ },
+ ],
+ span: 1019..1026,
+ },
},
],
},
@@ -230,9 +245,21 @@ Union {
body: [
Field {
name: fatal,
+ type: E,
},
Field {
name: errors,
+ type: GenericCallNode {
+ monadic: false,
+ base: List,
+ term: [
+ ArgumentTerm {
+ key: Nothing,
+ value: E,
+ },
+ ],
+ span: 1083..1090,
+ },
},
],
},
diff --git a/projects/valkyrie-parser/tests/tests/main.rs b/projects/valkyrie-parser/tests/tests/main.rs
index 076deccf..8b137891 100644
--- a/projects/valkyrie-parser/tests/tests/main.rs
+++ b/projects/valkyrie-parser/tests/tests/main.rs
@@ -1,55 +1 @@
-mod declaration;
-mod expression;
-mod literal;
-mod statement;
-use std::{
- fs::File,
- io::Write as _,
- path::{Path, PathBuf},
-};
-use valkyrie_antlr::ValkyrieProgramParser;
-use valkyrie_ast::helper::{Lispify, PrettyPrint, PrettyProvider};
-#[test]
-fn ready() {
- println!("it works!")
-}
-
-fn here() -> PathBuf {
- Path::new(env!("CARGO_MANIFEST_DIR")).join("tests").canonicalize().expect("failed to get manifest dir")
-}
-
-pub fn pretty_print(value: &T) {
- let arena = PrettyProvider::new(80);
- println!("{}", value.pretty_colorful(&arena));
-}
-
-fn top_debug(text: &str, output: &str) -> std::io::Result<()> {
- let mut file = File::create(here().join(output))?;
- let apply = ValkyrieProgramParser::parse(text).unwrap();
- let theme = PrettyProvider::new(128);
- for expr in &apply.statements {
- println!("=================================================================");
- pretty_print(expr);
- let text = expr.pretty_colorful(&theme);
- let lisp = expr.lispify();
- writeln!(file, "{}", lisp.pretty_string(&theme))?;
- println!("{}", lisp.pretty_colorful(&theme));
- }
- Ok(())
-}
-
-fn repl_debug(text: &str, output: &str) -> std::io::Result<()> {
- let mut file = File::create(here().join(output))?;
- let apply = ValkyrieProgramParser::parse(text).unwrap();
- let mut theme = PrettyProvider::new(128);
- for expr in &apply.statements {
- println!("=================================================================");
- pretty_print(expr);
- let text = expr.pretty_colorful(&theme);
- let lisp = expr.lispify();
- writeln!(file, "{}", lisp.pretty_string(&theme))?;
- println!("{}", lisp.pretty_colorful(&theme));
- }
- Ok(())
-}
diff --git a/projects/valkyrie-types/tests/main.rs b/projects/valkyrie-types/tests/main.rs
index 59a8e99d..d1120997 100644
--- a/projects/valkyrie-types/tests/main.rs
+++ b/projects/valkyrie-types/tests/main.rs
@@ -5,14 +5,6 @@ fn ready() {
println!("it works!")
}
-#[test]
-fn test_primitive() {
- let value: usize = 0;
- assert_type(value, "Unsigned64", "std::primitive::Unsigned64");
- let value: f64 = 0.0;
- assert_type(value, "Float64", "std::primitive::Float64");
-}
-
#[test]
fn test_list_index() {
let out = ValkyrieList::from_iter(vec!['1', '2', '3', '4', '5', '6', '7', '8', '9']);
@@ -20,27 +12,6 @@ fn test_list_index() {
println!("2: {:?}", out.get_ordinal(-1));
println!("2: {:?}", out.get_range(1, -1, 1).collect::>());
}
-#[test]
-fn test_list() {
- let value: Vec = vec![];
- assert_type(value, "List[Unsigned64]", "std::collection::List[std::primitive::Unsigned64]");
- // let value: Option = None;
- // assert_type(value, "Option[u64]", "std::primitive::Option[std::primitive::u64]");
- // let value: Option