1#[derive(Debug, Copy, Clone)]
7pub enum Scope {
8 A(bool), O(bool), }
11
12#[derive(Debug, Clone)]
13pub struct Stack(Vec<Scope>);
14
15impl Stack {
16 pub fn new() -> Stack {
17 Stack(Vec::new())
18 }
19
20 pub fn push(&mut self, s: Scope) {
21 self.0.push(s)
22 }
23
24 pub fn pop(&mut self) -> Option<Scope> {
25 self.0.pop()
26 }
27
28 pub fn top(&self) -> Option<Scope> {
29 self.0.last().map(|x| *x)
30 }
31
32 pub fn set(&mut self) {
33 self.0.last_mut().map(|x| match *x {
34 Scope::A(_) => *x = Scope::A(true),
35 Scope::O(_) => *x = Scope::O(true),
36 });
37 }
38}