Example #1
0
        private DataSet GetAvailableTokens(string checkString)
        {
            if (string.IsNullOrEmpty(checkString))
            {
                return(new DataSet(""));
            }

            return(m_Current.Filter((x) => TokenValidationPredicates.Potential(x, checkString)));
        }
Example #2
0
        private DataSet GetFinalTokens(string checkString)
        {
            if (string.IsNullOrEmpty(checkString))
            {
                return(new DataSet(""));
            }

            return(m_Previous.Filter((x) => TokenValidationPredicates.Final(x, checkString)));
        }
Example #3
0
        private Token FindNextTokenOf(string searchType, Token lastToken)
        {
            string lastType  = lastToken.Type;
            string lastValue = lastToken.Value;

            m_Tokens.RemoveAt(m_Tokens.Count - 1);
            int startline  = m_Line;
            int startIndex = m_Index - lastValue.Length;

            bool Reading = false;

            DataContainer searchData = m_Config.Tokens.All.GetSet(searchType);

            for (; m_Index < m_Code.Length; m_Index++)
            {
                if (m_Code[m_Index] == '\n')
                {
                    if (++m_Line % 5000 == 0)
                    {
                        Debug.Log("Status: Line " + m_Line);
                    }
                }


                m_Buffer.Append(m_Code[m_Index]);

                bool HasPotential = TokenValidationPredicates.Potential(searchData, m_Buffer.ToString());
                if (HasPotential)
                {
                    Reading = true;
                    continue;
                }
                else if (Reading)
                {
                    m_Buffer.Remove(m_Buffer.Length - 1, 1);

                    bool isFinal = TokenValidationPredicates.Final(searchData, m_Buffer.ToString());

                    if (isFinal)
                    {
                        int length = m_Index - startIndex;
                        m_SearchFlag = "";
                        m_Buffer.Clear();
                        return(new Token(lastType, m_Code.Substring(startIndex, length), m_Line));
                    }

                    m_Buffer.Clear();
                    Reading = false;
                }
                else if (!HasPotential)
                {
                    m_Buffer.Clear();
                }
            }

            throw new Exception("Tried parsing until I couldn't");
        }