From ea1365c77d507712c9bba3e03ee31835db7d62c6 Mon Sep 17 00:00:00 2001 From: Ryan Chandler Date: Thu, 28 Jul 2022 14:45:05 +0100 Subject: [PATCH] parser: support true/false (bool) expressions --- trunk_parser/src/ast.rs | 3 ++- trunk_parser/src/parser/mod.rs | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/trunk_parser/src/ast.rs b/trunk_parser/src/ast.rs index 559d9e5..6404dc4 100644 --- a/trunk_parser/src/ast.rs +++ b/trunk_parser/src/ast.rs @@ -269,7 +269,8 @@ pub enum Expression { ConstFetch(Box, Identifier), MethodCall(Box, Identifier, Vec), StaticMethodCall(Box, Identifier, Vec), - AnonymousClass(Option, Vec, Block) + AnonymousClass(Option, Vec, Block), + Bool(bool), } #[derive(Debug, Clone, PartialEq, Serialize)] diff --git a/trunk_parser/src/parser/mod.rs b/trunk_parser/src/parser/mod.rs index bb21f61..09c32f9 100644 --- a/trunk_parser/src/parser/mod.rs +++ b/trunk_parser/src/parser/mod.rs @@ -713,6 +713,8 @@ impl Parser { TokenKind::Int(i) => Expression::Int(*i), TokenKind::Identifier(i) => Expression::Identifier(i.to_string()), TokenKind::ConstantString(s) => Expression::ConstantString(s.to_string()), + TokenKind::True => Expression::Bool(true), + TokenKind::False => Expression::Bool(false), TokenKind::LeftParen => { self.next();