Exemple #1
0
 public void PredicateParse(string s)
 {
     _tokens = Regex.Matches(s, _pattern, RegexOptions.Compiled).Cast <Match>()
               .Select(m => m.Groups[1])
               .GetTwoWayEnumerator();
     Move();
 }
Exemple #2
0
        /// <summary>
        /// Tokenizes the given file (through constructor).
        /// </summary>
        /// <param name="sourceCode">The source code for this tokenizer to run on.</param>
        public void Tokenize(string sourceCode)
        {
            if (_tokenEnumerator != null)
            {
                throw new Exception("This code is already parsed!");
            }

            var tokens = TokenizeInternal(sourceCode);

            _tokenEnumerator = tokens.GetTwoWayEnumerator();
        }
Exemple #3
0
        /// <summary>
        /// Converts a string from lower_case to CamelCase.
        ///
        /// <param name="lower_case">a string in lower case</param>
        /// <returns>the specified string converted to camel case</returns>
        /// </summary>
        public static string lower_case_to_camel_case(string lower_case)
        {
            var result_builder = new StringBuilder("");

            ITwoWayEnumerator <char> i = lower_case.GetTwoWayEnumerator();

            i.MoveNext();
            int length = lower_case.Length;


            bool last_underscore = true;

            while (true)
            {
                char c = i.Current;
                if (c == '_')
                {
                    last_underscore = true;
                }
                else if (Char.IsUpper(c))
                {
                    // original string is not lower_case, don't apply transformation
                    return(lower_case);
                }
                else if (last_underscore)
                {
                    result_builder.Append(Char.ToUpper(c));
                    last_underscore = false;
                }
                else
                {
                    result_builder.Append(c);
                }

                if (!i.MoveNext())
                {
                    break;
                }
            }

            return(result_builder.ToString());
        }