From dfe15c16de2f8c80de55ac442ff8d8ff3687fb11 Mon Sep 17 00:00:00 2001 From: Johannes Stoelp Date: Mon, 30 Aug 2021 22:13:08 +0200 Subject: ch1: added minimal lexer implementation following chapter 1 --- src/main.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 src/main.rs (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..361f76f --- /dev/null +++ b/src/main.rs @@ -0,0 +1,18 @@ +mod lexer; + +use lexer::Lexer; +use std::io::Read; + +fn main() { + println!("Lex stdin."); + println!("ENTER to lex current input."); + println!("C-c to exit."); + let mut lex = Lexer::new(std::io::stdin().bytes().filter_map(|v| { + let v = v.ok()?; + Some(v.into()) + })); + + loop { + println!("{:?}", lex.gettok()); + } +} -- cgit v1.2.3