diff options
Diffstat (limited to 'lexers/LexRuby.cxx')
-rw-r--r-- | lexers/LexRuby.cxx | 122 |
1 files changed, 61 insertions, 61 deletions
diff --git a/lexers/LexRuby.cxx b/lexers/LexRuby.cxx index c06915144..be60f8041 100644 --- a/lexers/LexRuby.cxx +++ b/lexers/LexRuby.cxx @@ -68,7 +68,7 @@ static bool inline iswhitespace(char ch) { #define STYLE_MASK 63 #define actual_style(style) (style & STYLE_MASK) -static bool followsDot(unsigned int pos, Accessor &styler) { +static bool followsDot(Sci_PositionU pos, Accessor &styler) { styler.Flush(); for (; pos >= 1; --pos) { int style = actual_style(styler.StyleAt(pos)); @@ -95,16 +95,16 @@ static bool followsDot(unsigned int pos, Accessor &styler) { // Forward declarations static bool keywordIsAmbiguous(const char *prevWord); -static bool keywordDoStartsLoop(int pos, +static bool keywordDoStartsLoop(Sci_Position pos, Accessor &styler); static bool keywordIsModifier(const char *word, - int pos, + Sci_Position pos, Accessor &styler); -static int ClassifyWordRb(unsigned int start, unsigned int end, WordList &keywords, Accessor &styler, char *prevWord) { +static int ClassifyWordRb(Sci_PositionU start, Sci_PositionU end, WordList &keywords, Accessor &styler, char *prevWord) { char s[MAX_KEYWORD_LENGTH]; - unsigned int i, j; - unsigned int lim = end - start + 1; // num chars to copy + Sci_PositionU i, j; + Sci_PositionU lim = end - start + 1; // num chars to copy if (lim >= MAX_KEYWORD_LENGTH) { lim = MAX_KEYWORD_LENGTH - 1; } @@ -149,7 +149,7 @@ static int ClassifyWordRb(unsigned int start, unsigned int end, WordList &keywor //XXX Identical to Perl, put in common area -static bool isMatch(Accessor &styler, int lengthDoc, int pos, const char *val) { +static bool isMatch(Accessor &styler, Sci_Position lengthDoc, Sci_Position pos, const char *val) { if ((pos + static_cast<int>(strlen(val))) >= lengthDoc) { return false; } @@ -167,8 +167,8 @@ static bool isMatch(Accessor &styler, int lengthDoc, int pos, const char *val) { // Precondition: the here-doc target can be indented static bool lookingAtHereDocDelim(Accessor &styler, - int pos, - int lengthDoc, + Sci_Position pos, + Sci_Position lengthDoc, const char *HereDocDelim) { if (!isMatch(styler, lengthDoc, pos, HereDocDelim)) { @@ -201,7 +201,7 @@ static char opposite(char ch) { // Null transitions when we see we've reached the end // and need to relex the curr char. -static void redo_char(int &i, char &ch, char &chNext, char &chNext2, +static void redo_char(Sci_Position &i, char &ch, char &chNext, char &chNext2, int &state) { i--; chNext2 = chNext; @@ -209,19 +209,19 @@ static void redo_char(int &i, char &ch, char &chNext, char &chNext2, state = SCE_RB_DEFAULT; } -static void advance_char(int &i, char &ch, char &chNext, char &chNext2) { +static void advance_char(Sci_Position &i, char &ch, char &chNext, char &chNext2) { i++; ch = chNext; chNext = chNext2; } // precondition: startPos points to one after the EOL char -static bool currLineContainsHereDelims(int &startPos, +static bool currLineContainsHereDelims(Sci_Position &startPos, Accessor &styler) { if (startPos <= 1) return false; - int pos; + Sci_Position pos; for (pos = startPos - 1; pos > 0; pos--) { char ch = styler.SafeGetCharAt(pos); if (isEOLChar(ch)) { @@ -314,10 +314,10 @@ static void exitInnerExpression(int *p_inner_string_types, curr_quote = p_inner_quotes[inner_string_count]; } -static bool isEmptyLine(int pos, +static bool isEmptyLine(Sci_Position pos, Accessor &styler) { int spaceFlags = 0; - int lineCurrent = styler.GetLine(pos); + Sci_Position lineCurrent = styler.GetLine(pos); int indentCurrent = styler.IndentAmount(lineCurrent, &spaceFlags, NULL); return (indentCurrent & SC_FOLDLEVELWHITEFLAG) != 0; } @@ -346,10 +346,10 @@ static bool RE_CanFollowKeyword(const char *keyword) { // Look at chars up to but not including endPos // Don't look at styles in case we're looking forward -static int skipWhitespace(int startPos, - int endPos, +static int skipWhitespace(Sci_Position startPos, + Sci_Position endPos, Accessor &styler) { - for (int i = startPos; i < endPos; i++) { + for (Sci_Position i = startPos; i < endPos; i++) { if (!iswhitespace(styler[i])) { return i; } @@ -363,19 +363,19 @@ static int skipWhitespace(int startPos, // // iPrev points to the start of << -static bool sureThisIsHeredoc(int iPrev, +static bool sureThisIsHeredoc(Sci_Position iPrev, Accessor &styler, char *prevWord) { // Not so fast, since Ruby's so dynamic. Check the context // to make sure we're OK. int prevStyle; - int lineStart = styler.GetLine(iPrev); - int lineStartPosn = styler.LineStart(lineStart); + Sci_Position lineStart = styler.GetLine(iPrev); + Sci_Position lineStartPosn = styler.LineStart(lineStart); styler.Flush(); // Find the first word after some whitespace - int firstWordPosn = skipWhitespace(lineStartPosn, iPrev, styler); + Sci_Position firstWordPosn = skipWhitespace(lineStartPosn, iPrev, styler); if (firstWordPosn >= iPrev) { // Have something like {^ <<} //XXX Look at the first previous non-comment non-white line @@ -391,7 +391,7 @@ static bool sureThisIsHeredoc(int iPrev, return true; } } - int firstWordEndPosn = firstWordPosn; + Sci_Position firstWordEndPosn = firstWordPosn; char *dst = prevWord; for (;;) { if (firstWordEndPosn >= iPrev || @@ -414,15 +414,15 @@ static bool sureThisIsHeredoc(int iPrev, // Routine that saves us from allocating a buffer for the here-doc target // targetEndPos points one past the end of the current target -static bool haveTargetMatch(int currPos, - int lengthDoc, - int targetStartPos, - int targetEndPos, +static bool haveTargetMatch(Sci_Position currPos, + Sci_Position lengthDoc, + Sci_Position targetStartPos, + Sci_Position targetEndPos, Accessor &styler) { if (lengthDoc - currPos < targetEndPos - targetStartPos) { return false; } - int i, j; + Sci_Position i, j; for (i = targetStartPos, j = currPos; i < targetEndPos && j < lengthDoc; i++, j++) { @@ -447,19 +447,19 @@ static bool haveTargetMatch(int currPos, // return true == yes, we have no heredocs -static bool sureThisIsNotHeredoc(int lt2StartPos, +static bool sureThisIsNotHeredoc(Sci_Position lt2StartPos, Accessor &styler) { int prevStyle; // Use full document, not just part we're styling - int lengthDoc = styler.Length(); - int lineStart = styler.GetLine(lt2StartPos); - int lineStartPosn = styler.LineStart(lineStart); + Sci_Position lengthDoc = styler.Length(); + Sci_Position lineStart = styler.GetLine(lt2StartPos); + Sci_Position lineStartPosn = styler.LineStart(lineStart); styler.Flush(); const bool definitely_not_a_here_doc = true; const bool looks_like_a_here_doc = false; // Find the first word after some whitespace - int firstWordPosn = skipWhitespace(lineStartPosn, lt2StartPos, styler); + Sci_Position firstWordPosn = skipWhitespace(lineStartPosn, lt2StartPos, styler); if (firstWordPosn >= lt2StartPos) { return definitely_not_a_here_doc; } @@ -508,12 +508,12 @@ static bool sureThisIsNotHeredoc(int lt2StartPos, return definitely_not_a_here_doc; } // OK, now 'j' will point to the current spot moving ahead - int j = firstWordPosn + 1; + Sci_Position j = firstWordPosn + 1; if (styler.StyleAt(j) != SCE_RB_OPERATOR || styler[j] != '<') { // This shouldn't happen return definitely_not_a_here_doc; } - int nextLineStartPosn = styler.LineStart(lineStart + 1); + Sci_Position nextLineStartPosn = styler.LineStart(lineStart + 1); if (nextLineStartPosn >= lengthDoc) { return definitely_not_a_here_doc; } @@ -522,7 +522,7 @@ static bool sureThisIsNotHeredoc(int lt2StartPos, return definitely_not_a_here_doc; } bool allow_indent; - int target_start, target_end; + Sci_Position target_start, target_end; // From this point on no more styling, since we're looking ahead if (styler[j] == '-') { allow_indent = true; @@ -580,12 +580,12 @@ static bool sureThisIsNotHeredoc(int lt2StartPos, } // Just look at the start of each line - int last_line = styler.GetLine(lengthDoc - 1); + Sci_Position last_line = styler.GetLine(lengthDoc - 1); // But don't go too far if (last_line > lineStart + 50) { last_line = lineStart + 50; } - for (int line_num = lineStart + 1; line_num <= last_line; line_num++) { + for (Sci_Position line_num = lineStart + 1; line_num <= last_line; line_num++) { if (allow_indent) { j = skipWhitespace(styler.LineStart(line_num), lengthDoc, styler); } else { @@ -604,8 +604,8 @@ static bool sureThisIsNotHeredoc(int lt2StartPos, // move to the start of the first line that is not in a // multi-line construct -static void synchronizeDocStart(unsigned int &startPos, - int &length, +static void synchronizeDocStart(Sci_PositionU &startPos, + Sci_Position &length, int &initStyle, Accessor &styler, bool skipWhiteSpace=false) { @@ -620,9 +620,9 @@ static void synchronizeDocStart(unsigned int &startPos, return; } - int pos = startPos; + Sci_Position pos = startPos; // Quick way to characterize each line - int lineStart; + Sci_Position lineStart; for (lineStart = styler.GetLine(pos); lineStart > 0; lineStart--) { // Now look at the style before the previous line's EOL pos = styler.LineStart(lineStart) - 1; @@ -695,7 +695,7 @@ static void ColouriseRbDoc(Sci_PositionU startPos, Sci_Position length, int init bool preferRE = true; int state = initStyle; - int lengthDoc = startPos + length; + Sci_Position lengthDoc = startPos + length; char prevWord[MAX_KEYWORD_LENGTH + 1]; // 1 byte for zero prevWord[0] = '\0'; @@ -743,7 +743,7 @@ static void ColouriseRbDoc(Sci_PositionU startPos, Sci_Position length, int init int inner_string_count = 0; int brace_counts = 0; // Number of #{ ... } things within an expression - int i; + Sci_Position i; for (i = 0; i < INNER_STRINGS_MAX_COUNT; i++) { inner_string_types[i] = 0; inner_expn_brace_counts[i] = 0; @@ -1103,7 +1103,7 @@ static void ColouriseRbDoc(Sci_PositionU startPos, Sci_Position length, int init // No need to handle this state -- we'll just move to the end preferRE = false; } else { - int wordStartPos = styler.GetStartSegment(); + Sci_Position wordStartPos = styler.GetStartSegment(); int word_style = ClassifyWordRb(wordStartPos, i - 1, keywords, styler, prevWord); switch (word_style) { case SCE_RB_WORD: @@ -1445,12 +1445,12 @@ static void ColouriseRbDoc(Sci_PositionU startPos, Sci_Position length, int init // Helper functions for folding, disambiguation keywords // Assert that there are no high-bit chars -static void getPrevWord(int pos, +static void getPrevWord(Sci_Position pos, char *prevWord, Accessor &styler, int word_state) { - int i; + Sci_Position i; styler.Flush(); for (i = pos - 1; i > 0; i--) { if (actual_style(styler.StyleAt(i)) != word_state) { @@ -1488,7 +1488,7 @@ static bool keywordIsAmbiguous(const char *prevWord) // do after a while or until, as a noise word (like then after if) static bool keywordIsModifier(const char *word, - int pos, + Sci_Position pos, Accessor &styler) { if (word[0] == 'd' && word[1] == 'o' && !word[2]) { @@ -1496,8 +1496,8 @@ static bool keywordIsModifier(const char *word, } char ch, chPrev, chPrev2; int style = SCE_RB_DEFAULT; - int lineStart = styler.GetLine(pos); - int lineStartPosn = styler.LineStart(lineStart); + Sci_Position lineStart = styler.GetLine(pos); + Sci_Position lineStartPosn = styler.LineStart(lineStart); // We want to step backwards until we don't care about the current // position. But first move lineStartPosn back behind any // continuations immediately above word. @@ -1599,13 +1599,13 @@ static bool keywordIsModifier(const char *word, // Nothing fancy -- look to see if we follow a while/until somewhere // on the current line -static bool keywordDoStartsLoop(int pos, +static bool keywordDoStartsLoop(Sci_Position pos, Accessor &styler) { char ch; int style; - int lineStart = styler.GetLine(pos); - int lineStartPosn = styler.LineStart(lineStart); + Sci_Position lineStart = styler.GetLine(pos); + Sci_Position lineStartPosn = styler.LineStart(lineStart); styler.Flush(); while (--pos >= lineStartPosn) { style = actual_style(styler.StyleAt(pos)); @@ -1621,7 +1621,7 @@ static bool keywordDoStartsLoop(int pos, char prevWord[MAX_KEYWORD_LENGTH + 1]; // 1 byte for zero char *dst = prevWord; int wordLen = 0; - int start_word; + Sci_Position start_word; for (start_word = pos; start_word >= lineStartPosn && actual_style(styler.StyleAt(start_word)) == SCE_RB_WORD; start_word--) { @@ -1651,10 +1651,10 @@ static bool keywordDoStartsLoop(int pos, return false; } -static bool IsCommentLine(int line, Accessor &styler) { - int pos = styler.LineStart(line); - int eol_pos = styler.LineStart(line + 1) - 1; - for (int i = pos; i < eol_pos; i++) { +static bool IsCommentLine(Sci_Position line, Accessor &styler) { + Sci_Position pos = styler.LineStart(line); + Sci_Position eol_pos = styler.LineStart(line + 1) - 1; + for (Sci_Position i = pos; i < eol_pos; i++) { char ch = styler[i]; if (ch == '#') return true; @@ -1725,9 +1725,9 @@ static void FoldRbDoc(Sci_PositionU startPos, Sci_Position length, int initStyle synchronizeDocStart(startPos, length, initStyle, styler, // ref args false); - unsigned int endPos = startPos + length; + Sci_PositionU endPos = startPos + length; int visibleChars = 0; - int lineCurrent = styler.GetLine(startPos); + Sci_Position lineCurrent = styler.GetLine(startPos); int levelPrev = startPos == 0 ? 0 : (styler.LevelAt(lineCurrent) & SC_FOLDLEVELNUMBERMASK & ~SC_FOLDLEVELBASE); @@ -1736,7 +1736,7 @@ static void FoldRbDoc(Sci_PositionU startPos, Sci_Position length, int initStyle int styleNext = styler.StyleAt(startPos); int stylePrev = startPos <= 1 ? SCE_RB_DEFAULT : styler.StyleAt(startPos - 1); bool buffer_ends_with_eol = false; - for (unsigned int i = startPos; i < endPos; i++) { + for (Sci_PositionU i = startPos; i < endPos; i++) { char ch = chNext; chNext = styler.SafeGetCharAt(i + 1); int style = styleNext; |