Structures de base pour l'AST

This commit is contained in:
2024-04-29 08:36:53 +02:00
parent 5d5928d4ef
commit 0103749edd
2 changed files with 32 additions and 1 deletions

30
src/expr.rs Normal file
View File

@@ -0,0 +1,30 @@
use crate::token::Token;
pub struct Binary {
left: Expr,
operator: Token,
right: Expr,
}
pub struct Grouping {
expression: Expr,
}
pub enum Literal {
LiteralNumber(i8),
LiteralString(String),
LiteralBool(bool),
LiteralNil,
}
pub struct Unary {
operator: Token,
right: Expr,
}
pub enum Expr {
Binary ,
Grouping,
Literal,
Unary,
}

View File

@@ -6,6 +6,7 @@ mod rlox_interpreter;
mod scanner;
mod token;
mod token_type;
mod expr;
use crate::rlox_interpreter::RLoxInterpreter;
@@ -34,4 +35,4 @@ fn main() {
// https://github.com/munificent/craftinginterpreters/wiki/Lox-implementations#rust
// Pause :
// http://www.craftinginterpreters.com/scanning.html#lexical-errors
// http://www.craftinginterpreters.com/representing-code.html#working-with-trees