summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Li <li.davidm96@gmail.com>2017-11-04 19:11:55 -0400
committerDavid Li <li.davidm96@gmail.com>2017-11-04 19:11:55 -0400
commitd756b309068eaf991290c39963462efec27ebe6f (patch)
treeea7d8fc7b12a266dfd7ff6f3485bbc6b56fd5510
parentee7c269301f84bd5c7c942900aaa2d96d17d886f (diff)
Add a simple REPL to show parsing
-rw-r--r--src/main.rs15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/main.rs b/src/main.rs
index bd4659b..2564011 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,6 +1,19 @@
pub mod ast;
pub mod taiga;
+use std::io::{self, BufRead};
+
fn main() {
- println!("{:?}", taiga::parse_Program("(3 + 5) * 7"));
+ let stdin = io::stdin();
+ let mut handle = stdin.lock();
+ loop {
+ let mut input = String::new();
+ if let Ok(n) = handle.read_line(&mut input) {
+ if n == 0 { break; }
+ println!("{:?}", taiga::parse_Program(&input));
+ }
+ else {
+ break;
+ }
+ }
}