EnumAst Enum(string[] metadata, Visibility visibility) { Match(TokenKind.EnumKeyword); Token name = Match(TokenKind.Identifier); TypeAst type = new BaseTypeAst(new Token(TokenKind.Identifier, "int", 0, 0)); if (current.kind is TokenKind.Colon) { Next(); type = Type(); } Match(TokenKind.LeftBrace); List <EnumValueAst> values = new List <EnumValueAst>(); while (current.kind is not TokenKind.Eof and not TokenKind.RightBrace) { values.Add(EnumValue(name.text)); if (current.kind is not TokenKind.RightBrace) { Match(TokenKind.Comma); } } Match(TokenKind.RightBrace); return(new EnumAst(metadata, visibility, name, type, values.ToArray())); }
TypeAst Type() { Token typeBase = Match(TokenKind.Identifier); TypeAst baseType = new BaseTypeAst(typeBase); return(TypeExt(baseType)); }