1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Cosmetics.

This commit is contained in:
Sergey Prigogin 2012-12-31 16:34:48 -08:00
parent 78f863bc01
commit 76ddab24aa
9 changed files with 167 additions and 172 deletions

View file

@ -266,18 +266,16 @@ public class MacroDefinitionParser {
break loop; break loop;
case IToken.tIDENTIFIER: case IToken.tIDENTIFIER:
if (paramList != null) { if (paramList != null) {
// convert the parameters to special tokens // Convert the parameters to special tokens.
final char[] image = candidate.getCharImage(); final char[] image = candidate.getCharImage();
int idx= CharArrayUtils.indexOf(image, paramList); int idx= CharArrayUtils.indexOf(image, paramList);
if (idx >= 0) { if (idx >= 0) {
candidate= new TokenParameterReference(CPreprocessor.tMACRO_PARAMETER, idx, lexer.getSource(), candidate.getOffset(), candidate.getEndOffset(), paramList[idx]); candidate= new TokenParameterReference(CPreprocessor.tMACRO_PARAMETER, idx, lexer.getSource(), candidate.getOffset(), candidate.getEndOffset(), paramList[idx]);
needParam= false; needParam= false;
} } else {
else {
if (needParam) { if (needParam) {
log.handleProblem(IProblem.PREPROCESSOR_MACRO_PASTING_ERROR, name, fExpansionOffset, candidate.getEndOffset()); log.handleProblem(IProblem.PREPROCESSOR_MACRO_PASTING_ERROR, name, fExpansionOffset, candidate.getEndOffset());
} } else if (CharArrayUtils.equals(Keywords.cVA_ARGS, image)) {
else if (CharArrayUtils.equals(Keywords.cVA_ARGS, image)) {
log.handleProblem(IProblem.PREPROCESSOR_INVALID_VA_ARGS, null, fExpansionOffset, candidate.getEndOffset()); log.handleProblem(IProblem.PREPROCESSOR_INVALID_VA_ARGS, null, fExpansionOffset, candidate.getEndOffset());
} }
needParam= false; needParam= false;

View file

@ -271,7 +271,7 @@ public class MacroExpander {
try { try {
lastConsumed= parseArguments(input, (FunctionStyleMacro) macro, forbidden, argInputs, tracker); lastConsumed= parseArguments(input, (FunctionStyleMacro) macro, forbidden, argInputs, tracker);
} catch (AbortMacroExpansionException e) { } catch (AbortMacroExpansionException e) {
// ignore this macro expansion // Ignore this macro expansion.
for (TokenSource argInput : argInputs) { for (TokenSource argInput : argInputs) {
executeScopeMarkers(argInput, forbidden); executeScopeMarkers(argInput, forbidden);
if (tracker != null) { if (tracker != null) {
@ -514,7 +514,7 @@ public class MacroExpander {
continue loop; continue loop;
case IToken.tLPAREN: case IToken.tLPAREN:
// the first one sets nesting to zero. // The first one sets nesting to zero.
if (++nesting == 0) { if (++nesting == 0) {
continue; continue;
} }
@ -530,7 +530,7 @@ public class MacroExpander {
case IToken.tCOMMA: case IToken.tCOMMA:
assert nesting >= 0; assert nesting >= 0;
if (nesting == 0) { if (nesting == 0) {
if (idx < argCount-1) { // next argument if (idx < argCount - 1) { // Next argument.
isFirstOfArg= true; isFirstOfArg= true;
spaceMarkers.clear(); spaceMarkers.clear();
idx++; idx++;

View file

@ -44,7 +44,6 @@
* mixing with 12*3 instructions on 3 integers than you can with 3 instructions * mixing with 12*3 instructions on 3 integers than you can with 3 instructions
* on 1 byte), but shoehorning those bytes into integers efficiently is messy. * on 1 byte), but shoehorning those bytes into integers efficiently is messy.
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.parser.scanner; package org.eclipse.cdt.internal.core.parser.scanner;
/** /**

View file

@ -56,7 +56,6 @@ public class Token implements IToken, Cloneable {
return fNextToken; return fNextToken;
} }
@Override @Override
final public void setType(int kind) { final public void setType(int kind) {
fKind= kind; fKind= kind;

View file

@ -17,7 +17,8 @@ class TokenList {
final Token removeFirst() { final Token removeFirst() {
final Token first= fFirst; final Token first= fFirst;
if (first == fLast) { if (first == fLast) {
fFirst= fLast= null; fFirst= null;
fLast= null;
return first; return first;
} }
fFirst= (Token) first.getNext(); fFirst= (Token) first.getNext();
@ -26,9 +27,9 @@ class TokenList {
public final void append(Token t) { public final void append(Token t) {
if (fFirst == null) { if (fFirst == null) {
fFirst= fLast= t; fFirst= t;
} fLast= t;
else { } else {
fLast.setNext(t); fLast.setNext(t);
fLast= t; fLast= t;
} }
@ -40,13 +41,13 @@ class TokenList {
if (t != null) { if (t != null) {
if (fFirst == null) { if (fFirst == null) {
fFirst= tl.fFirst; fFirst= tl.fFirst;
} } else {
else {
fLast.setNext(tl.fFirst); fLast.setNext(tl.fFirst);
} }
fLast= tl.fLast; fLast= tl.fLast;
} }
tl.fFirst= tl.fLast= null; tl.fFirst= null;
tl.fLast= null;
} }
public final void appendAllButLast(TokenList tl) { public final void appendAllButLast(TokenList tl) {
@ -110,8 +111,7 @@ class TokenList {
fLast= null; fLast= null;
} }
} }
} } else {
else {
final Token r= (Token) l.getNext(); final Token r= (Token) l.getNext();
if (r != null) { if (r != null) {
l.setNext(r.getNext()); l.setNext(r.getNext());
@ -124,16 +124,17 @@ class TokenList {
void cutAfter(Token l) { void cutAfter(Token l) {
if (l == null) { if (l == null) {
fFirst= fLast= null; fFirst= null;
} fLast= null;
else { } else {
l.setNext(null); l.setNext(null);
fLast= l; fLast= l;
} }
} }
public void clear() { public void clear() {
fFirst= fLast= null; fFirst= null;
fLast= null;
} }
public boolean isEmpty() { public boolean isEmpty() {

View file

@ -147,7 +147,6 @@ public class TokenUtil {
} }
} }
/** /**
* Returns the last token in the given token list. * Returns the last token in the given token list.
* @throws NullPointerException if the argument is null * @throws NullPointerException if the argument is null
@ -159,5 +158,4 @@ public class TokenUtil {
} while ((tokenList = tokenList.getNext()) != null); } while ((tokenList = tokenList.getNext()) != null);
return last; return last;
} }
} }