summaryrefslogtreecommitdiff
path: root/src/theory/ast.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/theory/ast.rs')
-rw-r--r--src/theory/ast.rs45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/theory/ast.rs b/src/theory/ast.rs
new file mode 100644
index 0000000..4236cd7
--- /dev/null
+++ b/src/theory/ast.rs
@@ -0,0 +1,45 @@
+use derive_more::Display;
+
+#[derive(Display)]
+#[display("{name}{{\n{}\n}}", DHList((stages, "\n")))]
+pub struct ASTTheory {
+ name: String,
+ stages: Vec<ASTStage>,
+}
+
+#[derive(Display)]
+#[display("{name} {} => {}", DHList((domain, ",")), DHList((domain, ",")))]
+pub struct ASTStage {
+ name: String,
+ domain: Vec<ASTRecordEntry>,
+ codomain: Vec<ASTRecordEntry>,
+}
+
+#[derive(Display)]
+pub enum ASTRecordEntry {
+ #[display("{name} type")]
+ ASTType { name: String },
+ #[display("{path} : {of}")]
+ ASTTerm { path: ASTPath, of: String },
+ #[display("{path} ~: {of}")]
+ ASTDependency { path: ASTPath, of: String },
+ #[display("{lhs_path} == {rhs_path}")]
+ ASTEquality {
+ lhs_path: ASTPath,
+ rhs_path: ASTPath,
+ },
+ #[display("let {var} = {stage}({})", DHList((args, ", ")))]
+ ASTLet {
+ var: String,
+ stage: String,
+ args: Vec<ASTPath>,
+ },
+}
+
+#[derive(Display)]
+#[display("{}", DHList((_0, ".")))]
+pub struct ASTPath(Vec<String>);
+
+#[derive(Display)]
+#[display("{}", _0.0.iter().map(|x| x.to_string()).collect::<Vec<_>>().join(_0.1))]
+struct DHList<'a, T: std::fmt::Display>((&'a Vec<T>, &'static str));