diff --git a/src/parser/list.rs b/src/parser/list.rs new file mode 100644 index 00000000..235a5831 --- /dev/null +++ b/src/parser/list.rs @@ -0,0 +1,29 @@ +use std::rc::Rc; + +pub struct List { + head: Option>>, +} + +pub struct Node { + data: T, + parent: Option>>, +} + +impl List { + pub fn new() -> Self { + List { head: None } + } + + pub fn push_front(&self, data: T) -> List { + List { + head: Some(Rc::new(Node { + data: data, + parent: self.head.clone(), + })), + } + } + + pub fn get_data(&self) -> &T { + &self.data + } +} diff --git a/src/parser/mod.rs b/src/parser/mod.rs index 74d94558..4a9a2727 100644 --- a/src/parser/mod.rs +++ b/src/parser/mod.rs @@ -1,3 +1,4 @@ +mod list; mod new_context; mod nom_context; mod parser_with_context; diff --git a/src/parser/new_context.rs b/src/parser/new_context.rs index f184433a..8b137891 100644 --- a/src/parser/new_context.rs +++ b/src/parser/new_context.rs @@ -1,8 +1 @@ -pub struct List { - head: Option>>, -} -pub struct Node { - data: T, - parent: Option>>, -}