Suppression du code de test de lafficheur d'AST et du visiteur.

This commit is contained in:
2024-05-03 08:04:49 +02:00
parent 6e12be2d36
commit 72ef4e3bbf

View File

@@ -7,14 +7,8 @@ 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;
@@ -24,8 +18,6 @@ const EX_USAGE : i32 = 66;
fn main() {
let args: Vec<String> = env::args().collect();
essai_visitor();
let exit_code = match args.len() {
1 => { RLoxInterpreter::new().run_prompt() } ,
2 => { RLoxInterpreter::new().run_file(&args[1]) },
@@ -38,33 +30,6 @@ fn main() {
process::exit(exit_code);
}
fn essai_visitor() {
let expression = Expr::BinaryExpr(Binary {
left: Box::new(Expr::UnaryExpr( Unary {
operator: Token {
token_type: TokenType::Minus,
lexeme: String::from("-"),
line: 0,
literal: String::from("-")
},
right: Box::new(Expr::LiteralExpr(Literal::LiteralNumber(456.0)))
})),
operator: Token {
token_type: TokenType::Star,
lexeme: String::from("*"),
line: 0,
literal: String::from("*")
},
right: Box::new(Expr::GroupingExpr ( Grouping {
expression: Box::new(LiteralExpr(Literal::LiteralNumber(123.0)))
}))
});
let a = ASTPrinter{};
expression.accept(&a);
}
// Implémentations de référence :
// https://github.com/munificent/craftinginterpreters/wiki/Lox-implementations#rust