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 2013-01-15 16:58:33 -08:00
parent 23a2d90279
commit 93619fcb12
2 changed files with 36 additions and 34 deletions

View file

@ -1,12 +1,13 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2007, 2009 Wind River Systems, Inc. and others. * Copyright (c) 2007, 2013 Wind River Systems, Inc. and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* 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
* Sergey Prigogin (Google)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.core.parser.tests.scanner; package org.eclipse.cdt.core.parser.tests.scanner;

View file

@ -1,13 +1,14 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2007, 2010 Wind River Systems, Inc. and others. * Copyright (c) 2007, 2013 Wind River Systems, Inc. and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* 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
* Mike Kucera (IBM) - UTF string literals * Mike Kucera (IBM) - UTF string literals
* Sergey Prigogin (Google)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.parser.scanner; package org.eclipse.cdt.internal.core.parser.scanner;
@ -195,7 +196,7 @@ final public class Lexer implements ITokenSequence {
Token t= fToken; Token t= fToken;
Token lt= null; Token lt= null;
while (true) { while (true) {
switch(t.getType()) { switch (t.getType()) {
case IToken.tCOMPLETION: case IToken.tCOMPLETION:
if (lt != null) { if (lt != null) {
fLastToken= lt; fLastToken= lt;
@ -228,7 +229,7 @@ final public class Lexer implements ITokenSequence {
public Token nextDirective() throws OffsetLimitReachedException { public Token nextDirective() throws OffsetLimitReachedException {
Token t0; Token t0;
Token t1= fToken; Token t1= fToken;
for(;;) { for (;;) {
t0= t1; t0= t1;
t1= fetchToken(); t1= fetchToken();
final int tt1 = t1.getType(); final int tt1 = t1.getType();
@ -252,7 +253,7 @@ final public class Lexer implements ITokenSequence {
final int start= fOffset; final int start= fOffset;
final int c= fCharPhase3; final int c= fCharPhase3;
final int d= nextCharPhase3(); final int d= nextCharPhase3();
switch(c) { switch (c) {
case END_OF_INPUT: case END_OF_INPUT:
return newToken(IToken.tEND_OF_INPUT, start); return newToken(IToken.tEND_OF_INPUT, start);
case '\n': case '\n':
@ -266,7 +267,7 @@ final public class Lexer implements ITokenSequence {
continue; continue;
case 'L': case 'L':
switch(d) { switch (d) {
case 'R': case 'R':
if (fOptions.fSupportRawStringLiterals) { if (fOptions.fSupportRawStringLiterals) {
markPhase3(); markPhase3();
@ -289,7 +290,7 @@ final public class Lexer implements ITokenSequence {
case 'u': case 'u':
case 'U': case 'U':
if (fOptions.fSupportUTFLiterals) { if (fOptions.fSupportUTFLiterals) {
switch(d) { switch (d) {
case 'R': case 'R':
if (fOptions.fSupportRawStringLiterals) { if (fOptions.fSupportRawStringLiterals) {
markPhase3(); markPhase3();
@ -364,7 +365,7 @@ final public class Lexer implements ITokenSequence {
break; break;
case '\\': case '\\':
switch(d) { switch (d) {
case 'u': case 'U': case 'u': case 'U':
nextCharPhase3(); nextCharPhase3();
return identifier(start, 2); return identifier(start, 2);
@ -376,7 +377,7 @@ final public class Lexer implements ITokenSequence {
return number(start, 1, false); return number(start, 1, false);
case '.': case '.':
switch(d) { switch (d) {
case '0': case '1': case '2': case '3': case '4': case '0': case '1': case '2': case '3': case '4':
case '5': case '6': case '7': case '8': case '9': case '5': case '6': case '7': case '8': case '9':
nextCharPhase3(); nextCharPhase3();
@ -420,7 +421,7 @@ final public class Lexer implements ITokenSequence {
return newToken(IToken.tSEMI, start); return newToken(IToken.tSEMI, start);
case ':': case ':':
switch(d) { switch (d) {
case ':': case ':':
nextCharPhase3(); nextCharPhase3();
return newToken(IToken.tCOLONCOLON, start); return newToken(IToken.tCOLONCOLON, start);
@ -564,7 +565,7 @@ final public class Lexer implements ITokenSequence {
return headerName(start, false); return headerName(start, false);
} }
switch(d) { switch (d) {
case '=': case '=':
nextCharPhase3(); nextCharPhase3();
return newToken(IToken.tLTEQUAL, start); return newToken(IToken.tLTEQUAL, start);
@ -602,7 +603,7 @@ final public class Lexer implements ITokenSequence {
return newToken(IToken.tLT, start); return newToken(IToken.tLT, start);
case '>': case '>':
switch(d) { switch (d) {
case '=': case '=':
nextCharPhase3(); nextCharPhase3();
return newToken(IToken.tGTEQUAL, start); return newToken(IToken.tGTEQUAL, start);
@ -647,7 +648,7 @@ final public class Lexer implements ITokenSequence {
private Token newToken(final int kind, final int offset, final int imageLength) { private Token newToken(final int kind, final int offset, final int imageLength) {
final int endOffset= fOffset; final int endOffset= fOffset;
final int sourceLen= endOffset-offset; final int sourceLen= endOffset - offset;
char[] image; char[] image;
if (sourceLen != imageLength) { if (sourceLen != imageLength) {
image= getCharImage(offset, endOffset, imageLength); image= getCharImage(offset, endOffset, imageLength);
@ -730,7 +731,7 @@ final public class Lexer implements ITokenSequence {
int c= fCharPhase3; int c= fCharPhase3;
loop: while (!done) { loop: while (!done) {
switch(c) { switch (c) {
case END_OF_INPUT: case END_OF_INPUT:
if (fSupportContentAssist) { if (fSupportContentAssist) {
throw new OffsetLimitReachedException(ORIGIN_LEXER, newToken(tokenType, start, length)); throw new OffsetLimitReachedException(ORIGIN_LEXER, newToken(tokenType, start, length));
@ -763,7 +764,7 @@ final public class Lexer implements ITokenSequence {
final int delimOffset= fOffset; final int delimOffset= fOffset;
int delimEndOffset = delimOffset; int delimEndOffset = delimOffset;
int offset; int offset;
for(;; delimEndOffset++) { for (;; delimEndOffset++) {
if (!fInput.isValidOffset(delimEndOffset)) { if (!fInput.isValidOffset(delimEndOffset)) {
offset= delimEndOffset; offset= delimEndOffset;
break; break;
@ -774,8 +775,8 @@ final public class Lexer implements ITokenSequence {
} }
} }
final int delimLength= delimEndOffset-delimOffset; final int delimLength= delimEndOffset - delimOffset;
for(;; offset++) { for (;; offset++) {
if (!fInput.isValidOffset(offset)) { if (!fInput.isValidOffset(offset)) {
handleProblem(IProblem.SCANNER_UNBOUNDED_STRING, getInputChars(start, offset), start); handleProblem(IProblem.SCANNER_UNBOUNDED_STRING, getInputChars(start, offset), start);
break; break;
@ -799,11 +800,11 @@ final public class Lexer implements ITokenSequence {
} }
} }
} }
fOffset= offset-1; fOffset= offset - 1;
fEndOffset= offset; fEndOffset= offset;
fCharPhase3= 0; fCharPhase3= 0;
nextCharPhase3(); nextCharPhase3();
return newToken(tokenType, start, offset-start); return newToken(tokenType, start, offset - start);
} }
private Token charLiteral(final int start, final int tokenType) throws OffsetLimitReachedException { private Token charLiteral(final int start, final int tokenType) throws OffsetLimitReachedException {
@ -813,7 +814,7 @@ final public class Lexer implements ITokenSequence {
int c= fCharPhase3; int c= fCharPhase3;
loop: while (!done) { loop: while (!done) {
switch(c) { switch (c) {
case END_OF_INPUT: case END_OF_INPUT:
if (fSupportContentAssist) { if (fSupportContentAssist) {
throw new OffsetLimitReachedException(ORIGIN_LEXER, newToken(tokenType, start, length)); throw new OffsetLimitReachedException(ORIGIN_LEXER, newToken(tokenType, start, length));
@ -846,7 +847,7 @@ final public class Lexer implements ITokenSequence {
boolean isPartOfIdentifier= true; boolean isPartOfIdentifier= true;
int c= fCharPhase3; int c= fCharPhase3;
while (true) { while (true) {
switch(c) { switch (c) {
case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i':
case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r':
case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z':
@ -860,7 +861,7 @@ final public class Lexer implements ITokenSequence {
case '\\': // universal character name case '\\': // universal character name
markPhase3(); markPhase3();
switch(nextCharPhase3()) { switch (nextCharPhase3()) {
case 'u': case 'U': case 'u': case 'U':
length++; length++;
break; break;
@ -915,7 +916,7 @@ final public class Lexer implements ITokenSequence {
boolean isHex= false; boolean isHex= false;
int c= fCharPhase3; int c= fCharPhase3;
while (true) { while (true) {
switch(c) { switch (c) {
// non-digit // non-digit
case 'a': case 'b': case 'c': case 'd': case 'f': case 'g': case 'h': case 'i': case 'a': case 'b': case 'c': case 'd': case 'f': case 'g': case 'h': case 'i':
case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'q': case 'r': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'q': case 'r':
@ -963,7 +964,7 @@ final public class Lexer implements ITokenSequence {
// universal character name (non-digit) // universal character name (non-digit)
case '\\': case '\\':
markPhase3(); markPhase3();
switch(nextCharPhase3()) { switch (nextCharPhase3()) {
case 'u': case 'U': case 'u': case 'U':
length++; length++;
break; break;
@ -1024,7 +1025,7 @@ final public class Lexer implements ITokenSequence {
private int nextCharPhase3() { private int nextCharPhase3() {
int pos= fEndOffset; int pos= fEndOffset;
do { do {
if (!isValidOffset(pos+1)) { if (!isValidOffset(pos + 1)) {
if (!isValidOffset(pos)) { if (!isValidOffset(pos)) {
fOffset= pos; fOffset= pos;
fEndOffset= pos; fEndOffset= pos;
@ -1032,7 +1033,7 @@ final public class Lexer implements ITokenSequence {
return END_OF_INPUT; return END_OF_INPUT;
} }
fOffset= pos; fOffset= pos;
fEndOffset= pos+1; fEndOffset= pos + 1;
fCharPhase3= fInput.get(pos); fCharPhase3= fInput.get(pos);
return fCharPhase3; return fCharPhase3;
} }
@ -1041,7 +1042,7 @@ final public class Lexer implements ITokenSequence {
fOffset= pos; fOffset= pos;
fEndOffset= ++pos; fEndOffset= ++pos;
fCharPhase3= c; fCharPhase3= c;
switch(c) { switch (c) {
// windows line-ending // windows line-ending
case '\r': case '\r':
if (fInput.get(pos) == '\n') { if (fInput.get(pos) == '\n') {
@ -1091,7 +1092,7 @@ final public class Lexer implements ITokenSequence {
* @return the character encoded or 0. * @return the character encoded or 0.
*/ */
private char checkTrigraph(char c) { private char checkTrigraph(char c) {
switch(c) { switch (c) {
case '=': return '#'; case '=': return '#';
case '\'':return '^'; case '\'':return '^';
case '(': return '['; case '(': return '[';
@ -1112,7 +1113,7 @@ final public class Lexer implements ITokenSequence {
boolean haveBackslash= true; boolean haveBackslash= true;
int result= -1; int result= -1;
loop: while (isValidOffset(pos)) { loop: while (isValidOffset(pos)) {
switch(fInput.get(pos++)) { switch (fInput.get(pos++)) {
case '\n': case '\n':
if (haveBackslash) { if (haveBackslash) {
result= pos; result= pos;
@ -1151,7 +1152,7 @@ final public class Lexer implements ITokenSequence {
* Returns the image from the input without any modification. * Returns the image from the input without any modification.
*/ */
public char[] getInputChars(int offset, int endOffset) { public char[] getInputChars(int offset, int endOffset) {
final int length= endOffset-offset; final int length= endOffset - offset;
if (length <= 0) { if (length <= 0) {
return CharArrayUtils.EMPTY; return CharArrayUtils.EMPTY;
} }
@ -1171,7 +1172,7 @@ final public class Lexer implements ITokenSequence {
final char[] result= new char[imageLength]; final char[] result= new char[imageLength];
markPhase3(); markPhase3();
fEndOffset= offset; fEndOffset= offset;
for (int idx=0; idx<imageLength; idx++) { for (int idx= 0; idx < imageLength; idx++) {
result[idx]= (char) nextCharPhase3(); result[idx]= (char) nextCharPhase3();
} }
restorePhase3(); restorePhase3();