mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Cosmetics.
This commit is contained in:
parent
78f863bc01
commit
76ddab24aa
9 changed files with 167 additions and 172 deletions
|
@ -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;
|
||||||
|
|
|
@ -112,7 +112,7 @@ public class MacroExpander {
|
||||||
|
|
||||||
if (fLexer != null) {
|
if (fLexer != null) {
|
||||||
t= fLexer.currentToken();
|
t= fLexer.currentToken();
|
||||||
while(t.getType() == Lexer.tNEWLINE) {
|
while (t.getType() == Lexer.tNEWLINE) {
|
||||||
t= fLexer.nextToken();
|
t= fLexer.nextToken();
|
||||||
}
|
}
|
||||||
return t.getType() == IToken.tLPAREN;
|
return t.getType() == IToken.tLPAREN;
|
||||||
|
@ -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) {
|
||||||
|
@ -342,7 +342,7 @@ public class MacroExpander {
|
||||||
|
|
||||||
private void executeScopeMarkers(TokenSource input, IdentityHashMap<PreprocessorMacro, PreprocessorMacro> forbidden) {
|
private void executeScopeMarkers(TokenSource input, IdentityHashMap<PreprocessorMacro, PreprocessorMacro> forbidden) {
|
||||||
Token t= input.removeFirst();
|
Token t= input.removeFirst();
|
||||||
while(t != null) {
|
while (t != null) {
|
||||||
if (t.getType() == CPreprocessor.tSCOPE_MARKER) {
|
if (t.getType() == CPreprocessor.tSCOPE_MARKER) {
|
||||||
((ExpansionBoundary) t).execute(forbidden);
|
((ExpansionBoundary) t).execute(forbidden);
|
||||||
}
|
}
|
||||||
|
@ -356,7 +356,7 @@ public class MacroExpander {
|
||||||
boolean protect= false;
|
boolean protect= false;
|
||||||
Token l= null;
|
Token l= null;
|
||||||
Token t= input.removeFirst();
|
Token t= input.removeFirst();
|
||||||
while(t != null) {
|
while (t != null) {
|
||||||
switch (t.getType()) {
|
switch (t.getType()) {
|
||||||
case CPreprocessor.tSCOPE_MARKER:
|
case CPreprocessor.tSCOPE_MARKER:
|
||||||
((ExpansionBoundary) t).execute(forbidden);
|
((ExpansionBoundary) t).execute(forbidden);
|
||||||
|
@ -460,7 +460,7 @@ public class MacroExpander {
|
||||||
throws OffsetLimitReachedException, AbortMacroExpansionException {
|
throws OffsetLimitReachedException, AbortMacroExpansionException {
|
||||||
final int argCount= macro.getParameterPlaceholderList().length;
|
final int argCount= macro.getParameterPlaceholderList().length;
|
||||||
final boolean hasVarargs= macro.hasVarArgs() != FunctionStyleMacro.NO_VAARGS;
|
final boolean hasVarargs= macro.hasVarArgs() != FunctionStyleMacro.NO_VAARGS;
|
||||||
final int requiredArgs= hasVarargs ? argCount-1 : argCount;
|
final int requiredArgs= hasVarargs ? argCount - 1 : argCount;
|
||||||
int idx= 0;
|
int idx= 0;
|
||||||
int nesting= -1;
|
int nesting= -1;
|
||||||
for (int i = 0; i < result.length; i++) {
|
for (int i = 0; i < result.length; i++) {
|
||||||
|
@ -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++;
|
||||||
|
@ -592,7 +592,7 @@ public class MacroExpander {
|
||||||
Token l= null;
|
Token l= null;
|
||||||
Token n;
|
Token n;
|
||||||
Token pasteArg1= null;
|
Token pasteArg1= null;
|
||||||
for (Token t= replacement.first(); t != null; l=t, t=n) {
|
for (Token t= replacement.first(); t != null; l= t, t= n) {
|
||||||
n= (Token) t.getNext();
|
n= (Token) t.getNext();
|
||||||
|
|
||||||
switch (t.getType()) {
|
switch (t.getType()) {
|
||||||
|
@ -715,7 +715,7 @@ public class MacroExpander {
|
||||||
idx= ((TokenParameterReference) nn).getIndex();
|
idx= ((TokenParameterReference) nn).getIndex();
|
||||||
|
|
||||||
// check for gcc-extension preventing the paste operation
|
// check for gcc-extension preventing the paste operation
|
||||||
if (idx == args.length-1 && macro.hasVarArgs() != FunctionStyleMacro.NO_VAARGS &&
|
if (idx == args.length - 1 && macro.hasVarArgs() != FunctionStyleMacro.NO_VAARGS &&
|
||||||
!isKind(nn.getNext(), IToken.tPOUNDPOUND)) {
|
!isKind(nn.getNext(), IToken.tPOUNDPOUND)) {
|
||||||
final Token nnn= (Token) nn.getNext();
|
final Token nnn= (Token) nn.getNext();
|
||||||
TokenList arg= clone(expandedArgs[idx]);
|
TokenList arg= clone(expandedArgs[idx]);
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Sergey Prigogin (Google) - initial API and implementation
|
* Sergey Prigogin (Google) - initial API and implementation
|
||||||
*
|
*
|
||||||
* Based on lookup3.c, by Bob Jenkins {@link "http://burtleburtle.net/bob/c/lookup3.c"}
|
* Based on lookup3.c, by Bob Jenkins {@link "http://burtleburtle.net/bob/c/lookup3.c"}
|
||||||
*
|
*
|
||||||
|
@ -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;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Markus Schorn - initial API and implementation
|
* Markus Schorn - initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.parser.scanner;
|
package org.eclipse.cdt.internal.core.parser.scanner;
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ public class Token implements IToken, Cloneable {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
final public int getLength() {
|
final public int getLength() {
|
||||||
return fEndOffset-fOffset;
|
return fEndOffset - fOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -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;
|
||||||
|
@ -73,8 +72,8 @@ public class Token implements IToken, Cloneable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void shiftOffset(int shift) {
|
public void shiftOffset(int shift) {
|
||||||
fOffset+= shift;
|
fOffset += shift;
|
||||||
fEndOffset+= shift;
|
fEndOffset += shift;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Markus Schorn - initial API and implementation
|
* Markus Schorn - initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.parser.scanner;
|
package org.eclipse.cdt.internal.core.parser.scanner;
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Markus Schorn - initial API and implementation
|
* Markus Schorn - initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.parser.scanner;
|
package org.eclipse.cdt.internal.core.parser.scanner;
|
||||||
|
|
||||||
|
@ -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,19 +41,19 @@ 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) {
|
||||||
Token t= tl.first();
|
Token t= tl.first();
|
||||||
if (t != null) {
|
if (t != null) {
|
||||||
for (Token n= (Token) t.getNext(); n != null; t=n, n= (Token) n.getNext()) {
|
for (Token n= (Token) t.getNext(); n != null; t= n, n= (Token) n.getNext()) {
|
||||||
append(t);
|
append(t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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,19 +124,20 @@ 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() {
|
||||||
return fFirst==null;
|
return fFirst == null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Markus Schorn - initial API and implementation
|
* Markus Schorn - initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.parser.scanner;
|
package org.eclipse.cdt.internal.core.parser.scanner;
|
||||||
|
|
||||||
|
@ -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
|
||||||
|
@ -156,8 +155,7 @@ public class TokenUtil {
|
||||||
IToken last;
|
IToken last;
|
||||||
do {
|
do {
|
||||||
last = tokenList;
|
last = tokenList;
|
||||||
} while((tokenList = tokenList.getNext()) != null);
|
} while ((tokenList = tokenList.getNext()) != null);
|
||||||
return last;
|
return last;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue