summary refs log tree commit diff
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-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
3 files changed, 39 insertions, 1 deletions
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![