aboutsummaryrefslogtreecommitdiffhomepage
path: root/lexers/LexCPP.cxx
diff options
context:
space:
mode:
authorNeil <nyamatongwe@gmail.com>2017-04-06 21:04:52 +1000
committerNeil <nyamatongwe@gmail.com>2017-04-06 21:04:52 +1000
commit31b76af68badad3cb5d65b435b27760d65a9767a (patch)
tree2bd0a4ba12815acaa0c1f45b70f72bba66152dab /lexers/LexCPP.cxx
parentcda15af9657880e91ccf65603e109b202d9e78bf (diff)
downloadscintilla-mirror-31b76af68badad3cb5d65b435b27760d65a9767a.tar.gz
Added const to some lexers.
Diffstat (limited to 'lexers/LexCPP.cxx')
-rw-r--r--lexers/LexCPP.cxx42
1 files changed, 21 insertions, 21 deletions
diff --git a/lexers/LexCPP.cxx b/lexers/LexCPP.cxx
index 777ae0c48..d08ed7eac 100644
--- a/lexers/LexCPP.cxx
+++ b/lexers/LexCPP.cxx
@@ -56,7 +56,7 @@ bool IsSpaceEquiv(int state) {
bool FollowsPostfixOperator(StyleContext &sc, LexAccessor &styler) {
Sci_Position pos = (Sci_Position) sc.currentPos;
while (--pos > 0) {
- char ch = styler[pos];
+ const char ch = styler[pos];
if (ch == '+' || ch == '-') {
return styler[pos - 1] == ch;
}
@@ -68,9 +68,9 @@ bool followsReturnKeyword(StyleContext &sc, LexAccessor &styler) {
// Don't look at styles, so no need to flush.
Sci_Position pos = (Sci_Position) sc.currentPos;
Sci_Position currentLine = styler.GetLine(pos);
- Sci_Position lineStartPos = styler.LineStart(currentLine);
+ const Sci_Position lineStartPos = styler.LineStart(currentLine);
while (--pos > lineStartPos) {
- char ch = styler.SafeGetCharAt(pos);
+ const char ch = styler.SafeGetCharAt(pos);
if (ch != ' ' && ch != '\t') {
break;
}
@@ -141,14 +141,14 @@ BracketPair FindBracketPair(std::vector<std::string> &tokens) {
}
void highlightTaskMarker(StyleContext &sc, LexAccessor &styler,
- int activity, WordList &markerList, bool caseSensitive){
+ int activity, const WordList &markerList, bool caseSensitive){
if ((isoperator(sc.chPrev) || IsASpace(sc.chPrev)) && markerList.Length()) {
const int lengthMarker = 50;
char marker[lengthMarker+1];
Sci_Position currPos = (Sci_Position) sc.currentPos;
int i = 0;
while (i < lengthMarker) {
- char ch = styler.SafeGetCharAt(currPos + i);
+ const char ch = styler.SafeGetCharAt(currPos + i);
if (IsASpace(ch) || isoperator(ch)) {
break;
}
@@ -203,9 +203,9 @@ std::string GetRestOfLine(LexAccessor &styler, Sci_Position start, bool allowSpa
std::string restOfLine;
Sci_Position i =0;
char ch = styler.SafeGetCharAt(start, '\n');
- Sci_Position endLine = styler.LineEnd(styler.GetLine(start));
+ const Sci_Position endLine = styler.LineEnd(styler.GetLine(start));
while (((start+i) < endLine) && (ch != '\r')) {
- char chNext = styler.SafeGetCharAt(start + i + 1, '\n');
+ const char chNext = styler.SafeGetCharAt(start + i + 1, '\n');
if (ch == '/' && (chNext == '/' || chNext == '*'))
break;
if (allowSpace || (ch != ' '))
@@ -526,8 +526,8 @@ public:
return subStyles.Length(styleBase);
}
int SCI_METHOD StyleFromSubStyle(int subStyle) override {
- int styleBase = subStyles.BaseStyle(MaskActive(subStyle));
- int active = subStyle & activeFlag;
+ const int styleBase = subStyles.BaseStyle(MaskActive(subStyle));
+ const int active = subStyle & activeFlag;
return styleBase | active;
}
int SCI_METHOD PrimaryStyleFromStyle(int style) override {
@@ -637,7 +637,7 @@ Sci_Position SCI_METHOD LexerCPP::WordListSet(int n, const char *wl) {
struct After {
Sci_Position line;
explicit After(Sci_Position line_) : line(line_) {}
- bool operator()(PPDefinition &p) const {
+ bool operator()(const PPDefinition &p) const {
return p.line > line;
}
};
@@ -829,7 +829,7 @@ void SCI_METHOD LexerCPP::Lex(Sci_PositionU startPos, Sci_Position length, int i
const bool raw = literalString && sc.chPrev == 'R' && !setInvalidRawFirst.Contains(sc.chNext);
if (raw)
s[lenS--] = '\0';
- bool valid =
+ const bool valid =
(lenS == 0) ||
((lenS == 1) && ((s[0] == 'L') || (s[0] == 'u') || (s[0] == 'U'))) ||
((lenS == 2) && literalString && (s[0] == 'u') && (s[1] == '8'));
@@ -1198,7 +1198,7 @@ void SCI_METHOD LexerCPP::Lex(Sci_PositionU startPos, Sci_Position length, int i
if (!preproc.CurrentIfTaken()) {
// Similar to #if
std::string restOfLine = GetRestOfLine(styler, sc.currentPos + 2, true);
- bool ifGood = EvaluateExpression(restOfLine, preprocessorDefinitions);
+ const bool ifGood = EvaluateExpression(restOfLine, preprocessorDefinitions);
if (ifGood) {
preproc.InvertCurrentLevel();
activitySet = preproc.IsInactive() ? activeFlag : 0;
@@ -1294,7 +1294,7 @@ void SCI_METHOD LexerCPP::Fold(Sci_PositionU startPos, Sci_Position length, int
LexAccessor styler(pAccess);
- Sci_PositionU endPos = startPos + length;
+ const Sci_PositionU endPos = startPos + length;
int visibleChars = 0;
bool inLineComment = false;
Sci_Position lineCurrent = styler.GetLine(startPos);
@@ -1309,12 +1309,12 @@ void SCI_METHOD LexerCPP::Fold(Sci_PositionU startPos, Sci_Position length, int
int style = MaskActive(initStyle);
const bool userDefinedFoldMarkers = !options.foldExplicitStart.empty() && !options.foldExplicitEnd.empty();
for (Sci_PositionU i = startPos; i < endPos; i++) {
- char ch = chNext;
+ const char ch = chNext;
chNext = styler.SafeGetCharAt(i + 1);
- int stylePrev = style;
+ const int stylePrev = style;
style = styleNext;
styleNext = MaskActive(styler.StyleAt(i + 1));
- bool atEOL = i == (lineStartNext-1);
+ const bool atEOL = i == (lineStartNext-1);
if ((style == SCE_C_COMMENTLINE) || (style == SCE_C_COMMENTLINEDOC))
inLineComment = true;
if (options.foldComment && options.foldCommentMultiline && IsStreamCommentStyle(style) && !inLineComment) {
@@ -1334,7 +1334,7 @@ void SCI_METHOD LexerCPP::Fold(Sci_PositionU startPos, Sci_Position length, int
}
} else {
if ((ch == '/') && (chNext == '/')) {
- char chNext2 = styler.SafeGetCharAt(i + 2);
+ const char chNext2 = styler.SafeGetCharAt(i + 2);
if (chNext2 == '{') {
levelNext++;
} else if (chNext2 == '}') {
@@ -1537,14 +1537,14 @@ void LexerCPP::EvaluateTokens(std::vector<std::string> &tokens, const SymbolTabl
for (int prec=precArithmetic; prec <= precLogical; prec++) {
// Looking at 3 tokens at a time so end at 2 before end
for (size_t k=0; (k+2)<tokens.size();) {
- char chOp = tokens[k+1][0];
+ const char chOp = tokens[k+1][0];
if (
((prec==precArithmetic) && setArithmethicOp.Contains(chOp)) ||
((prec==precRelative) && setRelOp.Contains(chOp)) ||
((prec==precLogical) && setLogicalOp.Contains(chOp))
) {
- int valA = atoi(tokens[k].c_str());
- int valB = atoi(tokens[k+2].c_str());
+ const int valA = atoi(tokens[k].c_str());
+ const int valB = atoi(tokens[k+2].c_str());
int result = 0;
if (tokens[k+1] == "+")
result = valA + valB;
@@ -1631,7 +1631,7 @@ bool LexerCPP::EvaluateExpression(const std::string &expr, const SymbolTable &pr
EvaluateTokens(tokens, preprocessorDefinitions);
// "0" or "" -> false else true
- bool isFalse = tokens.empty() ||
+ const bool isFalse = tokens.empty() ||
((tokens.size() == 1) && ((tokens[0] == "") || tokens[0] == "0"));
return !isFalse;
}