diff --git a/src/expr.rs b/src/expr.rs new file mode 100644 index 0000000..47143b9 --- /dev/null +++ b/src/expr.rs @@ -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, +} diff --git a/src/main.rs b/src/main.rs index e5843a4..398de11 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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