From 1b23fbf6836b320f1783e804e50a8d3bbd9e11e8 Mon Sep 17 00:00:00 2001 From: Jesse Brault Date: Mon, 22 Sep 2025 20:57:45 -0500 Subject: [PATCH] Fix struct spec. --- ast-generator/src/spec/struct_spec.rs | 47 +++++++++++++++++++++++++-- 1 file changed, 44 insertions(+), 3 deletions(-) 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)]