-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathconst_state.rs
More file actions
39 lines (37 loc) · 1.4 KB
/
const_state.rs
File metadata and controls
39 lines (37 loc) · 1.4 KB
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
use super::{
any_state::{AnyResult, AnyState},
json_state::JsonState,
root_state::{RootState, RootStatus},
};
use crate::{mem::manager::Manager, tokenizer::JsonToken};
pub struct ConstState<M: Manager> {
pub key: String,
pub state: AnyState<M>,
}
impl<M: Manager> ConstState<M> {
pub fn parse(self, manager: M, token: JsonToken<M::Dealloc>) -> JsonState<M> {
match token {
JsonToken::Semicolon => todo!(),
_ => {
// TODO: use import_path in place of _ below to track possible errors -
// or provide an explanation on why it's not necessary.
let (any_result, _) = self.state.parse(manager, token);
match any_result {
AnyResult::Continue(state) => JsonState::ParseConst(ConstState {
key: self.key,
state,
}),
AnyResult::Success(mut success) => {
success.state.consts.insert(self.key, success.value);
JsonState::ParseRoot(RootState {
status: RootStatus::Initial,
state: success.state,
new_line: false,
})
}
AnyResult::Error(error) => JsonState::Error(error),
}
}
}
}
}