public static Exception OperatorIsUnknown(Tok token) => throw new FunParseException(213, $"operator '{ErrorsHelper.ToText(token)}' is unknown", token.Interval);
public static Exception ArrayInitializeStepMissed(Tok openBracket, Tok lastToken, Tok missedVal) { int start = openBracket.Start; int finish = lastToken.Finish; if (string.IsNullOrWhiteSpace(missedVal?.Value)) { return(new FunParseException(234, $"'[x..y..???]. Array step expected but was nothing'{Nl} Example: a[1..5..2]", start, finish)); } else { return(new FunParseException(237, $"'[x..y..???]. Array step expected but was {ErrorsHelper.ToText(missedVal)}'{Nl} Example: a[1..5..2]", start, finish)); } }
public static Exception FunctionAlreadyExist(UserFunctionDefinitionSyntaxNode userFun) => new FunParseException(545, $"Function {ErrorsHelper.Signature(userFun.Id, userFun.Args)} already exist", new Interval(userFun.Head.Interval.Start, userFun.Body.Interval.Finish));
public static Exception FunctionArgumentDuplicates(UserFunctionDefinitionSyntaxNode lexFunction, TypedVarDefSyntaxNode lexFunctionArg) => new FunParseException(554, $"'Argument name '{lexFunctionArg.Id}' duplicates at {ErrorsHelper.Signature(lexFunction.Id, lexFunction.Args)} ", lexFunction.Head.Interval);
public static Exception LeftBinaryArgumentIsMissing(Tok token) => throw new FunParseException(207, $"expression is missed before '{ErrorsHelper.ToText(token)}'", token.Interval);
public static Exception RightBinaryArgumentIsMissing(ISyntaxNode leftNode, Tok @operator) => throw new FunParseException(210, $"{ErrorsHelper.ToShortText(leftNode)} {ErrorsHelper.ToText(@operator)} ???. Right expression is missed{Nl} Example: {ErrorsHelper.ToShortText(leftNode)} {ErrorsHelper.ToText(@operator)} e", leftNode.Interval.Start, @operator.Finish);
public static Exception UnaryArgumentIsMissing(Tok operatorTok) => throw new FunParseException(201, $"{ErrorsHelper.ToText(operatorTok)} ???{Nl} right expression is missed{Nl} Example: {ErrorsHelper.ToText(operatorTok)} a", operatorTok.Interval);
public static Exception InvalidArgTypeDefinition(ISyntaxNode argumentNode) => new FunParseException(509, ErrorsHelper.ToShortText(argumentNode) + " is not valid fun arg", argumentNode.Interval);
public static Exception UnknownValueAtStartOfExpression(int exprStart, Tok flowCurrent) => new FunParseException(315, $"Unexpected symbol {ErrorsHelper.ToText(flowCurrent)}. Equation, anonymous equation, function or type definition expected.", exprStart, flowCurrent.Finish);
public static Exception ExpressionBeforeTheDefinition(int exprStart, ISyntaxNode expression, Tok flowCurrent) => new FunParseException(318, $"Unexpected expression {ErrorsHelper.ToShortText(expression)} before definition. Equation, anonymous equation, function or type definition expected.", exprStart, flowCurrent.Finish);
public static Exception FunExpressionIsMissed(string funName, List <TypedVarDefSyntaxNode> arguments, Interval interval) => new FunParseException(312, $"{ErrorsHelper.Signature(funName, arguments)} = ??? . Function body is missed {Nl}Example: {ErrorsHelper.Signature(funName, arguments)} = #place your body here", interval);
public static Exception FunDefTokenIsMissed(string funName, List <TypedVarDefSyntaxNode> arguments, Tok actual) { return(new FunParseException(309, $"{ErrorsHelper.Signature(funName, arguments)} ??? . '=' def symbol is skipped but was {ErrorsHelper.ToText(actual)}{Nl}Example: {ErrorsHelper.Signature(funName, arguments)} = ...", actual.Start, actual.Finish)); }
public static Exception UnexpectedExpression(ISyntaxNode lexNode) => new FunParseException(306, $"Unexpected expression {ErrorsHelper.ToShortText(lexNode)}", lexNode.Interval);
public static Exception TypeExpectedButWas(Tok token) => new FunParseException(276, $"Expected: type, but was {ErrorsHelper.ToText(token)}", token.Interval);
public static Exception FunctionCallObrMissed(int funStart, string name, int position, ISyntaxNode pipedVal) { if (pipedVal == null) { return(new FunParseException(270, $"{name}( ???. Close bracket ')' is missed{Nl} Example: {name}()", funStart, position)); } return(new FunParseException(273, $"{ErrorsHelper.ToShortText(pipedVal)}.{name}( ???. Close bracket ')' is missed{Nl} Example: {ErrorsHelper.ToShortText(pipedVal)}.{name}() or {name}({ErrorsHelper.ToShortText(pipedVal)})", funStart, position)); }