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
//! A TOML-like configuration language parser that supports single depth arrays, integers, strings and boolean literals.
//!
//! This library isn't intended to compete with `toml`. Frostwalker and `toml` have differing goals and I would recommend you use `toml` over Frostwalker as it supports more features, but Frostwalker has no dependencies apart from the standard library.
//!
//! The use of this library is easy and doesn't require much work:
//! ```
//! use frostwalker::parse;
//!
//! let parsed_output = parse("yes = true\r\nkey = \"value\"\r\narray = [ 1, 5 ]");
//! let hashmap = parsed_output.unwrap();
//! assert_eq!(hashmap.get("yes").unwrap(), "true");
//!
//! assert_eq!(hashmap.get("key").unwrap(), "value");
//!
//! assert_eq!(hashmap.get("array").unwrap(), "2");
//! assert_eq!(hashmap.get("array[0]").unwrap(), "1");
//! assert_eq!(hashmap.get("array[1]").unwrap(), "5");
//! ```
//!
use HashMap;
/// A structure for a lexical token.
///
/// It is used by all components of the parser stack and is here as to keep each component separate from the others.
/// An enumerator for types of lexical tokens.
///
/// It is used by all components of the parser stack and is here as to keep each component separate from the others.
/// The parsing function. This function takes in a string with configuration in it and either outputs a HashMap containing keys and values or an error message.
///
/// The parser wraps around each function of the parser stack (lexer, validator, and formatter) as to ensure the configuration text is parsed properly. Errors originate from the validator.