summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--Cargo.lock31
-rw-r--r--Cargo.toml3
-rw-r--r--modules/morgana_proc/Cargo.toml9
-rw-r--r--modules/morgana_proc/src/lib.rs21
-rw-r--r--modules/site_test/src/main.rs10
-rw-r--r--src/lib.rs1
6 files changed, 73 insertions, 2 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 7238fe6..5ebe58f 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -108,6 +108,14 @@ name = "morgana"
 version = "0.1.0"
 dependencies = [
  "futures",
+ "morgana_proc",
+]
+
+[[package]]
+name = "morgana_proc"
+version = "0.0.0"
+dependencies = [
+ "unsynn",
 ]
 
 [[package]]
@@ -118,6 +126,12 @@ dependencies = [
 ]
 
 [[package]]
+name = "mutants"
+version = "0.0.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "bc0287524726960e07b119cebd01678f852f147742ae0d925e6a520dca956126"
+
+[[package]]
 name = "pin-project-lite"
 version = "0.2.16"
 source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -148,6 +162,12 @@ dependencies = [
 ]
 
 [[package]]
+name = "shadow_counted"
+version = "0.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "65da48d447333cebe1aadbdd3662f3ba56e76e67f53bc46f3dd5f67c74629d6b"
+
+[[package]]
 name = "slab"
 version = "0.4.9"
 source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -172,3 +192,14 @@ name = "unicode-ident"
 version = "1.0.18"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512"
+
+[[package]]
+name = "unsynn"
+version = "0.0.26"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "14013db4ac11f92d4df4b56edb431eab9c1d9f7aee4791f3205b6a1119b83f54"
+dependencies = [
+ "mutants",
+ "proc-macro2",
+ "shadow_counted",
+]
diff --git a/Cargo.toml b/Cargo.toml
index 7fea5f5..772b010 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,5 +1,5 @@
 [workspace]
-members = ["modules/site_test"]
+members = ["modules/site_test", "modules/morgana_proc"]
 
 [package]
 name = "morgana"
@@ -8,6 +8,7 @@ edition = "2021"
 
 [dependencies]
 futures = "0.3.31"
+morgana_proc = { path = "./modules/morgana_proc/" }
 
 [features]
 blocking = ["futures/executor"]
diff --git a/modules/morgana_proc/Cargo.toml b/modules/morgana_proc/Cargo.toml
new file mode 100644
index 0000000..fb1e28a
--- /dev/null
+++ b/modules/morgana_proc/Cargo.toml
@@ -0,0 +1,9 @@
+[package]
+name = "morgana_proc"
+edition = "2021"
+
+[lib]
+proc-macro = true
+
+[dependencies]
+unsynn = "0.0.26"
diff --git a/modules/morgana_proc/src/lib.rs b/modules/morgana_proc/src/lib.rs
new file mode 100644
index 0000000..f4932d6
--- /dev/null
+++ b/modules/morgana_proc/src/lib.rs
@@ -0,0 +1,21 @@
+extern crate proc_macro;
+
+use unsynn::*;
+
+#[proc_macro]
+pub fn morx(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
+    println!("{:?}", input);
+    let ast: MorxBlock = unsynn::TokenStream::from(input).to_token_iter().parse_all().unwrap();
+
+    LiteralString::from_str("test").to_token_stream().into()
+}
+
+
+unsynn! {
+    struct MorxBlock(Any<Either<Literal, Box<MorxNode>>, Nothing>);
+    struct MorxNode(Ident, MorxChildren);
+    struct MorxAttr(Either<Ident, MorxComplexAttr>);
+    struct MorxComplexAttr(Ident, Assign, AttrValue);
+    struct AttrValue(Either<Ident, Literal, BracketGroup>);
+    struct MorxChildren(Either<EndOfStream, Semicolon, BracketGroupContaining<Box<MorxBlock>>>);
+}
diff --git a/modules/site_test/src/main.rs b/modules/site_test/src/main.rs
index 7ef98a1..55432d9 100644
--- a/modules/site_test/src/main.rs
+++ b/modules/site_test/src/main.rs
@@ -1,6 +1,6 @@
 use std::collections::HashMap;
 
-use morgana::{Component, RenderNode};
+use morgana::{morx, Component, RenderNode};
 
 pub fn main() {
     let parent = ParentLayout {
@@ -25,6 +25,14 @@ struct ParentLayout {
 
 impl Component for ParentLayout {
     fn render(self: Box<Self>) -> Vec<RenderNode> {
+        let test = morx! {
+            html lang="en-US" {
+                head { title { "test thing" } }
+                body { "some document" }
+            }
+        };
+
+
         vec![
             RenderNode::Element { name: "html".to_string(), attributes: HashMap::from([("lang".to_string(), "en-US".to_string())]), children: vec![
                 RenderNode::Element { name: "head".to_string(), attributes: HashMap::new(), children: vec![
diff --git a/src/lib.rs b/src/lib.rs
index 0178d60..2aa0d7a 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1,6 +1,7 @@
 mod render;
 
 pub use render::{Component, RenderNode};
+pub use morgana_proc::morx;
 
 pub async fn render_tree(parent_node: RenderNode) -> String {
     parent_node.render_to_string().await