Ejemplo n.º 1
0
        protected static void _SkipWhitespace(CharReader reader)
        {
            char currChar;

            while (true)
            {
                if (reader.EOF())
                {
                    break;
                }
                currChar = reader.Peek();
                // use c# definition of whitespace
                if (char.IsWhiteSpace(currChar))
                {
                    reader.Read(); // gobble char
                    continue;
                }
                // check for comments
                if (currChar == '/')
                {
                    reader.Read();       // gobble char
                    char nextChar = reader.Read();
                    if (nextChar == '/') // to EOF
                    {
                        while (true)
                        {
                            // not error if EOF before CR-LF
                            if (reader.EOF())
                            {
                                break;
                            }
                            currChar = reader.Read();
                            if (currChar == '\r' || currChar == '\n')
                            {
                                break;
                            }
                        }
                        continue;
                    }
                    else if (nextChar == '*') /* to */
                    {
                        nextChar = ' ';       // clear for comparison
                        while (true)
                        {
                            // will throw an error if EOF before '*/' is found
                            currChar = nextChar;
                            nextChar = reader.Read();
                            if (currChar == '*' && nextChar == '/')
                            {
                                break;
                            }
                        }
                        continue;
                    }
                    else // not a comment
                    {
                        // push back in reverse order
                        reader.Push(nextChar);
                        reader.Push(currChar);
                        break;
                    }
                }
                break;
            }
        }