diff --git a/trunk_parser/src/ast.rs b/trunk_parser/src/ast.rs index d884c4d..75d8283 100644 --- a/trunk_parser/src/ast.rs +++ b/trunk_parser/src/ast.rs @@ -10,6 +10,9 @@ pub enum Type { Union(Vec), Intersection(Vec), Void, + Null, + True, + False, } #[derive(Debug, Eq, PartialEq, Clone)] diff --git a/trunk_parser/src/parser/ident.rs b/trunk_parser/src/parser/ident.rs index 0bf4d64..230422c 100644 --- a/trunk_parser/src/parser/ident.rs +++ b/trunk_parser/src/parser/ident.rs @@ -57,9 +57,10 @@ impl Parser { pub(crate) fn type_with_static(&mut self) -> ParseResult { Ok(match self.current.kind { - TokenKind::Static => { + TokenKind::Static | TokenKind::Null | TokenKind::True | TokenKind::False => { + let str = self.current.kind.to_string(); self.next(); - "static".into() + str.into() } _ => self.full_name_maybe_type_keyword()?, }) diff --git a/trunk_parser/src/parser/mod.rs b/trunk_parser/src/parser/mod.rs index 3b7e0a1..97315bc 100644 --- a/trunk_parser/src/parser/mod.rs +++ b/trunk_parser/src/parser/mod.rs @@ -163,6 +163,9 @@ impl Parser { Ok(match &id[..] { b"void" => Type::Void, + b"null" => Type::Null, + b"true" => Type::True, + b"false" => Type::False, _ => Type::Plain(id), }) } @@ -4104,6 +4107,48 @@ mod tests { assert_ast("