sycamore_view_parser/
ir.rs1use proc_macro2::Span;
4use syn::spanned::Spanned;
5use syn::{Expr, Ident, LitStr, Path};
6
7pub struct Root(pub Vec<Node>);
9
10pub enum Node {
11 Tag(TagNode),
12 Text(TextNode),
13 Dyn(DynNode),
14}
15
16pub enum NodeType {
17 Tag,
18 Text,
19 Dyn,
20}
21
22pub struct TagNode {
23 pub ident: TagIdent,
24 pub props: Vec<Prop>,
25 pub children: Root,
26}
27
28pub enum TagIdent {
29 Path(Path),
31 Hyphenated(String),
34}
35
36impl TagIdent {
37 pub fn span(&self) -> Span {
38 match self {
39 Self::Path(path) => path.span(),
40 Self::Hyphenated(_) => Span::call_site(),
41 }
42 }
43}
44
45pub struct Prop {
46 pub ty: PropType,
47 pub value: Expr,
48 pub span: Span,
49}
50
51pub enum PropType {
52 Plain { ident: Ident },
54 PlainHyphenated { ident: String },
56 PlainQuoted { ident: String },
58 Directive { dir: Ident, ident: Ident },
60 Ref,
62 Spread,
64}
65
66pub struct TextNode {
67 pub value: LitStr,
68}
69
70pub struct DynNode {
71 pub value: Expr,
72}