1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-25 18:05:33 +02:00

Cosmetics.

This commit is contained in:
Sergey Prigogin 2010-10-04 03:40:57 +00:00
parent 2aed0a778f
commit 3c2fe616f7
3 changed files with 157 additions and 163 deletions

View file

@ -59,7 +59,7 @@ public class Scanner extends SimpleScanner {
*/
public void resetTo(int start, int end) {
Reader reader;
if (end >= source.length-1) {
if (end >= source.length - 1) {
reader= new CharArrayReader(source);
} else {
reader= new CharArrayReader(source, 0, Math.min(source.length, end+1));
@ -107,7 +107,7 @@ public class Scanner extends SimpleScanner {
/**
* Move to next character iff it is equal to the given expected character.
* If the characters do not match, the sanner does not move forward.
* If the characters do not match, the scanner does not move forward.
*
* @param c the expected character
* @return <code>true</code> if the next character was the expected character
@ -138,7 +138,7 @@ public class Scanner extends SimpleScanner {
} else if (diff > fTokenBuffer.length()) {
resetTo(nextCharacterStart, source.length - 1);
} else /* if (diff <= fTokenBuffer.length()) */ {
while(diff > 0) {
while (diff > 0) {
if (fTokenBuffer.length() > 0) {
ungetChar(fTokenBuffer.charAt(fTokenBuffer.length() - 1));
}
@ -209,5 +209,4 @@ public class Scanner extends SimpleScanner {
+ "<-- Ends here\n===============================\n" //$NON-NLS-1$
+ new String(end);
}
}

View file

@ -77,9 +77,8 @@ public class SimpleScanner {
private final Token newToken(int t) {
if (!fReuseToken) {
setCurrentToken(new Token(t, fTokenBuffer.toString(), fContext));
}
else {
setCurrentToken(new Token(t, fTokenBuffer.toString(), fContext));
} else {
fCurrentToken.set(t, fTokenBuffer.toString(), fContext);
}
return fCurrentToken;
@ -94,7 +93,7 @@ public class SimpleScanner {
private int categorizePreprocessor(StringBuilder text) {
boolean skipHash= true;
int i=0;
int i= 0;
for (; i < text.length(); i++) {
char c= text.charAt(i);
if (!Character.isWhitespace(c)) {
@ -215,7 +214,7 @@ public class SimpleScanner {
internalUngetChar(c);
} else if (fUniversalCharBuffer.length() > 0) {
char[] chs = fUniversalCharBuffer.toString().toCharArray();
for (int i = chs.length-1; i >= 0; --i) {
for (int i = chs.length - 1; i >= 0; --i) {
internalUngetChar(chs[i]);
}
} else {
@ -737,7 +736,7 @@ public class SimpleScanner {
switch(c) {
case '\'':
if (fTokenBuffer.length() > 1) {
if (fPreprocessorToken==0) {
if (fPreprocessorToken == 0) {
fPreprocessorToken= categorizePreprocessor(fTokenBuffer);
}
ungetChar(c);
@ -885,7 +884,6 @@ public class SimpleScanner {
return encounteredNewline;
}
static {
fgKeywords.put("and", new Integer(Token.t_and)); //$NON-NLS-1$
fgKeywords.put("and_eq", new Integer(Token.t_and_eq)); //$NON-NLS-1$
@ -980,7 +978,5 @@ public class SimpleScanner {
fgKeywords.put("synchronized", new Integer(Token.t_synchronized)); //$NON-NLS-1$
fgKeywords.put("throws", new Integer(Token.t_throws)); //$NON-NLS-1$
fgKeywords.put("transient", new Integer(Token.t_transient)); //$NON-NLS-1$
}
}

View file

@ -61,18 +61,18 @@ public class Token {
public boolean looksLikeExpressionStart() {
switch (type) {
case tINTEGER :
case t_false :
case t_true :
case tSTRING :
case tLSTRING :
case tFLOATINGPT :
case tCHAR :
case tAMPER :
case tDOT :
case tLPAREN :
case tINTEGER:
case t_false:
case t_true:
case tSTRING:
case tLSTRING:
case tFLOATINGPT:
case tCHAR:
case tAMPER:
case tDOT:
case tLPAREN:
return true;
default :
default:
break;
}
return false;
@ -80,15 +80,15 @@ public class Token {
public boolean looksLikeExpressionEnd() {
switch (type) {
case tINTEGER :
case tSTRING :
case tLSTRING :
case tFLOATINGPT :
case tCHAR :
case tRPAREN :
case tIDENTIFIER :
case tINTEGER:
case tSTRING:
case tLSTRING:
case tFLOATINGPT:
case tCHAR:
case tRPAREN:
case tIDENTIFIER:
return true;
default :
default:
break;
}
return false;
@ -100,113 +100,113 @@ public class Token {
public boolean isOperator() {
switch (type) {
case t_new :
case t_delete :
case tPLUS :
case tMINUS :
case tSTAR :
case tDIV :
case tXOR :
case tMOD :
case tAMPER :
case tBITOR :
case tCOMPL :
case tNOT :
case tASSIGN :
case tLT :
case tGT :
case tPLUSASSIGN :
case tMINUSASSIGN :
case tSTARASSIGN :
case tDIVASSIGN :
case tMODASSIGN :
case tBITORASSIGN :
case tAMPERASSIGN :
case tXORASSIGN :
case tSHIFTL :
case tSHIFTR :
case tSHIFTLASSIGN :
case tSHIFTRASSIGN :
case tEQUAL :
case tNOTEQUAL :
case tLTEQUAL :
case tGTEQUAL :
case tAND :
case tOR :
case tINCR :
case tDECR :
case tCOMMA :
case tDOT :
case tDOTSTAR :
case tARROW :
case tARROWSTAR :
case t_new:
case t_delete:
case tPLUS:
case tMINUS:
case tSTAR:
case tDIV:
case tXOR:
case tMOD:
case tAMPER:
case tBITOR:
case tCOMPL:
case tNOT:
case tASSIGN:
case tLT:
case tGT:
case tPLUSASSIGN:
case tMINUSASSIGN:
case tSTARASSIGN:
case tDIVASSIGN:
case tMODASSIGN:
case tBITORASSIGN:
case tAMPERASSIGN:
case tXORASSIGN:
case tSHIFTL:
case tSHIFTR:
case tSHIFTLASSIGN:
case tSHIFTRASSIGN:
case tEQUAL:
case tNOTEQUAL:
case tLTEQUAL:
case tGTEQUAL:
case tAND:
case tOR:
case tINCR:
case tDECR:
case tCOMMA:
case tDOT:
case tDOTSTAR:
case tARROW:
case tARROWSTAR:
return true;
default :
default:
return false;
}
}
public boolean isInfixOperator() {
switch (type) {
case tPLUS :
case tMINUS :
case tSTAR :
case tDIV :
case tXOR :
case tMOD :
case tAMPER :
case tBITOR :
case tASSIGN :
case tLT :
case tGT :
case tPLUSASSIGN :
case tMINUSASSIGN :
case tSTARASSIGN :
case tDIVASSIGN :
case tMODASSIGN :
case tBITORASSIGN :
case tAMPERASSIGN :
case tXORASSIGN :
case tSHIFTL :
case tSHIFTR :
case tSHIFTLASSIGN :
case tSHIFTRASSIGN :
case tEQUAL :
case tNOTEQUAL :
case tLTEQUAL :
case tGTEQUAL :
case tAND :
case tOR :
case tCOLON :
case tQUESTION :
case tPLUS:
case tMINUS:
case tSTAR:
case tDIV:
case tXOR:
case tMOD:
case tAMPER:
case tBITOR:
case tASSIGN:
case tLT:
case tGT:
case tPLUSASSIGN:
case tMINUSASSIGN:
case tSTARASSIGN:
case tDIVASSIGN:
case tMODASSIGN:
case tBITORASSIGN:
case tAMPERASSIGN:
case tXORASSIGN:
case tSHIFTL:
case tSHIFTR:
case tSHIFTLASSIGN:
case tSHIFTRASSIGN:
case tEQUAL:
case tNOTEQUAL:
case tLTEQUAL:
case tGTEQUAL:
case tAND:
case tOR:
case tCOLON:
case tQUESTION:
return true;
default :
default:
return false;
}
}
public boolean isPrefixOperator() {
switch (type) {
case tPLUS :
case tMINUS :
case tSTAR :
case tAMPER :
case tCOMPL :
case tNOT :
case tINCR :
case tDECR :
case tPLUS:
case tMINUS:
case tSTAR:
case tAMPER:
case tCOMPL:
case tNOT:
case tINCR:
case tDECR:
return true;
default :
default:
return false;
}
}
public boolean isPostfixOperator() {
switch (type) {
case tINCR :
case tDECR :
case tINCR:
case tDECR:
return true;
default :
default:
return false;
}
}
@ -216,36 +216,36 @@ public class Token {
}
public static boolean isAssignmentOperator(int type) {
switch (type) {
case tASSIGN :
case tPLUSASSIGN :
case tMINUSASSIGN :
case tSTARASSIGN :
case tDIVASSIGN :
case tAMPERASSIGN :
case tBITORASSIGN :
case tXORASSIGN :
case tMODASSIGN :
case tSHIFTLASSIGN :
case tSHIFTRASSIGN :
case tASSIGN:
case tPLUSASSIGN:
case tMINUSASSIGN:
case tSTARASSIGN:
case tDIVASSIGN:
case tAMPERASSIGN:
case tBITORASSIGN:
case tXORASSIGN:
case tMODASSIGN:
case tSHIFTLASSIGN:
case tSHIFTRASSIGN:
return true;
default :
default:
return false;
}
}
public boolean isControlStmt() {
switch (type) {
case t_if :
case t_else :
case t_for :
case t_do :
case t_while :
case t_switch :
case t_try :
case t_catch :
case t_finally :
case t_if:
case t_else:
case t_for:
case t_do:
case t_while:
case t_switch:
case t_try:
case t_catch:
case t_finally:
return true;
default :
default:
return false;
}
}
@ -292,27 +292,27 @@ public class Token {
public boolean isCPPToken() {
switch (type) {
case tCOLONCOLON :
case t_class :
case t_namespace :
case t_using :
case t_template :
case t_public :
case t_protected :
case t_private :
case t_operator :
case t_virtual :
case t_inline :
case t_friend :
case t_mutable :
case t_new :
case t_delete :
case t_reinterpret_cast :
case t_dynamic_cast :
case t_static_cast :
case t_finally :
case tCOLONCOLON:
case t_class:
case t_namespace:
case t_using:
case t_template:
case t_public:
case t_protected:
case t_private:
case t_operator:
case t_virtual:
case t_inline:
case t_friend:
case t_mutable:
case t_new:
case t_delete:
case t_reinterpret_cast:
case t_dynamic_cast:
case t_static_cast:
case t_finally:
return true;
default :
default:
return false;
}
}
@ -329,7 +329,7 @@ public class Token {
// overrider
public boolean isPreprocessor() {
switch(type) {
switch (type) {
case tPREPROCESSOR:
case tPREPROCESSOR_DEFINE:
case tPREPROCESSOR_INCLUDE:
@ -340,11 +340,11 @@ public class Token {
// overrider
public boolean isIncludeDirective() {
return type==tPREPROCESSOR_INCLUDE;
return type == tPREPROCESSOR_INCLUDE;
}
// overrider
public boolean isMacroDefinition() {
return type==tPREPROCESSOR_DEFINE;
return type == tPREPROCESSOR_DEFINE;
}
// Special Token types (non-grammar tokens)
@ -506,5 +506,4 @@ public class Token {
static public final int t_byte = 214;
static public final int t_transient = 215;
static public final int t_native = 216;
}