Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Schorn2008-04-11 06:47:44 +0000
committerMarkus Schorn2008-04-11 06:47:44 +0000
commit81a7a466e948fb152b46d85641ed2bf23968649a (patch)
treeefefbd557a55f7b80a19de8362c4d0dc6e6785d4 /core/org.eclipse.cdt.core
parent7a1ab1e347d5b29f1fe041e587081ce1cd6058d0 (diff)
downloadorg.eclipse.cdt-81a7a466e948fb152b46d85641ed2bf23968649a.tar.gz
org.eclipse.cdt-81a7a466e948fb152b46d85641ed2bf23968649a.tar.xz
org.eclipse.cdt-81a7a466e948fb152b46d85641ed2bf23968649a.zip
Support for case-ranges, bug 211882.
Diffstat (limited to 'core/org.eclipse.cdt.core')
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTBinaryExpression.java36
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTBinaryExpression.java10
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/cpp/IGPPASTBinaryExpression.java11
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/GNUScannerExtensionConfiguration.java6
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/GCCKeywords.java10
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/AbstractGNUSourceCodeParser.java14
6 files changed, 72 insertions, 15 deletions
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTBinaryExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTBinaryExpression.java
index f2e045c309..c0eb4c67ee 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTBinaryExpression.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTBinaryExpression.java
@@ -10,6 +10,7 @@
*******************************************************************************/
package org.eclipse.cdt.core.dom.ast;
+
/**
* This interface represents a binary expression.
*
@@ -194,9 +195,40 @@ public interface IASTBinaryExpression extends IASTExpression {
public static final int op_notequals = 29;
/**
- * op_last is the field used in subinterfaces to start their operators at
+ * For c==, only.
+ * <code>op_pmdot</code> pointer-to-member field dereference.
+ */
+ public static final int op_pmdot = 30;
+
+ /**
+ * For c++, only.
+ * <code>op_pmarrow</code> pointer-to-member pointer dereference.
+ */
+ public static final int op_pmarrow = 31;
+
+ /**
+ * For g++, only.
+ * <code>op_max</code> represents >?
+ */
+ public static final int op_max = 32;
+
+ /**
+ * For g++, only.
+ * <code>op_min</code> represents <?
+ */
+ public static final int op_min = 33;
+
+ /**
+ * For gcc compilers, only.
+ * <code>op_ellipses</code> represents ... as used for case ranges.
+ */
+ public static final int op_ellipses= 34;
+
+ /**
+ * @deprecated all constants must be defined here, to avoid using the same value twice.
*/
- public static final int op_last = op_notequals;
+ @Deprecated
+ public static final int op_last = op_ellipses;
/**
* Get the first operand.
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTBinaryExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTBinaryExpression.java
index 964dd00991..5c225ab099 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTBinaryExpression.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTBinaryExpression.java
@@ -22,15 +22,17 @@ public interface ICPPASTBinaryExpression extends IASTBinaryExpression {
/**
* <code>op_pmdot</code> pointer-to-member field dereference.
*/
- public static final int op_pmdot = IASTBinaryExpression.op_last + 1;
+ public static final int op_pmdot = IASTBinaryExpression.op_pmdot;
/**
* <code>op_pmarrow</code> pointer-to-member pointer dereference.
*/
- public static final int op_pmarrow = IASTBinaryExpression.op_last + 2;
+ public static final int op_pmarrow = IASTBinaryExpression.op_pmarrow;
/**
- * <code>op_last</code> is defined for subinterfaces to further extend.
+ * @deprecated all constants must be defined in {@link IASTBinaryExpression}, to avoid
+ * duplicate usage of the same constant.
*/
- public static final int op_last = op_pmarrow;
+ @Deprecated
+ public static final int op_last = IASTBinaryExpression.op_last;
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/cpp/IGPPASTBinaryExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/cpp/IGPPASTBinaryExpression.java
index 7b97592569..f4edba4721 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/cpp/IGPPASTBinaryExpression.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/cpp/IGPPASTBinaryExpression.java
@@ -10,6 +10,7 @@
*******************************************************************************/
package org.eclipse.cdt.core.dom.ast.gnu.cpp;
+import org.eclipse.cdt.core.dom.ast.IASTBinaryExpression;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTBinaryExpression;
/**
@@ -22,16 +23,18 @@ public interface IGPPASTBinaryExpression extends ICPPASTBinaryExpression {
/**
* <code>op_max</code> represents >?
*/
- public static final int op_max = ICPPASTBinaryExpression.op_last + 1;
+ public static final int op_max = IASTBinaryExpression.op_max;
/**
* <code>op_min</code> represents <?
*/
- public static final int op_min = ICPPASTBinaryExpression.op_last + 2;
+ public static final int op_min = IASTBinaryExpression.op_min;
/**
- * <code>op_last</code> provided for sub-interfaces to extend.
+ * @deprecated all constants must be defined in {@link IASTBinaryExpression} to avoid
+ * using a constant twice.
*/
- public static final int op_last = op_min;
+ @Deprecated
+ public static final int op_last = IASTBinaryExpression.op_last;
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/GNUScannerExtensionConfiguration.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/GNUScannerExtensionConfiguration.java
index c727a54129..a93316e84a 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/GNUScannerExtensionConfiguration.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/GNUScannerExtensionConfiguration.java
@@ -43,17 +43,23 @@ public abstract class GNUScannerExtensionConfiguration extends AbstractScannerEx
public static void addAdditionalGNUKeywords(CharArrayIntMap target) {
target.put(GCCKeywords.cp__ALIGNOF__, IGCCToken.t___alignof__ );
+ target.put(GCCKeywords.cp__ALIGNOF__, IGCCToken.t___alignof__ );
+ target.put(GCCKeywords.cp__ASM, IToken.t_asm);
target.put(GCCKeywords.cp__ASM__, IToken.t_asm);
target.put(GCCKeywords.cp__ATTRIBUTE, IGCCToken.t__attribute__ );
target.put(GCCKeywords.cp__ATTRIBUTE__, IGCCToken.t__attribute__ );
target.put(GCCKeywords.cp__CONST, IToken.t_const);
target.put(GCCKeywords.cp__CONST__, IToken.t_const);
target.put(GCCKeywords.cp__DECLSPEC, IGCCToken.t__declspec );
+ target.put(GCCKeywords.cp__INLINE, IToken.t_inline);
target.put(GCCKeywords.cp__INLINE__, IToken.t_inline);
target.put(GCCKeywords.cp__RESTRICT, IToken.t_restrict);
target.put(GCCKeywords.cp__RESTRICT__, IToken.t_restrict);
+ target.put(GCCKeywords.cp__VOLATILE, IToken.t_volatile);
target.put(GCCKeywords.cp__VOLATILE__, IToken.t_volatile);
+ target.put(GCCKeywords.cp__SIGNED, IToken.t_signed);
target.put(GCCKeywords.cp__SIGNED__, IToken.t_signed);
+ target.put(GCCKeywords.cp__TYPEOF, IGCCToken.t_typeof);
target.put(GCCKeywords.cp__TYPEOF__, IGCCToken.t_typeof);
target.put(GCCKeywords.cpTYPEOF, IGCCToken.t_typeof );
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/GCCKeywords.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/GCCKeywords.java
index 304147916c..c39046aae1 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/GCCKeywords.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/GCCKeywords.java
@@ -27,14 +27,20 @@ public class GCCKeywords {
public static final char [] cp__ATTRIBUTE__ = __ATTRIBUTE__.toCharArray();
public static final char [] cp__DECLSPEC = __DECLSPEC.toCharArray();
+ public static final char [] cp__ALIGNOF = "__alignof".toCharArray(); //$NON-NLS-1$
public static final char [] cp__ATTRIBUTE = "__attribute".toCharArray(); //$NON-NLS-1$
+ public static final char [] cp__ASM= "__asm".toCharArray(); //$NON-NLS-1$
public static final char [] cp__ASM__= "__asm__".toCharArray(); //$NON-NLS-1$
- public static final char [] cp__CONST__= "__const__".toCharArray(); //$NON-NLS-1$
public static final char [] cp__CONST= "__const".toCharArray(); //$NON-NLS-1$
+ public static final char [] cp__CONST__= "__const__".toCharArray(); //$NON-NLS-1$
+ public static final char [] cp__INLINE= "__inline".toCharArray(); //$NON-NLS-1$
public static final char [] cp__INLINE__= "__inline__".toCharArray(); //$NON-NLS-1$
- public static final char [] cp__RESTRICT__= "__restrict__".toCharArray(); //$NON-NLS-1$
public static final char [] cp__RESTRICT= "__restrict".toCharArray(); //$NON-NLS-1$
+ public static final char [] cp__RESTRICT__= "__restrict__".toCharArray(); //$NON-NLS-1$
+ public static final char [] cp__VOLATILE= "__volatile".toCharArray(); //$NON-NLS-1$
public static final char [] cp__VOLATILE__= "__volatile__".toCharArray(); //$NON-NLS-1$
+ public static final char [] cp__SIGNED= "__signed".toCharArray(); //$NON-NLS-1$
public static final char [] cp__SIGNED__= "__signed__".toCharArray(); //$NON-NLS-1$
+ public static final char [] cp__TYPEOF= "__typeof".toCharArray(); //$NON-NLS-1$
public static final char [] cp__TYPEOF__= "__typeof__".toCharArray(); //$NON-NLS-1$
}
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 84e7aca8f7..c1e39dab15 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
@@ -1689,9 +1689,17 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
protected IASTStatement parseCaseStatement() throws EndOfFileException, BacktrackException {
int startOffset = consume().getOffset(); // t_case
- IASTExpression case_exp = constantExpression();
+ IASTExpression caseExpression = constantExpression();
+ int lt1 = LT(1);
+ if (lt1 == IToken.tELLIPSIS) {
+ consume();
+ IASTExpression upperBoundExpression= constantExpression();
+ caseExpression = buildBinaryExpression(IASTBinaryExpression.op_assign,
+ caseExpression, upperBoundExpression, calculateEndOffset(upperBoundExpression));
+ lt1= LT(1);
+ }
int lastOffset = 0;
- switch (LT(1)) {
+ switch (lt1) {
case IToken.tCOLON:
case IToken.tEOC:
lastOffset = consume().getEndOffset();
@@ -1702,7 +1710,7 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
IASTCaseStatement cs = createCaseStatement();
((ASTNode) cs).setOffsetAndLength(startOffset, lastOffset - startOffset);
- cs.setExpression(case_exp);
+ cs.setExpression(caseExpression);
return cs;
}

Back to the top