diff --git a/src/schala_lang/parsing.rs b/src/schala_lang/parsing.rs index eec174a..a777a5e 100644 --- a/src/schala_lang/parsing.rs +++ b/src/schala_lang/parsing.rs @@ -450,6 +450,7 @@ pub enum Expression { IntLiteral(u64), FloatLiteral(f64), StringLiteral(Rc), + BoolLiteral(bool), BinExp(Operation, Box, Box), Variable(Rc), Call { @@ -669,6 +670,8 @@ impl Parser { parse_method!(literal(&mut self) -> ParseResult { match self.peek() { DigitGroup(_) | HexNumberSigil | BinNumberSigil | Period => self.number_literal(), + Keyword(Kw::True) => { self.next(); Ok(Expression::BoolLiteral(true)) }, + Keyword(Kw::False) => { self.next(); Ok(Expression::BoolLiteral(false)) }, StrLiteral(s) => { self.next(); Ok(Expression::StringLiteral(s)) @@ -848,6 +851,12 @@ mod parse_tests { })])); } + #[test] + fn parse_bools() { + parse_test!("false", AST(vec![Expression(BoolLiteral(false))])); + parse_test!("true", AST(vec![Expression(BoolLiteral(true))])); + } + #[test] fn parsing_strings() { parse_test!(r#""hello""#, AST(vec![Expression(StringLiteral(rc!(hello)))]));