Пример #1
0
 public MemoryCompiler(Map <String, String> _files, StringList _refAssemblies)
 {
     files         = _files;
     refAssemblies = _refAssemblies;
 }
Пример #2
0
        public static String format(String _pattern, char _sep, Map <String, String> _map)
        {
            int           length_     = _pattern.Length;
            StringBuilder strBuilder_ = new StringBuilder();
            int           i_          = List.FIRST_INDEX;
            StringList    keys_       = new StringList(_map.getKeys());
            bool          quoted_     = false;

            while (i_ < length_)
            {
                if (quoted_)
                {
                    if (_pattern.ElementAt(i_) != _sep)
                    {
                        strBuilder_.Append(_pattern.ElementAt(i_));
                        i_++;
                        continue;
                    }
                    quoted_ = false;
                    i_++;
                    continue;
                }
                int nbSeqQuotes_ = SIZE_EMPTY;
                while (true)
                {
                    if (i_ >= length_)
                    {
                        break;
                    }
                    if (_pattern.ElementAt(i_) != _sep)
                    {
                        break;
                    }
                    nbSeqQuotes_++;
                    i_++;
                }
                quoted_ = nbSeqQuotes_ % 2 == 1;
                int nbAdds_ = nbSeqQuotes_ / 2;
                for (int i = SIZE_EMPTY; i < nbAdds_; i++)
                {
                    strBuilder_.Append(_sep);
                }
                if (quoted_)
                {
                    continue;
                }
                int        j_    = List.FIRST_INDEX;
                StringList list_ = keys_;
                while (true)
                {
                    StringList nexList_ = new StringList();
                    foreach (String k in list_)
                    {
                        if (k.Length <= j_)
                        {
                            continue;
                        }
                        if (k.ElementAt(j_) == _pattern.ElementAt(j_ + i_))
                        {
                            nexList_.Add(k);
                        }
                    }
                    list_ = nexList_;
                    String subString_ = _pattern.Substring(i_, j_ + 1);
                    if (list_.containsObj(subString_))
                    {
                        strBuilder_.Append(_map.getVal(subString_));
                        i_ += j_;
                        break;
                    }
                    if (list_.isEmpty())
                    {
                        strBuilder_.Append(subString_);
                        i_ += j_;
                        break;
                    }
                    j_++;
                }
                i_++;
            }
            return(strBuilder_.ToString());
        }
Пример #3
0
        public static bool match(String _string, String _filter)
        {
            if (_filter.isEmpty())
            {
                return(true);
            }
            Pair <Pair <StringList, StringList>, Pair <Boolean, Boolean> > wordsAndSeparators_
                = wordsAndSeparators(_filter);

            Console.WriteLine(wordsAndSeparators_);
            StringList words_      = wordsAndSeparators_.getFirst().getSecond();
            StringList separators_ = wordsAndSeparators_.getFirst().getFirst();
            String     lastSep_;
            int        nbPts_     = SIZE_EMPTY;
            int        nbZeroOne_ = SIZE_EMPTY;
            int        index_     = FIRST_INDEX;

            if (words_.isEmpty())
            {
                lastSep_   = separators_.last();
                nbPts_     = 0;
                nbZeroOne_ = 0;
                index_     = FIRST_INDEX;
                foreach (char c in lastSep_.ToCharArray())
                {
                    if (c == CHARACTER)
                    {
                        nbPts_++;
                    }
                    if (c == POSSIBLE_CHAR)
                    {
                        nbZeroOne_++;
                    }
                }
                index_ += nbPts_;
                if (index_ == _string.Count())
                {
                    return(true);
                }
                if (index_ < _string.Count())
                {
                    if (lastSep_.Contains(char.ToString(STRING)))
                    {
                        return(true);
                    }
                    if (_string.Count() <= index_ + nbZeroOne_)
                    {
                        return(true);
                    }
                }
                return(false);
            }
            if (wordsAndSeparators_.getSecond().getFirst())
            {
                separators_.Insert(FIRST_INDEX, EMPTY_STRING);
            }
            //BEGIN MODIF

            /*if (separators_.isEmpty())
             * {
             *  if (wordsAndSeparators_.getSecond().getSecond())
             *  {
             *      separators_.Add(EMPTY_STRING);
             *  }
             * }*/
            //END MODIF
            if (wordsAndSeparators_.getSecond().getSecond())
            {
                separators_.Add(EMPTY_STRING);
            }
            int i_ = FIRST_INDEX;

            index_ = FIRST_INDEX;
            int indiceRDecalePt_ = 0;
            int indiceNext_      = 0;

            foreach (String e in words_)
            {
                String sep_ = separators_.get(i_);
                nbPts_     = 0;
                nbZeroOne_ = 0;
                foreach (char c in sep_.ToCharArray())
                {
                    if (c == CHARACTER)
                    {
                        nbPts_++;
                    }
                    if (c == POSSIBLE_CHAR)
                    {
                        nbZeroOne_++;
                    }
                }
                indiceRDecalePt_ = index_ + nbPts_;
                //indiceNext_ = _string.IndexOf(e, indiceRDecalePt_);
                if (separators_.get(i_).Contains(char.ToString(STRING)))
                {
                    if (words_.isValidIndex(i_ + 1))
                    {
                        indiceNext_ = _string.IndexOf(e, indiceRDecalePt_);
                        //indiceNext_ = greatestIndex(_string, e, indiceRDecalePt_);
                        if (indiceNext_ == INDEX_NOT_FOUND_ELT)
                        {
                            return(false);
                        }
                    }
                    else
                    {
                        indiceNext_ = greatestIndex(_string, e, indiceRDecalePt_);
                        if (indiceNext_ == INDEX_NOT_FOUND_ELT)
                        {
                            return(false);
                        }
                    }
                }
                else
                {
                    indiceNext_ = _string.IndexOf(e, indiceRDecalePt_);
                    if (indiceRDecalePt_ > indiceNext_ || indiceRDecalePt_ < indiceNext_ - nbZeroOne_)
                    {
                        return(false);
                    }
                }
                index_ = indiceNext_ + e.Count();
                i_++;
            }
            Console.WriteLine(separators_);
            lastSep_ = separators_.last();
            Console.WriteLine(lastSep_ + "%" + _string + "%" + _filter);
            nbPts_     = 0;
            nbZeroOne_ = 0;
            foreach (char c in lastSep_.ToCharArray())
            {
                if (c == CHARACTER)
                {
                    nbPts_++;
                }
                if (c == POSSIBLE_CHAR)
                {
                    nbZeroOne_++;
                }
            }
            index_ += nbPts_;
            if (index_ == _string.Count())
            {
                return(true);
            }
            if (index_ < _string.Count())
            {
                if (lastSep_.Contains(char.ToString(STRING)))
                {
                    return(true);
                }
                if (_string.Count() <= index_ + nbZeroOne_)
                {
                    return(true);
                }
            }
            return(false);
        }
Пример #4
0
        public static String formatBasic(String _pattern, Map <String, String> _map, bool _substringFirst)
        {
            bool          exit_;
            int           i_;
            int           length_;
            StringBuilder strBuilder_;
            StringList    keys_;
            String        subString_;

            if (_substringFirst)
            {
                length_     = _pattern.Length;
                strBuilder_ = new StringBuilder();
                i_          = List.FIRST_INDEX;
                keys_       = new StringList(_map.getKeys());
                exit_       = false;
                while (i_ < length_)
                {
                    int        j_    = List.FIRST_INDEX;
                    StringList list_ = keys_;
                    while (true)
                    {
                        StringList nexList_ = new StringList();
                        foreach (String k in list_)
                        {
                            if (k.Length <= j_)
                            {
                                continue;
                            }
                            if (k.ElementAt(j_) == _pattern.ElementAt(j_ + i_))
                            {
                                nexList_.Add(k);
                            }
                        }
                        list_ = nexList_;
                        if (_pattern.Length <= j_ + i_ + 1)
                        {
                            exit_      = true;
                            subString_ = _pattern.Substring(i_);
                            if (list_.containsObj(subString_))
                            {
                                strBuilder_.Append(_map.getVal(subString_));
                            }
                            else
                            {
                                strBuilder_.Append(subString_);
                            }
                            break;
                        }
                        subString_ = _pattern.Substring(i_, j_ + 1);
                        if (list_.containsObj(subString_))
                        {
                            strBuilder_.Append(_map.getVal(subString_));
                            i_ += j_;
                            break;
                        }
                        if (list_.isEmpty())
                        {
                            strBuilder_.Append(subString_);
                            i_ += j_;
                            break;
                        }
                        j_++;
                    }
                    if (exit_)
                    {
                        break;
                    }
                    i_++;
                }
                return(strBuilder_.ToString());
            }
            length_     = _pattern.Length;
            strBuilder_ = new StringBuilder();
            i_          = List.FIRST_INDEX;
            keys_       = new StringList(_map.getKeys());
            exit_       = false;
            while (i_ < length_)
            {
                int        j_    = List.FIRST_INDEX;
                StringList list_ = keys_;
                while (true)
                {
                    StringList nexList_ = new StringList();
                    foreach (String k in list_)
                    {
                        if (k.Length <= j_)
                        {
                            continue;
                        }
                        if (k.ElementAt(j_) == _pattern.ElementAt(j_ + i_))
                        {
                            nexList_.Add(k);
                        }
                    }
                    list_ = nexList_;
                    if (_pattern.Length <= j_ + i_ + 1)
                    {
                        exit_      = true;
                        subString_ = _pattern.Substring(i_);
                        if (list_.containsObj(subString_))
                        {
                            strBuilder_.Append(_map.getVal(subString_));
                        }
                        else
                        {
                            strBuilder_.Append(subString_);
                        }
                        break;
                    }
                    subString_ = _pattern.Substring(i_, j_ + 1);
                    StringList filterList_ = new StringList(list_);
                    bool       exist_      = false;
                    foreach (String s in filterList_)
                    {
                        if (s.Contains(subString_ + _pattern.ElementAt(j_ + i_ + 1)))
                        {
                            exist_ = true;
                            break;
                        }
                    }
                    if (list_.containsObj(subString_) && !exist_)
                    {
                        strBuilder_.Append(_map.getVal(subString_));
                        i_ += j_;
                        break;
                    }
                    if (list_.isEmpty())
                    {
                        strBuilder_.Append(subString_);
                        i_ += j_;
                        break;
                    }
                    j_++;
                }
                if (exit_)
                {
                    break;
                }
                i_++;
            }
            return(strBuilder_.ToString());
        }