conlang: Self is not a type, it's a path to a type

This commit is contained in:
2024-07-17 15:05:52 -05:00
parent ded100bf71
commit b3d62c09aa
11 changed files with 25 additions and 20 deletions

View File

@@ -672,10 +672,6 @@ impl<'t> Parser<'t> {
self.consume_peeked();
TyKind::Never
}
TokenKind::SelfTy => {
self.consume_peeked();
TyKind::SelfTy
}
TokenKind::Punct(Punct::Amp) | TokenKind::Punct(Punct::AmpAmp) => self.tyref()?.into(),
TokenKind::Punct(Punct::LParen) => {
let out = self.tytuple()?;
@@ -751,6 +747,7 @@ macro literal_like() {
macro path_like() {
TokenKind::Super
| TokenKind::SelfKw
| TokenKind::SelfTy
| TokenKind::Identifier
| TokenKind::Punct(Punct::ColonColon)
}
@@ -762,6 +759,7 @@ impl<'t> Parser<'t> {
let out = match self.peek_kind(PARSING)? {
TokenKind::Super => PathPart::SuperKw,
TokenKind::SelfKw => PathPart::SelfKw,
TokenKind::SelfTy => PathPart::SelfTy,
TokenKind::Identifier => PathPart::Ident(self.identifier()?),
t => return Err(self.error(Unexpected(t), PARSING)),
};