Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Kucera2008-02-05 15:40:42 +0000
committerMike Kucera2008-02-05 15:40:42 +0000
commita8f928a682fb85e879920f667b9ae3019d19ed29 (patch)
tree06d1633b68c3db48810f9033a14cac2753919487 /core/org.eclipse.cdt.core/parser
parent22f2deea941e050d0df91cfe47e33a83997447b7 (diff)
downloadorg.eclipse.cdt-a8f928a682fb85e879920f667b9ae3019d19ed29.tar.gz
org.eclipse.cdt-a8f928a682fb85e879920f667b9ae3019d19ed29.tar.xz
org.eclipse.cdt-a8f928a682fb85e879920f667b9ae3019d19ed29.zip
cleaned up the code in parseTypeIdOrUnaryExpression()
Diffstat (limited to 'core/org.eclipse.cdt.core/parser')
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/AbstractGNUSourceCodeParser.java41
1 files changed, 15 insertions, 26 deletions
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/AbstractGNUSourceCodeParser.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/AbstractGNUSourceCodeParser.java
index c15335c8b8e..a4444cec8d4 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/AbstractGNUSourceCodeParser.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/AbstractGNUSourceCodeParser.java
@@ -1938,16 +1938,14 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
throwBacktrack(token.getOffset(), token.getLength());
}
- protected IASTNode[] parseTypeIdOrUnaryExpression(
- boolean typeIdWithParentheses) throws EndOfFileException {
+ protected IASTNode[] parseTypeIdOrUnaryExpression(boolean typeIdWithParentheses) throws EndOfFileException {
return parseTypeIdOrUnaryExpression(typeIdWithParentheses, new int[1]);
}
- protected IASTNode[] parseTypeIdOrUnaryExpression(
- boolean typeIdWithParentheses, int[] endoffset) throws EndOfFileException {
+ protected IASTNode[] parseTypeIdOrUnaryExpression(boolean typeIdWithParentheses, int[] endoffset) throws EndOfFileException {
IASTTypeId typeId = null;
- IASTExpression unaryExpression = null;
- IToken typeIdLA = null, unaryExpressionLA = null;
+
+ IToken typeIdLA = null;
IToken mark = mark();
try {
if (typeIdWithParentheses)
@@ -1971,36 +1969,27 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
}
}
}
- } catch (BacktrackException e) {
- typeId = null;
- }
+ } catch (BacktrackException e) { }
backup(mark);
+
+ IToken unaryExpressionLA = null;
+ IASTExpression unaryExpression = null;
try {
- unaryExpression = unaryExpression();
+ unaryExpression = unaryExpression(); // throws BacktrackException
unaryExpressionLA = LA(1);
- } catch (BacktrackException bte) {
- unaryExpression = null;
- }
- IASTNode[] result;
+ } catch (BacktrackException bte) { }
+
if (unaryExpression == null && typeId != null) {
backup(typeIdLA);
- result = new IASTNode[1];
- result[0] = typeId;
- return result;
+ return new IASTNode[] {typeId};
}
if (unaryExpression != null && typeId == null) {
backup(unaryExpressionLA);
- result = new IASTNode[1];
- result[0] = unaryExpression;
endoffset[0]= calculateEndOffset(unaryExpression);
- return result;
+ return new IASTNode[] {unaryExpression};
}
- if (unaryExpression != null && typeId != null
- && typeIdLA == unaryExpressionLA) {
- result = new IASTNode[2];
- result[0] = typeId;
- result[1] = unaryExpression;
- return result;
+ if (unaryExpression != null && typeId != null && typeIdLA == unaryExpressionLA) {
+ return new IASTNode[] {typeId, unaryExpression};
}
return EMPTY_NODE_ARRAY;

Back to the top