diff options
author | NanoTech | 2016-12-06 09:42:42 +0000 |
---|---|---|
committer | NanoTech | 2017-03-10 23:48:27 -0600 |
commit | 84c7ec41455e9f7b9bdd7a7336a877fb04e4bd3a (patch) | |
tree | 4064be9c639a53a7ed9e3f8dd55a135891a2c4d3 /src | |
parent | d6240a4b184cac1fbf61ab35f9f3813efb780d31 (diff) |
Read and parse stdin
Diffstat (limited to 'src')
-rw-r--r-- | src/main.rs | 9 | ||||
-rw-r--r-- | src/parser.rs | 2 |
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)) } |