1#[cfg(feature = "serde-impl")]
2use serde::{Deserialize, Serialize};
3use swc_atoms::Atom;
4use swc_common::{ast_node, EqIgnoreSpan, Span};
5
6#[ast_node("TokenAndSpan")]
7#[derive(Eq, Hash, EqIgnoreSpan)]
8pub struct TokenAndSpan {
9 pub span: Span,
10 pub token: Token,
11}
12
13#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, EqIgnoreSpan)]
14#[cfg_attr(feature = "serde-impl", derive(Serialize, Deserialize))]
15#[cfg_attr(
16 feature = "encoding-impl",
17 derive(::swc_common::Encode, ::swc_common::Decode)
18)]
19pub struct AttributeToken {
20 pub span: Span,
21 pub name: Atom,
22 #[cfg_attr(
23 feature = "encoding-impl",
24 encoding(with = "cbor4ii::core::types::Maybe")
25 )]
26 pub raw_name: Option<Atom>,
27 #[cfg_attr(
28 feature = "encoding-impl",
29 encoding(with = "cbor4ii::core::types::Maybe")
30 )]
31 pub value: Option<Atom>,
32 #[cfg_attr(
33 feature = "encoding-impl",
34 encoding(with = "cbor4ii::core::types::Maybe")
35 )]
36 pub raw_value: Option<Atom>,
37}
38
39#[derive(Debug, Clone, PartialEq, Eq, Hash, EqIgnoreSpan)]
40#[cfg_attr(feature = "serde-impl", derive(Serialize, Deserialize))]
41#[cfg_attr(
42 feature = "encoding-impl",
43 derive(::swc_common::Encode, ::swc_common::Decode)
44)]
45pub enum Token {
46 Doctype {
47 #[cfg_attr(
49 feature = "encoding-impl",
50 encoding(with = "cbor4ii::core::types::Maybe")
51 )]
52 name: Option<Atom>,
53 #[cfg_attr(
55 feature = "encoding-impl",
56 encoding(with = "cbor4ii::core::types::Maybe")
57 )]
58 public_id: Option<Atom>,
59 #[cfg_attr(
61 feature = "encoding-impl",
62 encoding(with = "cbor4ii::core::types::Maybe")
63 )]
64 system_id: Option<Atom>,
65 #[cfg_attr(
67 feature = "encoding-impl",
68 encoding(with = "cbor4ii::core::types::Maybe")
69 )]
70 raw: Option<Atom>,
71 },
72 StartTag {
73 tag_name: Atom,
74 attributes: Vec<AttributeToken>,
75 },
76 EndTag {
77 tag_name: Atom,
78 attributes: Vec<AttributeToken>,
79 },
80 EmptyTag {
81 tag_name: Atom,
82 attributes: Vec<AttributeToken>,
83 },
84 Comment {
85 data: Atom,
86 raw: Atom,
87 },
88 Character {
89 #[cfg_attr(
90 feature = "encoding-impl",
91 encoding(with = "swc_common::serializer::WithChar")
92 )]
93 value: char,
94 #[cfg_attr(
95 feature = "encoding-impl",
96 encoding(with = "cbor4ii::core::types::Maybe")
97 )]
98 raw: Option<Atom>,
99 },
100 ProcessingInstruction {
101 target: Atom,
102 data: Atom,
103 },
104 Cdata {
105 data: Atom,
106 raw: Atom,
107 },
108 Eof,
109}