1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
// SPDX-FileCopyrightText: 2022 Kevin Amado <kamadorueda@gmail.com>
//
// SPDX-License-Identifier: GPL-3.0-only
//! NixEl is a Rust library that turns
//! [Nix](https://nixos.org) code
//! into a correct, typed data-structured.
//!
//! Just use the [parse()] or [parse_bytes()] methods
//! to build a [Parsed] structure
//! and use the [Expression] enum variants to traverse the AST.
//!
//! You can also retrieve [Trivia::Comment]s,
//! [Trivia::MultilineComment]s
//! and [Trivia::Whitespace],
//! using the [Parsed::trivia_before()] and [Parsed::trivia_after()]
//! methods.
//!
//! For example:
//!
//! ```
//! let input: String = String::from(
//! r#"
//! ## Greet the user
//! "Hello, World!"
//! ## Bye!
//! "#,
//! );
//!
//! let parsed: nixel::Parsed = nixel::parse(input);
//!
//! match &*parsed.expression {
//! nixel::Expression::String(string) => {
//! assert_eq!(
//! &string.span,
//! &nixel::Span {
//! start: nixel::Position { line: 3, column: 9 }.into(),
//! end: nixel::Position { line: 3, column: 24 }.into(),
//! }
//! .into()
//! );
//! assert_eq!(
//! &parsed.trivia_before(&string.span.start)[1],
//! &nixel::Trivia::Comment(nixel::TriviaComment {
//! content: "# Greet the user".into(),
//! span: nixel::Span {
//! start: nixel::Position { line: 2, column: 9 }.into(),
//! end: nixel::Position { line: 2, column: 25 }.into(),
//! }
//! .into()
//! })
//! );
//! assert_eq!(
//! &string.parts[0],
//! &nixel::Part::Raw(nixel::PartRaw {
//! content: "Hello, World!".into(),
//! span: nixel::Span {
//! start: nixel::Position { line: 3, column: 10 }.into(),
//! end: nixel::Position { line: 3, column: 23 }.into(),
//! }
//! .into()
//! })
//! );
//! assert_eq!(
//! &parsed.trivia_after(&string.span.end)[1],
//! &nixel::Trivia::Comment(nixel::TriviaComment {
//! content: "# Bye!".into(),
//! span: nixel::Span {
//! start: nixel::Position { line: 4, column: 9 }.into(),
//! end: nixel::Position { line: 4, column: 15 }.into(),
//! }
//! .into()
//! })
//! );
//! },
//! expression => unreachable!("Expected a String, got: {expression:#?}"),
//! }
//! ```
//!
//! Source code can be found at
//! [github.com/kamadorueda/nixel](https://github.com/kamadorueda/nixel).
pub
pub
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;