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
use super::CompileResult;
use super::SymTable;
use std::fmt;
#[cfg_attr(feature = "unstable",
stable(feature = "ast", since = "0.0.2") )]
pub const INDENT: &'static str = "\t";
#[cfg_attr(feature = "unstable",
stable(feature = "ast", since = "0.0.1") )]
pub trait ASTNode {
#[cfg_attr(feature = "unstable",
stable(feature = "compile", since = "0.0.1") )]
fn compile<'a>(&'a self,
state: &'a SymTable<'a>)
-> CompileResult;
#[cfg_attr(feature = "unstable",
stable(feature = "ast", since = "0.0.1") )]
fn prettyprint(&self) -> String {
self.print_level(0)
}
#[cfg_attr(feature = "unstable",
stable(feature = "ast", since = "0.0.1") )]
fn print_level(&self, level: usize) -> String;
}
#[cfg_attr(feature = "unstable",
stable(feature = "ast", since = "0.0.1") )]
impl fmt::Debug for ASTNode {
#[cfg_attr(feature = "unstable",
stable(feature = "ast", since = "0.0.1") )]
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.prettyprint())
}
}