summaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
authorNanoTech2016-12-08 03:12:38 -0600
committerNanoTech2017-03-10 23:48:28 -0600
commite72192c0c1825f36f054263437029d05d717c957 (patch)
tree5002416c3e358edc3e1ca70a1aba68b97ea1e02c /src/main.rs
parent9598e4ff43a8fd4bc2aa2af75ff1094c2ef96258 (diff)
Begin implementing type checking
Diffstat (limited to '')
-rw-r--r--src/main.rs20
1 files changed, 13 insertions, 7 deletions
diff --git a/src/main.rs b/src/main.rs
index deb6ac3..17c990d 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -4,12 +4,14 @@ extern crate lalrpop_util;
extern crate nom;
extern crate term_painter;
+pub mod context;
mod core;
pub use core::*;
pub mod grammar;
mod grammar_util;
pub mod lexer;
pub mod parser;
+pub mod typecheck;
use std::io::{self, Read};
@@ -62,29 +64,33 @@ fn print_error(message: &str, source: &str, start: usize, end: usize) {
fn main() {
let mut buffer = String::new();
io::stdin().read_to_string(&mut buffer).unwrap();
- match parser::parse_expr(&buffer) {
- Ok(e) => println!("{:?}", e),
+ let expr = match parser::parse_expr(&buffer) {
+ Ok(e) => e,
Err(lalrpop_util::ParseError::User { error: lexer::LexicalError::Error(pos, e) }) => {
print_error(&format!("Unexpected token {:?}", e), &buffer, pos, pos);
+ return;
}
Err(lalrpop_util::ParseError::UnrecognizedToken { token: Some((start, t, end)), expected: e }) => {
print_error(&format!("Unrecognized token {:?}", t), &buffer, start, end);
if e.len() > 0 {
println!("Expected {:?}", e);
}
+ return;
}
Err(e) => {
print_error(&format!("Parser error {:?}", e), &buffer, 0, 0);
+ return;
}
- }
+ };
- /*
- expr <- case exprFromText (Directed "(stdin)" 0 0 0 0) inText of
- Left err -> Control.Exception.throwIO err
- Right expr -> return expr
+ println!("{:?}", expr);
+ /*
expr' <- load expr
+ */
+ println!("{:?}", typecheck::type_of(&expr));
+ /*
typeExpr <- case Dhall.TypeCheck.typeOf expr' of
Left err -> Control.Exception.throwIO err
Right typeExpr -> return typeExpr