AST - Moved dumper trait out of the way
This commit is contained in:
parent
a69fea5538
commit
407fbe26b0
1 changed files with 10 additions and 6 deletions
16
src/ast.rs
16
src/ast.rs
|
@ -1,11 +1,5 @@
|
|||
use crate::tokens::Token;
|
||||
|
||||
/// This trait should be implemented by nodes to allow AST dumps.
|
||||
pub trait AstDumper {
|
||||
/// Dump the node as a string.
|
||||
fn dump(&self) -> String;
|
||||
}
|
||||
|
||||
/// An AST node that represents an expression.
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum ExprNode {
|
||||
|
@ -29,6 +23,16 @@ pub enum ExprNode {
|
|||
Litteral { value: Token },
|
||||
}
|
||||
|
||||
/* -------------------------------- *
|
||||
* Dumper trait and implementations *
|
||||
* -------------------------------- */
|
||||
|
||||
/// This trait should be implemented by nodes to allow AST dumps.
|
||||
pub trait AstDumper {
|
||||
/// Dump the node as a string.
|
||||
fn dump(&self) -> String;
|
||||
}
|
||||
|
||||
impl AstDumper for ExprNode {
|
||||
fn dump(&self) -> String {
|
||||
match self {
|
||||
|
|
Loading…
Reference in a new issue