Ejemplo n.º 1
0
        CharHashSet _suffixesFirsts; //first chars of all suffixes, for fast suffix detection
        #endregion


        #region overrides: Init, TryMatch
        public override void Init(GrammarData grammarData)
        {
            base.Init(grammarData);
            //collect all suffixes, prefixes in lists and create sets of first chars for both
            Prefixes.Sort(StringList.LongerFirst);
            Suffixes.Sort(StringList.LongerFirst);

            _prefixesFirsts = new CharHashSet(CaseSensitivePrefixesSuffixes);
            _suffixesFirsts = new CharHashSet(CaseSensitivePrefixesSuffixes);
            foreach (string pfx in Prefixes)
            {
                _prefixesFirsts.Add(pfx[0]);
            }

            foreach (string sfx in Suffixes)
            {
                _suffixesFirsts.Add(sfx[0]);
            }
        }//method
Ejemplo n.º 2
0
        string _suffixesFirsts;       //first chars of all suffixes, for fast suffix detection
        #endregion


        #region overrides: Init, TryMatch
        public override void Init(GrammarData grammarData)
        {
            base.Init(grammarData);
            //collect all suffixes, prefixes in lists and create strings of first chars for both
            Prefixes.Sort(StringList.LongerFirst);
            _prefixesFirsts = string.Empty;
            foreach (string pfx in Prefixes)
            {
                _prefixesFirsts += pfx[0];
            }

            Suffixes.Sort(StringList.LongerFirst);
            _suffixesFirsts = string.Empty;
            foreach (string sfx in Suffixes)
            {
                _suffixesFirsts += sfx[0]; //we don't care if there are repetitions
            }
            if (!CaseSensitive)
            {
                _prefixesFirsts = _prefixesFirsts.ToLower() + _prefixesFirsts.ToUpper();
                _suffixesFirsts = _suffixesFirsts.ToLower() + _suffixesFirsts.ToUpper();
            }
        }//method