Esempio n. 1
0
 public ExpressionItemTransform(int offset, int length, ExpressionItemNode target, ExpressionNode transform, ExpressionNode separator)
     : base(offset, length)
 {
     Target = target;
     target.SetParent(this);
     Transform = transform;
     transform.SetParent(this);
     Separator = separator;
     separator?.SetParent(this);
 }
Esempio n. 2
0
 public ExpressionItemFunctionInvocation(int offset, int length, ExpressionItemNode target, ExpressionFunctionName methodName, ExpressionArgumentList arguments)
     : base(offset, length)
 {
     Target = target;
     target.SetParent(this);
     Function = methodName;
     methodName?.SetParent(this);
     Arguments = arguments;
     arguments?.SetParent(this);
 }
Esempio n. 3
0
        static ExpressionNode ParseItemFunction(string buffer, ref int offset, int endOffset, int baseOffset, ExpressionItemNode target)
        {
            int nameOffset  = offset;
            var funcNameStr = ReadName(buffer, ref offset, endOffset);

            if (funcNameStr == null)
            {
                return(new IncompleteExpressionError(
                           baseOffset + offset,
                           offset > endOffset,
                           ExpressionErrorKind.ExpectingMethodName,
                           new ExpressionItemFunctionInvocation(target.Offset, (offset + baseOffset) - target.Offset, target, null, null)));
            }
            var funcName = new ExpressionFunctionName(nameOffset + baseOffset, funcNameStr);

            ConsumeSpace(buffer, ref offset, endOffset);

            if (offset > endOffset || buffer [offset] != '(')
            {
                return(new IncompleteExpressionError(
                           baseOffset + offset,
                           offset > endOffset,
                           ExpressionErrorKind.ExpectingLeftParen,
                           new ExpressionItemFunctionInvocation(target.Offset, (offset + baseOffset) - target.Offset, target, funcName, null)
                           ));
            }

            if (WrapError(
                    ParseFunctionArgumentList(buffer, ref offset, endOffset, baseOffset),
                    out ExpressionArgumentList args,
                    out IncompleteExpressionError error,
                    (n, o) => new ExpressionItemFunctionInvocation(target.Offset, o - target.Offset, target, funcName, n)
                    ))
            {
                return(error);
            }

            return(new ExpressionItemFunctionInvocation(target.Offset, (offset + baseOffset) - target.Offset, target, funcName, args));
        }
Esempio n. 4
0
 public ExpressionItem(int offset, int length, ExpressionItemNode expression) : base(offset, length)
 {
     Expression = expression;
     expression.SetParent(this);
 }
Esempio n. 5
0
        static ExpressionNode ParseItemTransform(string buffer, ref int offset, int endOffset, int baseOffset, ExpressionItemNode target)
        {
            char terminator = buffer [offset];

            if (WrapError(
                    ReadArgumentString(terminator, buffer, ref offset, endOffset, baseOffset),
                    out ExpressionNode expr,
                    out IncompleteExpressionError err,
                    (n, o) => new ExpressionItemTransform(target.Offset, o - target.Offset + baseOffset, target, n, null)
                    ))
            {
                return(err);
            }

            int preSpaceOffset = offset;

            ConsumeSpace(buffer, ref offset, endOffset);

            if (offset > endOffset || buffer [offset] != ',')
            {
                return(new ExpressionItemTransform(target.Offset, preSpaceOffset - target.Offset + baseOffset, target, expr, null));
            }
            offset++;

            ConsumeSpace(buffer, ref offset, endOffset);

            bool foundCustomSeparator = false;

            if (offset <= endOffset)
            {
                terminator = buffer [offset];
                if (terminator == '\'' || terminator == '"' || terminator == '`')
                {
                    foundCustomSeparator = true;
                }
            }

            if (!foundCustomSeparator)
            {
                return(new IncompleteExpressionError(
                           offset,
                           offset > endOffset,
                           ExpressionErrorKind.ExpectingValue,
                           new ExpressionItemTransform(target.Offset, preSpaceOffset - target.Offset + baseOffset, target, expr, null)
                           ));
            }

            if (WrapError(
                    ReadArgumentString(terminator, buffer, ref offset, endOffset, baseOffset),
                    out ExpressionNode sepExpr,
                    out err,
                    (n, o) => new ExpressionItemTransform(target.Offset, o - target.Offset + baseOffset, target, expr, n)
                    ))
            {
                return(err);
            }

            return(new ExpressionItemTransform(target.Offset, offset - target.Offset + baseOffset, target, expr, sepExpr));
        }