wip: add whitespace parsing to rsx

This commit is contained in:
Jonathan Kelley committed 2022-09-30 10:51:53 -07:00
1 parent 5313fc0cc6
commit 181a51a63b
14 files changed
+278 -24

No files matched your search

+33
View File
@@ -0,0 +1,33 @@
use proc_macro2::{Span, TokenStream as TokenStream2};
use quote::{quote, ToTokens, TokenStreamExt};
use syn::{parse::Parse, LitStr};
use crate::whitespace::Whitespace;
#[derive(Debug, PartialEq, Eq)]
pub struct TextNode {
pub ws: Whitespace,
pub text: LitStr,
}
impl TextNode {
pub fn span(&self) -> Span {
self.text.span()
}
}
impl Parse for TextNode {
fn parse(input: syn::parse::ParseStream) -> syn::Result<Self> {
Ok(Self {
ws: Whitespace::default(),
text: input.parse()?,
})
}
}
impl ToTokens for TextNode {
fn to_tokens(&self, tokens: &mut TokenStream2) {
let text = &self.text;
tokens.append_all(quote! { #text });
}
}