about summary refs log tree commit diff
path: root/users/tazjin/rlox/src/parser.rs
diff options
context:
space:
mode:
authorVincent Ambo <mail@tazj.in>2020-12-19T12·01+0100
committertazjin <mail@tazj.in>2020-12-20T16·25+0000
commitbc6775c318206e1bda5e40b5a2e2411f910ad336 (patch)
tree7334ad39d09cb26fee6475ef9602aabefad03562 /users/tazjin/rlox/src/parser.rs
parente115e58f9c96ba4acff7e21021333b48b73f4a9f (diff)
feat(tazjin/rlox): Implement tree-walk interpreter of exprs r/2018
This is only a subset of the Lox spec so far. It implements the
language up to the runtime error chapter on
https://craftinginterpreters.com/evaluating-expressions.html

Change-Id: I295dbf4b6544420d6fe80b6aaba661fb21acdea6
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2281
Reviewed-by: tazjin <mail@tazj.in>
Tested-by: BuildkiteCI
Diffstat (limited to 'users/tazjin/rlox/src/parser.rs')
-rw-r--r--users/tazjin/rlox/src/parser.rs14
1 files changed, 7 insertions, 7 deletions
diff --git a/users/tazjin/rlox/src/parser.rs b/users/tazjin/rlox/src/parser.rs
index 0d5f72fe4dc9..611a99f01c22 100644
--- a/users/tazjin/rlox/src/parser.rs
+++ b/users/tazjin/rlox/src/parser.rs
@@ -12,15 +12,15 @@ use crate::scanner::{Token, TokenKind};
 
 #[derive(Debug)]
 pub struct Binary<'a> {
-    left: Box<Expr<'a>>,
-    operator: Token<'a>,
-    right: Box<Expr<'a>>,
+    pub left: Box<Expr<'a>>,
+    pub operator: Token<'a>,
+    pub right: Box<Expr<'a>>,
 }
 
 #[derive(Debug)]
-pub struct Grouping<'a>(Box<Expr<'a>>);
+pub struct Grouping<'a>(pub Box<Expr<'a>>);
 
-#[derive(Debug)]
+#[derive(Debug, Clone, PartialEq)]
 pub enum Literal {
     Boolean(bool),
     Number(f64),
@@ -30,8 +30,8 @@ pub enum Literal {
 
 #[derive(Debug)]
 pub struct Unary<'a> {
-    operator: Token<'a>,
-    right: Box<Expr<'a>>,
+    pub operator: Token<'a>,
+    pub right: Box<Expr<'a>>,
 }
 
 #[derive(Debug)]