Remove interfaces
This commit is contained in:
@@ -84,14 +84,13 @@ public sealed class Parser
|
||||
}
|
||||
|
||||
var keyword = ExpectSymbol();
|
||||
var definition = keyword.Symbol switch
|
||||
DefinitionSyntax definition = keyword.Symbol switch
|
||||
{
|
||||
Symbol.Func => ParseFunc(startIndex, exported, null),
|
||||
Symbol.Struct => ParseStruct(startIndex, exported),
|
||||
Symbol.Interface => ParseInterface(startIndex, exported),
|
||||
_ => throw new ParseException(Diagnostic
|
||||
.Error($"Expected 'func', 'struct' or 'interface' but found '{keyword.Symbol}'")
|
||||
.WithHelp("Valid definition keywords are 'func', 'struct' and 'interface'")
|
||||
.Error($"Expected 'func' or 'struct' but found '{keyword.Symbol}'")
|
||||
.WithHelp("Valid definition keywords are 'func' and 'struct'")
|
||||
.At(keyword)
|
||||
.Build())
|
||||
};
|
||||
@@ -103,7 +102,7 @@ public sealed class Parser
|
||||
_diagnostics.Add(e.Diagnostic);
|
||||
while (HasToken)
|
||||
{
|
||||
if (CurrentToken is SymbolToken { Symbol: Symbol.Extern or Symbol.Func or Symbol.Struct or Symbol.Interface })
|
||||
if (CurrentToken is SymbolToken { Symbol: Symbol.Extern or Symbol.Func or Symbol.Struct })
|
||||
{
|
||||
break;
|
||||
}
|
||||
@@ -164,19 +163,9 @@ public sealed class Parser
|
||||
return new FuncSyntax(GetTokens(startIndex), name.Value, exported, externSymbol, signature, body);
|
||||
}
|
||||
|
||||
private DefinitionSyntax ParseStruct(int startIndex, bool exported)
|
||||
private StructSyntax ParseStruct(int startIndex, bool exported)
|
||||
{
|
||||
var name = ExpectIdentifier();
|
||||
var interfaceImplementations = new List<TypeSyntax>();
|
||||
|
||||
if (TryExpectSymbol(Symbol.Colon))
|
||||
{
|
||||
do
|
||||
{
|
||||
var interfaceType = ParseType();
|
||||
interfaceImplementations.Add(interfaceType);
|
||||
} while (TryExpectSymbol(Symbol.Comma));
|
||||
}
|
||||
|
||||
ExpectSymbol(Symbol.OpenBrace);
|
||||
|
||||
@@ -212,30 +201,7 @@ public sealed class Parser
|
||||
}
|
||||
}
|
||||
|
||||
return new StructSyntax(GetTokens(startIndex), name.Value, exported, fields, funcs, interfaceImplementations);
|
||||
}
|
||||
|
||||
private InterfaceSyntax ParseInterface(int startIndex, bool exported)
|
||||
{
|
||||
var name = ExpectIdentifier();
|
||||
|
||||
ExpectSymbol(Symbol.OpenBrace);
|
||||
|
||||
List<InterfaceFuncSyntax> functions = [];
|
||||
|
||||
while (!TryExpectSymbol(Symbol.CloseBrace))
|
||||
{
|
||||
var funcStartIndex = _tokenIndex;
|
||||
|
||||
ExpectSymbol(Symbol.Func);
|
||||
|
||||
var funcName = ExpectIdentifier().Value;
|
||||
var signature = ParseFuncSignature();
|
||||
|
||||
functions.Add(new InterfaceFuncSyntax(GetTokens(funcStartIndex), funcName, signature));
|
||||
}
|
||||
|
||||
return new InterfaceSyntax(GetTokens(startIndex), name.Value, exported, functions);
|
||||
return new StructSyntax(GetTokens(startIndex), name.Value, exported, fields, funcs);
|
||||
}
|
||||
|
||||
private StatementSyntax ParseStatement()
|
||||
|
||||
Reference in New Issue
Block a user