Skip to main content

mago_syntax/ast/ast/
inline.rs

1use serde::Serialize;
2use strum::Display;
3
4use mago_span::HasSpan;
5use mago_span::Span;
6
7#[derive(Debug, Clone, Copy, Eq, PartialEq, Hash, Serialize, PartialOrd, Ord, Display)]
8#[serde(tag = "type", content = "value")]
9pub enum InlineKind {
10    Text,
11    Shebang,
12}
13
14/// Represents inline text within a PHP script.
15///
16/// # Example:
17///
18/// ```php
19/// This is an inline text.
20/// <?php
21///   // PHP code
22/// ?>
23/// This is another inline text.
24/// ```
25#[derive(Debug, Clone, Copy, Eq, PartialEq, Hash, Serialize, PartialOrd, Ord)]
26pub struct Inline<'arena> {
27    pub kind: InlineKind,
28    pub span: Span,
29    pub value: &'arena str,
30}
31
32impl HasSpan for Inline<'_> {
33    fn span(&self) -> Span {
34        self.span
35    }
36}