wip: refactor out translation into its own crate
This commit is contained in:
1 parent
4aac2cdae1
commit
14bc007c15
9 files changed
+153
-2
No files matched your search
@@ -1,3 +1,5 @@
|
||||
use crate::comments::UserComment;
|
||||
|
||||
use super::*;
|
||||
|
||||
use proc_macro2::{Span, TokenStream as TokenStream2};
|
||||
@@ -16,6 +18,17 @@ Parse
|
||||
-> component()
|
||||
-> "text {with_args}"
|
||||
-> (0..10).map(|f| rsx!("asd")), // <--- notice the comma - must be a complete expr
|
||||
-> // some comment here (no support for slash asterisk comments - those get deleted completely)
|
||||
|
||||
|
||||
|
||||
div {
|
||||
// Comment
|
||||
div { // a comment here because it shares the line
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
#[derive(PartialEq, Eq, Clone, Debug, Hash)]
|
||||
pub enum BodyNode {
|
||||
@@ -25,6 +38,7 @@ pub enum BodyNode {
|
||||
IfChain(ExprIf),
|
||||
Text(IfmtInput),
|
||||
RawExpr(Expr),
|
||||
Comment(UserComment),
|
||||
}
|
||||
|
||||
impl BodyNode {
|
||||
@@ -40,6 +54,7 @@ impl BodyNode {
|
||||
BodyNode::RawExpr(exp) => exp.span(),
|
||||
BodyNode::ForLoop(fl) => fl.for_token.span(),
|
||||
BodyNode::IfChain(f) => f.if_token.span(),
|
||||
BodyNode::Comment(c) => c.span,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -128,6 +143,7 @@ impl Parse for BodyNode {
|
||||
impl ToTokens for BodyNode {
|
||||
fn to_tokens(&self, tokens: &mut TokenStream2) {
|
||||
match &self {
|
||||
BodyNode::Comment(_) => {}
|
||||
BodyNode::Element(el) => el.to_tokens(tokens),
|
||||
BodyNode::Component(comp) => comp.to_tokens(tokens),
|
||||
BodyNode::Text(txt) => tokens.append_all(quote! {
|
||||
|
||||
Reference in new issue
Block a user