AST - Moved dumper trait out of the way

This commit is contained in:
Emmanuel BENOîT 2022-12-31 14:27:20 +01:00
parent a69fea5538
commit 407fbe26b0

View file

@ -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 {