From bd082b186b9f025655ce98a09583ae999788a890 Mon Sep 17 00:00:00 2001 From: Borodinov Ilya Date: Mon, 11 Nov 2024 22:44:25 +0300 Subject: [PATCH] start ast --- Cargo.lock | 19 +++++++++++++++++++ crates/ast/src/lib.rs | 32 +++++++++++++++++++++----------- 2 files changed, 40 insertions(+), 11 deletions(-) create mode 100644 Cargo.lock diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..4ff19a7 --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,19 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "cogs_ast" +version = "0.1.0" + +[[package]] +name = "cogs_axum" +version = "0.1.0" + +[[package]] +name = "cogs_codegen" +version = "0.1.0" + +[[package]] +name = "cogs_parser" +version = "0.1.0" diff --git a/crates/ast/src/lib.rs b/crates/ast/src/lib.rs index b93cf3f..90d2fd8 100644 --- a/crates/ast/src/lib.rs +++ b/crates/ast/src/lib.rs @@ -1,14 +1,24 @@ -pub fn add(left: u64, right: u64) -> u64 { - left + right +pub struct Component { + pub elements: Vec, } -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn it_works() { - let result = add(2, 2); - assert_eq!(result, 4); - } +pub enum Element { + Html(HtmlTag), + Block(CodeBlock), +} + +pub struct HtmlTag { + pub tag: String, + pub attributes: Vec, + pub content: Vec, +} + +pub struct Attribute { + pub name: String, + pub value: String, +} + +pub struct CodeBlock { + pub is_async: bool, + pub content: String, }