Mise en place formelle du visiteur et séparation de l'affichage d'un arbre syntaxique abstrait (AST).
This commit is contained in:
12
src/main.rs
12
src/main.rs
@@ -1,17 +1,20 @@
|
||||
use std::env;
|
||||
use std::process;
|
||||
use crate::expr::{Binary, Expr, Grouping, Literal, Unary, Visitable};
|
||||
use crate::expr::Expr::LiteralExpr;
|
||||
|
||||
mod rlox_interpreter;
|
||||
|
||||
mod scanner;
|
||||
mod token;
|
||||
mod token_type;
|
||||
mod expr;
|
||||
mod astprinter;
|
||||
|
||||
use crate::rlox_interpreter::RLoxInterpreter;
|
||||
use crate::token::Token;
|
||||
use crate::token_type::TokenType;
|
||||
use crate::expr::{Binary, Expr, Grouping, Literal, Unary, VisitableExpr};
|
||||
use crate::expr::Expr::LiteralExpr;
|
||||
use crate::astprinter::ASTPrinter;
|
||||
|
||||
// Exit codes from #include <sysexits.h>
|
||||
const EX_OK: i32 = 0;
|
||||
@@ -44,7 +47,7 @@ fn essai_visitor() {
|
||||
line: 0,
|
||||
literal: String::from("-")
|
||||
},
|
||||
right: Box::new(Expr::LiteralExpr(Literal::LiteralNumber(123.0)))
|
||||
right: Box::new(Expr::LiteralExpr(Literal::LiteralNumber(456.0)))
|
||||
})),
|
||||
operator: Token {
|
||||
token_type: TokenType::Star,
|
||||
@@ -57,7 +60,8 @@ fn essai_visitor() {
|
||||
}))
|
||||
});
|
||||
|
||||
expression.visit();
|
||||
let a = ASTPrinter{};
|
||||
expression.accept(&a);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user