From 5a7718698373d07a29fffcb792acdb81aa7712d7 Mon Sep 17 00:00:00 2001 From: Rory Dudley Date: Sat, 23 Mar 2024 02:45:54 -0600 Subject: read() and recite() overhaul Rebuilt the LR parser (i.e. read()) from the ground up. This required that some changes be made to recite(), in order to accomodate the new data structures. These data structures were each split out into their own file, in order to make working with each component a bit easier. In addition to reworking the parts of the parser already present, some new features were also added, such as: - Support for strings (' and ") - Support for environment variables ($) - Support for interpreting tild as $HOME (~) - Support for sub-reading and sub-reciting (`) --- src/main.rs | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs index 04d58eb..75c2d46 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,9 +1,10 @@ -mod recite; -use recite::path::prefresh; -use recite::Poem; use std::io::{self, Write}; use std::path::Path; use std::sync::{Arc, Mutex}; +mod path; +use path::prefresh; +mod poem; +use poem::{read::Readable, recite::Reciteable, Poem}; /// Starts the main shell loop /// @@ -57,15 +58,23 @@ fn repl(path: &Vec<&Path>, prompt: &str, at_prompt: &mut Arc>) { // Not at the prompt *at_prompt.lock().unwrap() = false; - // Parse a poem + // Parse the poem let poem = Poem::read(poetry); - match poem { - Some(poem) => match poem.recite(path, &mut bins) { - Ok(_) => {} - Err(e) => eprintln!("dwvsh: {}", e.to_string().to_lowercase()), - }, - None => {} + let poem = match poem { + Ok(poem) => poem, + Err(e) => { + eprintln!("dwvsh: {}", e.to_string().to_lowercase()); + continue; + } }; + + // println!("{:?}", poem); + + // Recite the poem + match poem.recite(path, &mut bins, None) { + Ok(_) => {} + Err(e) => eprintln!("dwvsh: {}", e.to_string().to_lowercase()), + } } } -- cgit v1.2.3