Example #1
0
 public SegmentedString(SegmentedString other)
 {
     m_pushedChar1   = other.m_pushedChar1;
     m_pushedChar2   = other.m_pushedChar2;
     m_currentString = new SegmentedSubstring(other.m_currentString);
     if (m_pushedChar2 != 0)
     {
         m_currentChar = m_pushedChar2;
     }
     else if (m_pushedChar1 != 0)
     {
         m_currentChar = m_pushedChar1;
     }
     else
     {
         m_currentChar = m_currentString.m_length != 0 ? m_currentString.getCurrentChar() : '\0';
     }
     m_numberOfCharactersConsumedPriorToCurrentString = other.m_numberOfCharactersConsumedPriorToCurrentString;
     m_numberOfCharactersConsumedPriorToCurrentLine   = other.m_numberOfCharactersConsumedPriorToCurrentLine;
     m_currentLine   = other.m_currentLine;
     m_substrings    = new List <SegmentedSubstring>(other.m_substrings);
     m_closed        = other.m_closed;
     m_empty         = other.m_empty;
     m_fastPathFlags = other.m_fastPathFlags;
     m_advanceFunc   = other.m_advanceFunc;
     m_advanceAndUpdateLineNumberFunc = other.m_advanceAndUpdateLineNumberFunc;
 }
Example #2
0
        public bool peek(SegmentedString source, bool skipNullCharacters = false)
        {
            if (source.isEmpty())
            {
                return(false);
            }

            m_nextInputCharacter = source.currentChar();

            // Every branch in this function is expensive, so we have a
            // fast-reject branch for characters that don't require special
            // handling. Please run the parser benchmark whenever you touch
            // this function. It's very hot.
            const char specialCharacterMask = (char)('\n' | '\r' | '\0');

            if (m_nextInputCharacter & ~specialCharacterMask)
            {
                m_skipNextNewLine = false;
                return(true);
            }
            return(processNextInputCharacter(source, skipNullCharacters));
        }