use std::{cell::RefCell, ops::Range, rc::Rc};
#[derive(Debug)]
pub enum AstNode {
Dummy,
Compound(Vec<Rc<RefCell<Ast>>>),
Stat(String),
Continue(String),
Break(String),
Return(String),
If {
cond: String,
body: Rc<RefCell<Ast>>,
otherwise: Option<Rc<RefCell<Ast>>>,
},
While {
cond: String,
body: Rc<RefCell<Ast>>,
},
DoWhile {
cond: String,
body: Rc<RefCell<Ast>>,
},
For {
init: String,
cond: String,
upd: String,
body: Rc<RefCell<Ast>>,
},
Switch {
cond: String,
cases: Vec<String>,
body: Rc<RefCell<Ast>>,
},
Goto(String),
}
#[derive(Debug)]
pub struct Ast {
pub node: AstNode,
pub range: Range<usize>,
pub label: Option<Vec<String>>,
}
impl Ast {
pub fn new(node: AstNode, range: Range<usize>, label: Option<Vec<String>>) -> Ast {
Ast { node, range, label }
}
}