Beispiel #1
0
        public static string getNextCharacterPartFromKeyword_startingFromNonParameter(string keyword, int startFrom)
        {
            for (int x = startFrom; x < keyword.Length; x++)
            {
                if (ZeroCodeUtil.tryStringMatch(keyword, x, "(?<"))
                {
                    return(keyword.Substring(startFrom, x - startFrom));
                }

                if (ZeroCodeUtil.tryStringMatch(keyword, x, "(*")) // needs some clever tests ideas, if this is valid????
                {
                    return(keyword.Substring(startFrom, x - startFrom));
                }
            }

            return(keyword.Substring(startFrom));

            /*
             * int firstTryPos = getNextMatch(keyword, startFrom, "(*(+");
             *
             * int secondTryPos = getNextMatch(keyword, startFrom, "(?<");
             *
             * if(firstTryPos==-1 && secondTryPos==-1)
             *  return keyword.Substring(startFrom);
             *
             * if(secondTryPos == -1)
             *  return keyword.Substring(startFrom, firstTryPos - startFrom);
             *
             * if(firstTryPos == -1)
             *  return keyword.Substring(startFrom, secondTryPos - startFrom);
             *
             * return keyword.Substring(startFrom, Math.Min(firstTryPos,secondTryPos) - startFrom);*/
        }
Beispiel #2
0
        public static string tryStringFromNewVertexString(string text, int startPos, ref int pos)
        {
            string newVertex = null;

            int sPos = startPos;

            bool shallProceed = true;

            if (ZeroCodeUtil.tryStringMatch(text, sPos, ZeroCodeCommon.NewVertexPrefix.ToString()))
            {
                while (shallProceed)
                {
                    sPos++;

                    if (text[sPos] == ZeroCodeCommon.NewVertexSuffix &&
                        sPos > 0 && text[sPos - 1] != ZeroCodeCommon.EscapeCharacter)    // if is no \"
                    {
                        shallProceed = false;
                    }
                }

                pos = sPos + 1;

                newVertex = ZeroCodeCommon.stringFromNewVertexString(text.Substring(startPos, sPos - startPos + 1));
            }

            return(newVertex);
        }
Beispiel #3
0
        public static char getFirstCharacterFromKeyword(string keyword)
        {
            if (ZeroCodeUtil.tryStringMatch(keyword, 0, "(?<"))
            {
                int pos = ZeroCodeUtil.getNextMatch(keyword, 3, ">)");

                return(keyword[pos + 2]);
            }
            else
            {
                return(keyword[0]);
            }
        }
Beispiel #4
0
        // to be used only in ZeroCodeCommon.stringFromLinkString( , FALSE) scenario
        // and that means that TO BE USED ONLY IN KEYWORDS
        public static string tryStringFromLinkString(string text, int startPos, ref int pos, int endPos)
        {
            string newVertex = null;

            int sPos = startPos;

            bool shallProceed = true;

            if (ZeroCodeUtil.tryStringMatch(text, startPos, ZeroCodeCommon.CodeGraphLinkPrefix.ToString()))
            {
                bool isInEscape = false;

                while (shallProceed)
                {
                    sPos++;

                    if (sPos == endPos)
                    {
                        shallProceed = false;
                    }

                    if (text[sPos] == '\n' || text[sPos] == '\r')
                    {
                        shallProceed = false;
                    }

                    //if (text[sPos] == ' ' && !isInEscape)
                    //  shallProceed = false;

                    if (text[sPos] == '\'' && !isInEscape)
                    {
                        isInEscape = true;
                    }

                    if (text[sPos] == '\'' && isInEscape &&
                        sPos > 0 && text[sPos - 1] != '\\')    // if is no \'
                    {
                        isInEscape = false;
                    }
                }

                pos = sPos;

                newVertex = ZeroCodeCommon.stringFromLinkString(text.Substring(startPos, sPos - startPos), false);
            }

            return(newVertex);
        }