Пример #1
0
        public bool Parse(string text, int currentPosition, object state, IToken currentToken, out int newPosition, out IToken newToken, out IForwardMovingTokenizer newParser)
        {
            //if we can't find a , or ) then we kack
            var idx = text.IndexOf(",", currentPosition);

            if (idx == -1)
            {
                idx = text.IndexOf(")", currentPosition);
                if (idx == -1)
                {
                    newPosition = -1;
                    newToken    = null;
                    newParser   = null;
                    return(false);
                }

                var substring = text.Substring(currentPosition, idx - currentPosition);
                newPosition = idx + 1;
                newToken    = NaturalToken.New(substring).HasDPCTokenType(DPCTokenType.Item);
                newParser   = new ToDotParser();
                return(true);
            }
            else
            {
                var substring = text.Substring(currentPosition, idx - currentPosition);
                newPosition = idx + 1;
                newToken    = NaturalToken.New(substring).HasDPCTokenType(DPCTokenType.Item);
                newParser   = new ToCommaOrEndParenthesisParser();
                return(true);
            }
        }
Пример #2
0
        public bool Parse(string text, int currentPosition, object state, IToken currentToken, out int newPosition, out IToken newToken, out IForwardMovingTokenizer newParser)
        {
            //if we can't find a , or ) then we kack
            var idx = text.IndexOf(",", currentPosition);
            if (idx == -1)
            {
                idx = text.IndexOf(")", currentPosition);
                if (idx == -1)
                {
                    newPosition = -1;
                    newToken = null;
                    newParser = null;
                    return false;
                }

                var substring = text.Substring(currentPosition, idx - currentPosition);
                newPosition = idx + 1;
                newToken = NaturalToken.New(substring).HasDPCTokenType(DPCTokenType.Item);
                newParser = new ToDotParser();
                return true;
            }
            else
            {
                var substring = text.Substring(currentPosition, idx - currentPosition);
                newPosition = idx + 1;
                newToken = NaturalToken.New(substring).HasDPCTokenType(DPCTokenType.Item);
                newParser = new ToCommaOrEndParenthesisParser();
                return true;
            }
        }