summaryrefslogtreecommitdiff
path: root/src/main.rs
blob: e60a893227857606e17cd6b543c81c7e5a2f3980 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
extern crate lalrpop_util;
#[macro_use]
extern crate nom;

mod core;
pub use core::*;
pub mod grammar;
mod grammar_util;
pub mod lexer;
pub mod parser;

use std::io::{self, Read};

fn main() {
    let mut buffer = String::new();
    io::stdin().read_to_string(&mut buffer).unwrap();
    match parser::parse_expr(&buffer) {
        Ok(e) => println!("{:?}", e),
        Err(lalrpop_util::ParseError::User { error: lexer::LexicalError::Error(pos, e) }) => {
            let context = &buffer[pos..::std::cmp::min(buffer.len(), pos + 20)];
            println!("Unexpected token in {:?}: {:?}...", e, context);
        }
        Err(e) => println!("{:?}", e),
    }

    /*
    expr <- case exprFromText (Directed "(stdin)" 0 0 0 0) inText of
        Left  err  -> Control.Exception.throwIO err
        Right expr -> return expr

    expr' <- load expr

    typeExpr <- case Dhall.TypeCheck.typeOf expr' of
        Left  err      -> Control.Exception.throwIO err
        Right typeExpr -> return typeExpr
    Data.Text.Lazy.IO.hPutStrLn stderr (pretty (normalize typeExpr))
    Data.Text.Lazy.IO.hPutStrLn stderr mempty
    Data.Text.Lazy.IO.putStrLn (pretty (normalize expr')) )
    */
}