Suppression du code de test de lafficheur d'AST et du visiteur.
This commit is contained in:
35
src/main.rs
35
src/main.rs
@@ -7,14 +7,8 @@ mod scanner;
|
|||||||
mod token;
|
mod token;
|
||||||
mod token_type;
|
mod token_type;
|
||||||
mod expr;
|
mod expr;
|
||||||
mod astprinter;
|
|
||||||
|
|
||||||
use crate::rlox_interpreter::RLoxInterpreter;
|
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>
|
// Exit codes from #include <sysexits.h>
|
||||||
const EX_OK: i32 = 0;
|
const EX_OK: i32 = 0;
|
||||||
@@ -24,8 +18,6 @@ const EX_USAGE : i32 = 66;
|
|||||||
fn main() {
|
fn main() {
|
||||||
let args: Vec<String> = env::args().collect();
|
let args: Vec<String> = env::args().collect();
|
||||||
|
|
||||||
essai_visitor();
|
|
||||||
|
|
||||||
let exit_code = match args.len() {
|
let exit_code = match args.len() {
|
||||||
1 => { RLoxInterpreter::new().run_prompt() } ,
|
1 => { RLoxInterpreter::new().run_prompt() } ,
|
||||||
2 => { RLoxInterpreter::new().run_file(&args[1]) },
|
2 => { RLoxInterpreter::new().run_file(&args[1]) },
|
||||||
@@ -38,33 +30,6 @@ fn main() {
|
|||||||
process::exit(exit_code);
|
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 :
|
// Implémentations de référence :
|
||||||
// https://github.com/munificent/craftinginterpreters/wiki/Lox-implementations#rust
|
// https://github.com/munificent/craftinginterpreters/wiki/Lox-implementations#rust
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user