Skip to content

Commit

Permalink
Add file
Browse files Browse the repository at this point in the history
  • Loading branch information
ryuichiueda committed Jan 20, 2024
1 parent 6c60867 commit b676f93
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/elements.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ pub mod pipeline;
pub mod command;
pub mod io;
pub mod word;
pub mod subword;

use self::io::pipe::Pipe;
26 changes: 26 additions & 0 deletions src/elements/subword.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//SPDX-FileCopyrightText: 2022 Ryuichi Ueda [email protected]
//SPDX-License-Identifier: BSD-3-Clause

pub mod unquoted;
pub mod brace;

use crate::{Feeder, ShellCore};
use super::subword::unquoted::UnquotedSubword;
use std::fmt;
use std::fmt::Debug;

impl Debug for dyn Subword {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
fmt.debug_struct(&self.get_text()).finish()
}
}

pub trait Subword {
fn get_text(&self) -> String;
fn eval(&mut self) -> Vec<Vec<String>>;
}

pub fn parse(feeder: &mut Feeder, core: &mut ShellCore) -> Option<Box<dyn Subword>> {
if let Some(a) = UnquotedSubword::parse(feeder, core){ Some(Box::new(a)) }
else{ None }
}
2 changes: 2 additions & 0 deletions src/elements/word.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
//SPDX-License-Identifier: BSD-3-Clause

use crate::{Feeder, ShellCore};
use crate::elements::subword;
use crate::elements::subword::Subword;

#[derive(Debug)]
pub struct Word {
Expand Down

0 comments on commit b676f93

Please sign in to comment.