summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main.rs9
-rw-r--r--src/parser.rs2
2 files changed, 7 insertions, 4 deletions
diff --git a/src/main.rs b/src/main.rs
index aebbad9..e5238dc 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -9,12 +9,15 @@ mod grammar_util;
pub mod lexer;
pub mod parser;
+use std::io::{self, Read};
+
fn main() {
- println!("Hello, world!");
+ let mut buffer = String::new();
+ io::stdin().read_to_string(&mut buffer).unwrap();
+ let r = parser::parse_expr(&buffer);
+ println!("{:?}", r);
/*
- inText <- Data.Text.Lazy.IO.getContents
-
expr <- case exprFromText (Directed "(stdin)" 0 0 0 0) inText of
Left err -> Control.Exception.throwIO err
Right expr -> return expr
diff --git a/src/parser.rs b/src/parser.rs
index 1561230..1ecf040 100644
--- a/src/parser.rs
+++ b/src/parser.rs
@@ -6,7 +6,7 @@ use lexer::{Lexer, LexicalError, Tok};
pub type ParseError = lalrpop_util::ParseError<usize, Tok, LexicalError>;
-fn parse_expr(s: &str) -> Result<BoxExpr, ParseError> {
+pub fn parse_expr(s: &str) -> Result<BoxExpr, ParseError> {
grammar::parse_Expr(Lexer::new(s))
}