aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main.rs
diff options
context:
space:
mode:
authorJohannes Stoelp <johannes.stoelp@gmail.com>2021-08-30 22:13:08 +0200
committerJohannes Stoelp <johannes.stoelp@gmail.com>2021-09-02 23:46:44 +0200
commitdfe15c16de2f8c80de55ac442ff8d8ff3687fb11 (patch)
tree36c2989b35995692df4f8d2552eab3de87c2ee8b /src/main.rs
downloadllvm-kaleidoscope-rs-dfe15c16de2f8c80de55ac442ff8d8ff3687fb11.tar.gz
llvm-kaleidoscope-rs-dfe15c16de2f8c80de55ac442ff8d8ff3687fb11.zip
ch1: added minimal lexer implementation following chapter 1chapter1
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs18
1 files changed, 18 insertions, 0 deletions
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());
+ }
+}