void EvaluationQueue::RemoveFirst() { if(!m_tokens.IsEmpty()) { m_workingGroupChanged = false; m_tokens.RemoveAt(0); } else { if (m_queue == NULL) return; // shouldn't happen EvaluationQueueElement* tmp = m_queue; if (m_queue == m_last) { m_queue = m_last = NULL; } else m_queue = m_queue->next; delete tmp; m_size--; if(!Empty()) { AddTokens(GetCell()->GetEditable()->GetValue()); m_workingGroupChanged = true; } } }
void EvaluationQueue::AddToQueue(GroupCell* gr) { bool emptyWas = Empty(); if (gr->GetGroupType() != GC_TYPE_CODE || gr->GetEditable() == NULL) // dont add cells which can't be evaluated return; EvaluationQueueElement* newelement = new EvaluationQueueElement(gr); if (m_last == NULL) m_queue = m_last = newelement; else { m_last->next = newelement; m_last = newelement; } m_size++; if(emptyWas) { AddTokens(gr->GetEditable()->GetValue()); m_workingGroupChanged = true; } }
void TextMateAnnotator::Tokenize( const char* docStart, const char* docEnd ) { TextMatePatterns* patterns = m_language.defaultPatterns; std::vector<TextMatePatterns*> patternsStack; uint32_t style = m_defaultStyle; std::vector<uint32_t> styleStack; const char* lineStart = docStart; const char* searchStart = lineStart; const char* lineEnd = std::find( lineStart, docEnd, 0x0A ); bool isFirstSearch = true; while ( searchStart != docEnd ) { TextMateBestMatch match; if ( searchStart != lineEnd ) match = FindBestMatch( lineStart, searchStart, lineEnd, isFirstSearch, patterns->regexes ); if ( match.index >= 0 ) { AddTokensUpTo( lineStart - docStart + match.start, style ); AddTokens( patterns->regexes[match.index], patterns->captures[match.index], patterns->styles[match.index], lineStart - docStart ); searchStart = lineStart + match.start + match.length; if ( match.index == 0 && !patternsStack.empty() ) { style = styleStack.back(); styleStack.pop_back(); patterns = patternsStack.back(); patternsStack.pop_back(); isFirstSearch = true; } else if ( patterns->patterns[match.index] ) { styleStack.push_back( style ); style = patterns->styles[match.index]; patternsStack.push_back( patterns ); patterns = patterns->patterns[match.index]; isFirstSearch = true; } } else { lineStart = (std::min)( lineEnd + 1, docEnd ); searchStart = lineStart; lineEnd = std::find( lineStart, docEnd, 0x0A ); isFirstSearch = true; } } AddTokensUpTo( docEnd - docStart, style ); }