...
This commit is contained in:
@@ -23,12 +23,12 @@ public interface IFuncSignature
|
||||
if (Name != name) return false;
|
||||
if (Parameters.Count == 0 && parameters.Count == 0) return true;
|
||||
if (Parameters.Count > parameters.Count) return false;
|
||||
|
||||
|
||||
for (var i = 0; i < parameters.Count; i++)
|
||||
{
|
||||
if (i > Parameters.Count)
|
||||
if (i >= Parameters.Count)
|
||||
{
|
||||
if (Parameters[^1].Variadic)
|
||||
if (Parameters.Count > 0 && Parameters[^1].Variadic)
|
||||
{
|
||||
if (!NubType.IsCompatibleWith(parameters[i], Parameters[^1].Type))
|
||||
{
|
||||
@@ -45,7 +45,7 @@ public interface IFuncSignature
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -249,109 +249,6 @@ public class Parser
|
||||
return new StatementExpressionNode(GetTokensForNode(startIndex), expr);
|
||||
}
|
||||
|
||||
// private StatementNode ParseStatementIdentifier(int startIndex)
|
||||
// {
|
||||
// var leftExpr = ParsePrimaryExpression();
|
||||
//
|
||||
// var symbol = ExpectSymbol();
|
||||
//
|
||||
// switch (symbol.Symbol)
|
||||
// {
|
||||
// case Symbol.DoubleColon:
|
||||
// {
|
||||
// if (leftExpr is not IdentifierNode namespaceNode)
|
||||
// {
|
||||
// throw new ParseException(Diagnostic
|
||||
// .Error("Invalid syntax before '::'")
|
||||
// .WithHelp("Only identifiers can be used before '::' for namespace resolution")
|
||||
// .At(symbol)
|
||||
// .Build());
|
||||
// }
|
||||
//
|
||||
// var name = ExpectIdentifier();
|
||||
// ExpectSymbol(Symbol.OpenParen);
|
||||
// var parameters = new List<ExpressionNode>();
|
||||
// while (!TryExpectSymbol(Symbol.CloseParen))
|
||||
// {
|
||||
// parameters.Add(ParseExpression());
|
||||
// if (!TryExpectSymbol(Symbol.Comma) && Peek().TryGetValue(out var nextToken) && nextToken is not SymbolToken { Symbol: Symbol.CloseParen })
|
||||
// {
|
||||
// _diagnostics.Add(Diagnostic
|
||||
// .Warning("Missing comma between function arguments")
|
||||
// .WithHelp("Add a ',' to separate arguments")
|
||||
// .At(nextToken)
|
||||
// .Build());
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return new FuncCallStatementNode(GetTokensForNode(startIndex), new FuncCall(namespaceNode.Identifier, name.Value, parameters));
|
||||
// }
|
||||
// case Symbol.OpenParen:
|
||||
// {
|
||||
// if (leftExpr is not IdentifierNode funcNode)
|
||||
// {
|
||||
// throw new ParseException(Diagnostic
|
||||
// .Error("Invalid syntax before '('")
|
||||
// .WithHelp("Only identifiers can be called as functions")
|
||||
// .At(symbol)
|
||||
// .Build());
|
||||
// }
|
||||
//
|
||||
// var parameters = new List<ExpressionNode>();
|
||||
// while (!TryExpectSymbol(Symbol.CloseParen))
|
||||
// {
|
||||
// parameters.Add(ParseExpression());
|
||||
// if (!TryExpectSymbol(Symbol.Comma) && Peek().TryGetValue(out var nextToken) && nextToken is not SymbolToken { Symbol: Symbol.CloseParen })
|
||||
// {
|
||||
// _diagnostics.Add(Diagnostic
|
||||
// .Warning("Missing comma between function arguments")
|
||||
// .WithHelp("Add a ',' to separate arguments")
|
||||
// .At(nextToken)
|
||||
// .Build());
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return new FuncCallStatementNode(GetTokensForNode(startIndex), new FuncCall(_namespace, funcNode.Identifier, parameters));
|
||||
// }
|
||||
// case Symbol.Assign:
|
||||
// {
|
||||
// var value = ParseExpression();
|
||||
//
|
||||
// switch (leftExpr)
|
||||
// {
|
||||
// case IdentifierNode identifierNode:
|
||||
// {
|
||||
// return new VariableAssignmentNode(GetTokensForNode(startIndex), identifierNode.Identifier, value);
|
||||
// }
|
||||
// case ArrayIndexNode arrayIndexNode:
|
||||
// {
|
||||
// return new ArrayIndexAssignmentNode(GetTokensForNode(startIndex), arrayIndexNode.Expression, arrayIndexNode.Index, value);
|
||||
// }
|
||||
// case MemberAccessNode memberAccessNode:
|
||||
// {
|
||||
// return new MemberAssignmentNode(GetTokensForNode(startIndex), memberAccessNode.Expression, memberAccessNode.Member, value);
|
||||
// }
|
||||
// default:
|
||||
// {
|
||||
// throw new ParseException(Diagnostic
|
||||
// .Error("Invalid left-hand side in assignment")
|
||||
// .WithHelp("Left side must be a variable, array element, or struct member")
|
||||
// .At(symbol)
|
||||
// .Build());
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// default:
|
||||
// {
|
||||
// throw new ParseException(Diagnostic
|
||||
// .Error($"Unexpected symbol '{symbol.Symbol}' after identifier")
|
||||
// .WithHelp("Expected '(', '=', or '::' after identifier")
|
||||
// .At(symbol)
|
||||
// .Build());
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
private VariableDeclarationNode ParseVariableDeclaration(int startIndex)
|
||||
{
|
||||
ExpectSymbol(Symbol.Let);
|
||||
|
||||
Reference in New Issue
Block a user