Exemplo n.º 1
0
        public static Exception ExpressionListMissed(int start, int end, IList <ISyntaxNode> arguments)
        {
            var argumentsStub = ErrorsHelper.CreateArgumentsStub(arguments);

            return(new FunParseException(285, $"({argumentsStub}???) {Nl}Expression inside the brackets is missed{Nl} Example: ({argumentsStub})",
                                         start, end));
        }
Exemplo n.º 2
0
        public static Exception BracketExpressionListError(int openBracketTokenPos, TokFlow flow)
        {
            var res      = ErrorsHelper.GetExpressionListError(openBracketTokenPos, flow, TokType.Obr, TokType.Cbr);
            var list     = res.Parsed;
            var argStubs = ErrorsHelper.CreateArgumentsStub(list);

            switch (res.Type)
            {
            case ExprListErrorType.FirstElementMissed:
                return(new FunParseException(449,
                                             $"( ??? , ..) <- First element missed {Nl}Remove ',' or place element before it", res.Interval));

            case ExprListErrorType.ElementMissed:
                return(new FunParseException(452,
                                             $"({argStubs},???, ..) <- element missed {Nl}Remove ',' or place element before it",
                                             res.Interval));

            case ExprListErrorType.TotalyWrongDefinition:
                return(new FunParseException(455, "Wrong expression", res.Interval));

            case ExprListErrorType.SingleOpenBracket:
                return(new FunParseException(458,
                                             $"( <- unexpected bracket{Nl} ?",
                                             res.Interval));

            case ExprListErrorType.SepIsMissing:
                return(new FunParseException(461,
                                             $"({argStubs}, ??? , ...  <- Seems like ',' is missing{Nl} Example: ({argStubs}, myArgument, ...)",
                                             res.Interval));

            case ExprListErrorType.ArgumentIsInvalid:
                return(new FunParseException(464,
                                             $"({argStubs}, ??? , ...  <- Seems like invalid expressions{Nl} Example: ({argStubs}, myArgument, ...)",
                                             res.Interval));

            case ExprListErrorType.CloseBracketIsMissing:
                return(new FunParseException(467,
                                             $"({argStubs}, ??? <- Close bracket ')' is missing{Nl} Example:({argStubs})",
                                             res.Interval));

            case ExprListErrorType.LastArgumentIsInvalid:
                return(new FunParseException(470,
                                             $"({ErrorsHelper.CreateArgumentsStub(list.Take(list.Length-1))} ??? ) <- Seems like invalid expression{Nl} Example: ({argStubs}, myArgument, ...)",
                                             res.Interval));

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Exemplo n.º 3
0
        public static Exception ArrayInitializeByListError(int openBracketTokenPos, TokFlow flow)
        {
            var res      = ErrorsHelper.GetExpressionListError(openBracketTokenPos, flow, TokType.ArrOBr, TokType.ArrCBr);
            var list     = res.Parsed;
            var argStubs = ErrorsHelper.CreateArgumentsStub(list);

            switch (res.Type)
            {
            case ExprListErrorType.FirstElementMissed:
                return(new FunParseException(401,
                                             $"[ ??? , ..] <- First element missed {Nl}Remove ',' or place element before it", res.Interval));

            case ExprListErrorType.ElementMissed:
                return(new FunParseException(404,
                                             $"[{argStubs},???, ..] <- element missed {Nl}Remove ',' or place element before it",
                                             res.Interval));

            case ExprListErrorType.TotalyWrongDefinition:
                return(new FunParseException(407, "Wrong array definition ", res.Interval));

            case ExprListErrorType.SingleOpenBracket:
                return(new FunParseException(410,
                                             $"[ <- unexpected array symbol{Nl} Did you mean array initialization [,], slice [::] or indexing [i]?",
                                             res.Interval));

            case ExprListErrorType.SepIsMissing:
                return(new FunParseException(413,
                                             $"[{argStubs}, ??? , ...  <- Seems like ',' is missing{Nl} Example: [{argStubs}, myArgument, ...]",
                                             res.Interval));

            case ExprListErrorType.ArgumentIsInvalid:
                return(new FunParseException(416,
                                             $"[{argStubs}, ??? , ...  <- Seems like array argument is invalid{Nl} Example: [{argStubs}, myArgument, ...]",
                                             res.Interval));

            case ExprListErrorType.CloseBracketIsMissing:
                return(new FunParseException(419,
                                             $"[{argStubs} ??? <- Array close bracket ']' is missing{Nl} Example: [{argStubs}]",
                                             res.Interval));

            case ExprListErrorType.LastArgumentIsInvalid:
                return(new FunParseException(422,
                                             $"[{ErrorsHelper.CreateArgumentsStub(list.Take(list.Length-1))} ??? ] <- Seems like array argument is invalid{Nl} Example: [{argStubs}, myArgument, ...]",
                                             res.Interval));

            default:
                throw new ArgumentOutOfRangeException();
            }
        }