diff options
author | Joe Mueller <unknown> | 2015-07-30 14:35:17 +1000 |
---|---|---|
committer | Joe Mueller <unknown> | 2015-07-30 14:35:17 +1000 |
commit | 58471e908a3b74b27379bb19a13d62cd8d4476b0 (patch) | |
tree | 8f61293f34d008fea20584c631d23e58b3fe53aa /lexers/LexPerl.cxx | |
parent | 2270ab97445c6f12bd0fddb273ab617fdb421594 (diff) | |
download | scintilla-mirror-58471e908a3b74b27379bb19a13d62cd8d4476b0.tar.gz |
Use Sci_Position / Sci_PositionU for variables in lexers that represent
positions and line numbers and may be widened to 64-bits in a future release.
Diffstat (limited to 'lexers/LexPerl.cxx')
-rw-r--r-- | lexers/LexPerl.cxx | 70 |
1 files changed, 35 insertions, 35 deletions
diff --git a/lexers/LexPerl.cxx b/lexers/LexPerl.cxx index c81dc2663..df6cc9d3e 100644 --- a/lexers/LexPerl.cxx +++ b/lexers/LexPerl.cxx @@ -69,19 +69,19 @@ using namespace Scintilla; // we also assume SCE_PL_STRING_VAR is the interpolated style with the smallest value #define INTERPOLATE_SHIFT (SCE_PL_STRING_VAR - SCE_PL_STRING) -static bool isPerlKeyword(unsigned int start, unsigned int end, WordList &keywords, LexAccessor &styler) { +static bool isPerlKeyword(Sci_PositionU start, Sci_PositionU end, WordList &keywords, LexAccessor &styler) { // old-style keyword matcher; needed because GetCurrent() needs // current segment to be committed, but we may abandon early... char s[100]; - unsigned int i, len = end - start; + Sci_PositionU i, len = end - start; if (len > 30) { len = 30; } for (i = 0; i < len; i++, start++) s[i] = styler[start]; s[i] = '\0'; return keywords.InList(s); } -static int disambiguateBareword(LexAccessor &styler, unsigned int bk, unsigned int fw, - int backFlag, unsigned int backPos, unsigned int endPos) { +static int disambiguateBareword(LexAccessor &styler, Sci_PositionU bk, Sci_PositionU fw, + int backFlag, Sci_PositionU backPos, Sci_PositionU endPos) { // identifiers are recognized by Perl as barewords under some // conditions, the following attempts to do the disambiguation // by looking backward and forward; result in 2 LSB @@ -93,7 +93,7 @@ static int disambiguateBareword(LexAccessor &styler, unsigned int bk, unsigned i return result; // first look backwards past whitespace/comments to set EOL flag // (some disambiguation patterns must be on a single line) - if (backPos <= static_cast<unsigned int>(styler.LineStart(styler.GetLine(bk)))) + if (backPos <= static_cast<Sci_PositionU>(styler.LineStart(styler.GetLine(bk)))) moreback = true; // look backwards at last significant lexed item for disambiguation bk = backPos - 1; @@ -128,7 +128,7 @@ static int disambiguateBareword(LexAccessor &styler, unsigned int bk, unsigned i return result; } -static void skipWhitespaceComment(LexAccessor &styler, unsigned int &p) { +static void skipWhitespaceComment(LexAccessor &styler, Sci_PositionU &p) { // when backtracking, we need to skip whitespace and comments int style; while ((p > 0) && (style = styler.StyleAt(p), @@ -136,7 +136,7 @@ static void skipWhitespaceComment(LexAccessor &styler, unsigned int &p) { p--; } -static int styleBeforeBracePair(LexAccessor &styler, unsigned int bk) { +static int styleBeforeBracePair(LexAccessor &styler, Sci_PositionU bk) { // backtrack to find open '{' corresponding to a '}', balanced // return significant style to be tested for '/' disambiguation int braceCount = 1; @@ -163,7 +163,7 @@ static int styleBeforeBracePair(LexAccessor &styler, unsigned int bk) { return SCE_PL_DEFAULT; } -static int styleCheckIdentifier(LexAccessor &styler, unsigned int bk) { +static int styleCheckIdentifier(LexAccessor &styler, Sci_PositionU bk) { // backtrack to classify sub-styles of identifier under test // return sub-style to be tested for '/' disambiguation if (styler.SafeGetCharAt(bk) == '>') // inputsymbol, like <foo> @@ -188,7 +188,7 @@ static int styleCheckIdentifier(LexAccessor &styler, unsigned int bk) { return 0; } -static int podLineScan(LexAccessor &styler, unsigned int &pos, unsigned int endPos) { +static int podLineScan(LexAccessor &styler, Sci_PositionU &pos, Sci_PositionU endPos) { // forward scan the current line to classify line for POD style int state = -1; while (pos < endPos) { @@ -212,7 +212,7 @@ static int podLineScan(LexAccessor &styler, unsigned int &pos, unsigned int endP return state; } -static bool styleCheckSubPrototype(LexAccessor &styler, unsigned int bk) { +static bool styleCheckSubPrototype(LexAccessor &styler, Sci_PositionU bk) { // backtrack to identify if we're starting a subroutine prototype // we also need to ignore whitespace/comments: // 'sub' [whitespace|comment] <identifier> [whitespace|comment] @@ -247,10 +247,10 @@ static int opposite(int ch) { return ch; } -static bool IsCommentLine(int line, LexAccessor &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, LexAccessor &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]; int style = styler.StyleAt(i); if (ch == '#' && style == SCE_PL_COMMENTLINE) @@ -261,8 +261,8 @@ static bool IsCommentLine(int line, LexAccessor &styler) { return false; } -static bool IsPackageLine(int line, LexAccessor &styler) { - int pos = styler.LineStart(line); +static bool IsPackageLine(Sci_Position line, LexAccessor &styler) { + Sci_Position pos = styler.LineStart(line); int style = styler.StyleAt(pos); if (style == SCE_PL_WORD && styler.Match(pos, "package")) { return true; @@ -270,7 +270,7 @@ static bool IsPackageLine(int line, LexAccessor &styler) { return false; } -static int PodHeadingLevel(int pos, LexAccessor &styler) { +static int PodHeadingLevel(Sci_Position pos, LexAccessor &styler) { int lvl = static_cast<unsigned char>(styler.SafeGetCharAt(pos + 5)); if (lvl >= '1' && lvl <= '4') { return lvl - '0'; @@ -400,7 +400,7 @@ Sci_Position SCI_METHOD LexerPerl::WordListSet(int n, const char *wl) { wordListN = &keywords; break; } - int firstModification = -1; + Sci_Position firstModification = -1; if (wordListN) { WordList wlNew; wlNew.Set(wl); @@ -600,7 +600,7 @@ void SCI_METHOD LexerPerl::Lex(Sci_PositionU startPos, Sci_Position length, int int numState = PERLNUM_DECIMAL; int dotCount = 0; - unsigned int endPos = startPos + length; + Sci_PositionU endPos = startPos + length; // Backtrack to beginning of style if required... // If in a long distance lexical state, backtrack to find quote characters. @@ -663,7 +663,7 @@ void SCI_METHOD LexerPerl::Lex(Sci_PositionU startPos, Sci_Position length, int || initStyle == SCE_PL_POD_VERB ) { // POD backtracking finds preceding blank lines and goes back past them - int ln = styler.GetLine(startPos); + Sci_Position ln = styler.GetLine(startPos); if (ln > 0) { initStyle = styler.StyleAt(styler.LineStart(--ln)); if (initStyle == SCE_PL_POD || initStyle == SCE_PL_POD_VERB) { @@ -682,7 +682,7 @@ void SCI_METHOD LexerPerl::Lex(Sci_PositionU startPos, Sci_Position length, int // Look backwards past whitespace and comments in order to detect either // operator or keyword. Later updated as we go along. int backFlag = BACK_NONE; - unsigned int backPos = startPos; + Sci_PositionU backPos = startPos; if (backPos > 0) { backPos--; skipWhitespaceComment(styler, backPos); @@ -814,7 +814,7 @@ void SCI_METHOD LexerPerl::Lex(Sci_PositionU startPos, Sci_Position length, int case SCE_PL_HERE_DELIM: if (HereDoc.State == 0) { // '<<' encountered int delim_ch = sc.chNext; - int ws_skip = 0; + Sci_Position ws_skip = 0; HereDoc.State = 1; // pre-init HERE doc class HereDoc.Quote = sc.chNext; HereDoc.Quoted = false; @@ -822,7 +822,7 @@ void SCI_METHOD LexerPerl::Lex(Sci_PositionU startPos, Sci_Position length, int HereDoc.Delimiter[HereDoc.DelimiterLength] = '\0'; if (IsASpaceOrTab(delim_ch)) { // skip whitespace; legal only for quoted delimiters - unsigned int i = sc.currentPos + 1; + Sci_PositionU i = sc.currentPos + 1; while ((i < endPos) && IsASpaceOrTab(delim_ch)) { i++; delim_ch = static_cast<unsigned char>(styler.SafeGetCharAt(i)); @@ -929,8 +929,8 @@ void SCI_METHOD LexerPerl::Lex(Sci_PositionU startPos, Sci_Position length, int break; case SCE_PL_POD: case SCE_PL_POD_VERB: { - unsigned int fw = sc.currentPos; - int ln = styler.GetLine(fw); + Sci_PositionU fw = sc.currentPos; + Sci_Position ln = styler.GetLine(fw); if (sc.atLineStart && sc.Match("=cut")) { // end of POD sc.SetState(SCE_PL_POD); sc.Forward(4); @@ -942,7 +942,7 @@ void SCI_METHOD LexerPerl::Lex(Sci_PositionU startPos, Sci_Position length, int styler.SetLineState(ln, pod); if (pod == SCE_PL_DEFAULT) { if (sc.state == SCE_PL_POD_VERB) { - unsigned int fw2 = fw; + Sci_PositionU fw2 = fw; while (fw2 < (endPos - 1) && pod == SCE_PL_DEFAULT) { fw = fw2++; // penultimate line (last blank line) pod = podLineScan(styler, fw2, endPos); @@ -1234,8 +1234,8 @@ void SCI_METHOD LexerPerl::Lex(Sci_PositionU startPos, Sci_Position length, int if (sc.chPrev == ':' && sc.GetRelative(-2) == ':') { sc.ChangeState(SCE_PL_IDENTIFIER); } - unsigned int bk = sc.currentPos; - unsigned int fw = sc.currentPos + 1; + Sci_PositionU bk = sc.currentPos; + Sci_PositionU fw = sc.currentPos + 1; // first check for possible quote-like delimiter if (sc.ch == 's' && !setWord.Contains(sc.chNext)) { sc.ChangeState(SCE_PL_REGSUBST); @@ -1341,7 +1341,7 @@ void SCI_METHOD LexerPerl::Lex(Sci_PositionU startPos, Sci_Position length, int bool preferRE = false; bool isHereDoc = sc.Match('<', '<'); bool hereDocSpace = false; // for: SCALAR [whitespace] '<<' - unsigned int bk = (sc.currentPos > 0) ? sc.currentPos - 1: 0; + Sci_PositionU bk = (sc.currentPos > 0) ? sc.currentPos - 1: 0; sc.Complete(); styler.Flush(); if (styler.StyleAt(bk) == SCE_PL_DEFAULT) @@ -1410,7 +1410,7 @@ void SCI_METHOD LexerPerl::Lex(Sci_PositionU startPos, Sci_Position length, int // keywords always forced as /PATTERN/: split, if, elsif, while // everything else /PATTERN/ unless digit/space immediately after '/' // for '//', defined-or favoured unless special keywords - unsigned int bkend = bk + 1; + Sci_PositionU bkend = bk + 1; while (bk > 0 && styler.StyleAt(bk - 1) == SCE_PL_WORD) { bk--; } @@ -1506,8 +1506,8 @@ void SCI_METHOD LexerPerl::Lex(Sci_PositionU startPos, Sci_Position length, int sc.SetState(SCE_PL_POD); backFlag = BACK_NONE; } else if (sc.ch == '-' && setWordStart.Contains(sc.chNext)) { // extended '-' cases - unsigned int bk = sc.currentPos; - unsigned int fw = 2; + Sci_PositionU bk = sc.currentPos; + Sci_PositionU fw = 2; if (setSingleCharOp.Contains(sc.chNext) && // file test operators !setWord.Contains(sc.GetRelative(2))) { sc.SetState(SCE_PL_WORD); @@ -1564,9 +1564,9 @@ void SCI_METHOD LexerPerl::Fold(Sci_PositionU startPos, Sci_Position length, int LexAccessor styler(pAccess); - unsigned int endPos = startPos + length; + Sci_PositionU endPos = startPos + length; int visibleChars = 0; - int lineCurrent = styler.GetLine(startPos); + Sci_Position lineCurrent = styler.GetLine(startPos); // Backtrack to previous line in case need to fix its fold status if (startPos > 0) { @@ -1586,7 +1586,7 @@ void SCI_METHOD LexerPerl::Fold(Sci_PositionU startPos, Sci_Position length, int // Used at end of line to determine if the line was a package definition bool isPackageLine = false; int podHeading = 0; - 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; |