diff --git a/trunk_parser/src/parser/ident.rs b/trunk_parser/src/parser/ident.rs index b18b8f0..1bfb807 100644 --- a/trunk_parser/src/parser/ident.rs +++ b/trunk_parser/src/parser/ident.rs @@ -22,6 +22,17 @@ impl Parser { Ok(expect!(self, TokenKind::Variable(v), v, "expected variable name")) } + pub(crate) fn full_name_maybe_type_keyword(&mut self) -> ParseResult { + match self.current.kind { + TokenKind::Array | TokenKind::Callable => { + let r = Ok(self.current.kind.to_string()); + self.next(); + r + }, + _ => self.full_name() + } + } + pub(crate) fn ident_maybe_reserved(&mut self) -> ParseResult { match self.current.kind { TokenKind::Static | TokenKind::Abstract | TokenKind::Final | TokenKind::For | diff --git a/trunk_parser/src/parser/mod.rs b/trunk_parser/src/parser/mod.rs index 0f67a48..34e7965 100644 --- a/trunk_parser/src/parser/mod.rs +++ b/trunk_parser/src/parser/mod.rs @@ -89,11 +89,11 @@ impl Parser { fn type_string(&mut self) -> ParseResult { if self.current.kind == TokenKind::Question { self.next(); - let t = self.full_name()?; + let t = self.full_name_maybe_type_keyword()?; return Ok(Type::Nullable(t)); } - let id = self.full_name()?; + let id = self.full_name_maybe_type_keyword()?; if self.current.kind == TokenKind::Pipe { self.next(); @@ -101,7 +101,7 @@ impl Parser { let mut types = vec![id]; while ! self.is_eof() { - let id = self.full_name()?; + let id = self.full_name_maybe_type_keyword()?; types.push(id); if self.current.kind != TokenKind::Pipe { @@ -118,7 +118,7 @@ impl Parser { let mut types = vec![id]; while ! self.is_eof() { - let id = self.full_name()?; + let id = self.full_name_maybe_type_keyword()?; types.push(id); if self.current.kind != TokenKind::Ampersand {