1#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
2pub struct TextRange {
3 pub start: usize,
4 pub end: usize,
5}
6
7impl TextRange {
8 #[must_use]
9 pub const fn new(start: usize, end: usize) -> Self {
10 Self { start, end }
11 }
12}
13
14#[derive(Debug, Clone, PartialEq, Eq)]
15pub struct File {
16 pub items: Vec<Statement>,
17 pub range: TextRange,
18}
19
20#[derive(Debug, Clone, PartialEq, Eq)]
21pub enum Statement {
22 Command(CommandInvocation),
23}
24
25#[derive(Debug, Clone, PartialEq, Eq)]
26pub struct CommandInvocation {
27 pub name: Identifier,
28 pub arguments: Vec<Argument>,
29 pub range: TextRange,
30}
31
32#[derive(Debug, Clone, PartialEq, Eq)]
33pub struct Identifier {
34 pub text: String,
35 pub range: TextRange,
36}
37
38#[derive(Debug, Clone, PartialEq, Eq)]
39pub enum Argument {
40 Unquoted(UnquotedArgument),
41 Quoted(QuotedArgument),
42 Bracket(BracketArgument),
43 ParenGroup(ParenGroup),
44}
45
46impl Argument {
47 #[must_use]
48 pub const fn range(&self) -> TextRange {
49 match self {
50 Self::Unquoted(argument) => argument.range,
51 Self::Quoted(argument) => argument.range,
52 Self::Bracket(argument) => argument.range,
53 Self::ParenGroup(group) => group.range,
54 }
55 }
56}
57
58#[derive(Debug, Clone, PartialEq, Eq)]
59pub struct UnquotedArgument {
60 pub text: String,
61 pub range: TextRange,
62}
63
64#[derive(Debug, Clone, PartialEq, Eq)]
65pub struct QuotedArgument {
66 pub text: String,
67 pub range: TextRange,
68}
69
70#[derive(Debug, Clone, PartialEq, Eq)]
71pub struct BracketArgument {
72 pub text: String,
73 pub range: TextRange,
74}
75
76#[derive(Debug, Clone, PartialEq, Eq)]
77pub struct ParenGroup {
78 pub items: Vec<Argument>,
79 pub range: TextRange,
80}