aboutsummaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
authorJJ2023-04-05 07:24:06 +0000
committerJJ2023-04-05 16:17:05 +0000
commita68aa104c91a617a2d78a1015f786dce7fdac795 (patch)
tree8264bf5c55492c4ebef49d8b2d7289efefcf6698 /src/main.rs
wip
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs51
1 files changed, 51 insertions, 0 deletions
diff --git a/src/main.rs b/src/main.rs
new file mode 100644
index 0000000..f31e163
--- /dev/null
+++ b/src/main.rs
@@ -0,0 +1,51 @@
+use std::io::{Write, stdout, stdin};
+use crate::ast::*;
+
+mod ast;
+mod classes;
+mod effects;
+mod parser;
+mod simple;
+
+fn main() {
+ println!("type-systems");
+ let mut input = String::new();
+ loop {
+ println!("infer, check, or execute? (i/c/e)");
+ print!("\x1b[1m==> \x1b[22m");
+ stdout().flush().unwrap();
+
+ input.clear();
+ stdin().read_line(&mut input).unwrap();
+ match input.trim() {
+ "i" | "g" | "infer" => {
+ println!("enter partially annotated expression to fully infer");
+ print!("\x1b[1m====> \x1b[22m");
+ stdout().flush().unwrap();
+
+ input.clear();
+ stdin().read_line(&mut input).unwrap();
+ simple::infer(Context::new(), parser::parse(&input));
+ },
+ "c" | "t" | "check" | "typecheck" => {
+ println!("enter fully annotated expression to typecheck");
+ print!("\x1b[1m====> \x1b[22m");
+ stdout().flush().unwrap();
+
+ input.clear();
+ stdin().read_line(&mut input).unwrap();
+ simple::check(Context::new(), parser::parse(&input));
+ },
+ "e" | "r" | "execute" | "run" => {
+ println!("enter expression to execute");
+ print!("\x1b[1m====> \x1b[22m");
+ stdout().flush().unwrap();
+
+ input.clear();
+ stdin().read_line(&mut input).unwrap();
+ simple::execute(Context::new(), parser::parse(&input));
+ },
+ _ => println!("invalid option {}. please try again.", input.trim())
+ }
+ }
+}