1use swc_atoms::Atom;
2use swc_common::{ast_node, EqIgnoreSpan, Span};
3
4#[ast_node("TokenAndSpan")]
5#[derive(Eq, Hash, EqIgnoreSpan)]
6pub struct TokenAndSpan {
7 pub span: Span,
8 pub token: Token,
9}
10
11#[ast_node]
12#[derive(Eq, PartialOrd, Ord, Hash, EqIgnoreSpan)]
13pub struct AttributeToken {
14 pub span: Span,
15
16 pub name: Atom,
17 #[cfg_attr(
18 feature = "encoding-impl",
19 encoding(with = "cbor4ii::core::types::Maybe")
20 )]
21 pub raw_name: Option<Atom>,
22
23 #[cfg_attr(
24 feature = "encoding-impl",
25 encoding(with = "cbor4ii::core::types::Maybe")
26 )]
27 pub value: Option<Atom>,
28 #[cfg_attr(
29 feature = "encoding-impl",
30 encoding(with = "cbor4ii::core::types::Maybe")
31 )]
32 pub raw_value: Option<Atom>,
33}
34
35#[derive(Debug, Clone, PartialEq, Eq, Hash, EqIgnoreSpan)]
36#[cfg_attr(
37 feature = "rkyv",
38 derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)
39)]
40#[cfg_attr(
41 feature = "rkyv",
42 rkyv(serialize_bounds(__S: rkyv::ser::Writer + rkyv::ser::Allocator,
43 __S::Error: rkyv::rancor::Source))
44)]
45#[cfg_attr(feature = "rkyv", derive(bytecheck::CheckBytes))]
46#[cfg_attr(feature = "rkyv", repr(u32))]
47#[cfg_attr(feature = "serde-impl", derive(serde::Serialize, serde::Deserialize))]
48#[cfg_attr(
49 feature = "encoding-impl",
50 derive(::swc_common::Encode, ::swc_common::Decode)
51)]
52pub enum Raw {
53 Same,
54 Atom(Atom),
55}
56
57#[derive(Debug, Clone, PartialEq, Eq, Hash, EqIgnoreSpan)]
58#[cfg_attr(
59 feature = "rkyv",
60 derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)
61)]
62#[cfg_attr(
63 feature = "rkyv",
64 rkyv(serialize_bounds(__S: rkyv::ser::Writer + rkyv::ser::Allocator,
65 __S::Error: rkyv::rancor::Source))
66)]
67#[cfg_attr(feature = "rkyv", derive(bytecheck::CheckBytes))]
68#[cfg_attr(feature = "rkyv", repr(u32))]
69#[cfg_attr(feature = "serde-impl", derive(serde::Serialize, serde::Deserialize))]
70#[cfg_attr(
71 feature = "encoding-impl",
72 derive(::swc_common::Encode, ::swc_common::Decode)
73)]
74pub enum Token {
75 Doctype {
76 #[cfg_attr(
78 feature = "encoding-impl",
79 encoding(with = "cbor4ii::core::types::Maybe")
80 )]
81 name: Option<Atom>,
82 force_quirks: bool,
84
85 #[cfg_attr(
87 feature = "encoding-impl",
88 encoding(with = "cbor4ii::core::types::Maybe")
89 )]
90 public_id: Option<Atom>,
91
92 #[cfg_attr(
94 feature = "encoding-impl",
95 encoding(with = "cbor4ii::core::types::Maybe")
96 )]
97 system_id: Option<Atom>,
98 #[cfg_attr(
100 feature = "encoding-impl",
101 encoding(with = "cbor4ii::core::types::Maybe")
102 )]
103 raw: Option<Atom>,
104 },
105 StartTag {
106 tag_name: Atom,
107 #[cfg_attr(
108 feature = "encoding-impl",
109 encoding(with = "cbor4ii::core::types::Maybe")
110 )]
111 raw_tag_name: Option<Atom>,
112 is_self_closing: bool,
113 attributes: Vec<AttributeToken>,
114 },
115 EndTag {
116 tag_name: Atom,
117 #[cfg_attr(
118 feature = "encoding-impl",
119 encoding(with = "cbor4ii::core::types::Maybe")
120 )]
121 raw_tag_name: Option<Atom>,
122 is_self_closing: bool,
123 attributes: Vec<AttributeToken>,
124 },
125 Comment {
126 data: Atom,
127 #[cfg_attr(
128 feature = "encoding-impl",
129 encoding(with = "cbor4ii::core::types::Maybe")
130 )]
131 raw: Option<Atom>,
132 },
133 Character {
134 #[cfg_attr(
135 feature = "encoding-impl",
136 encoding(with = "::swc_common::serializer::WithChar")
137 )]
138 value: char,
139 #[cfg_attr(
140 feature = "encoding-impl",
141 encoding(with = "cbor4ii::core::types::Maybe")
142 )]
143 raw: Option<Raw>,
144 },
145 Eof,
146}