diff --git a/ast-generator/src/spec/struct_spec.rs b/ast-generator/src/spec/struct_spec.rs index 56acd01..780e23a 100644 --- a/ast-generator/src/spec/struct_spec.rs +++ b/ast-generator/src/spec/struct_spec.rs @@ -48,15 +48,15 @@ impl SkipChild { pub struct VecChild { name: String, rule: String, - kind: String, + build: Box } impl VecChild { - pub fn new(name: &str, rule: &str, kind: &str) -> Self { + pub fn new(name: &str, rule: &str, build: Box) -> Self { Self { name: name.to_string(), rule: rule.to_string(), - kind: kind.to_string(), + build } } @@ -69,10 +69,51 @@ impl VecChild { pub fn rule(&self) -> &str { &self.rule } + + pub fn build(&self) -> &VecChildBuild { + &self.build + } +} +pub enum VecChildBuild { + String(VecChildStringBuild), + Node(VecChildNodeBuild) +} + +pub struct VecChildStringBuild { + with: String +} + +impl VecChildStringBuild { + pub fn new(with: &str) -> Self { + Self { with: with.to_string() } + } + + pub fn with(&self) -> &str { + &self.with + } +} + +pub struct VecChildNodeBuild { + kind: String, + with: String +} + +impl VecChildNodeBuild { + pub fn new(kind: &str, with: &str) -> Self { + Self { + kind: kind.to_string(), + with: with.to_string() + } + } + pub fn kind(&self) -> &str { &self.kind } + + pub fn with(&self) -> &str { + &self.with + } } #[derive(Debug)]