[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[cdt-patch] Core/Parser to fix NPE in the parsers(struct, union, typedef)
|
====================================
Patch from John Camelon
=====================================
Index: dom/org/eclipse/cdt/internal/core/dom/DOMBuilder.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/dom/org/eclipse/cdt/internal/core/dom/DOMBuilder.java,v
retrieving revision 1.11
diff -u -r1.11 DOMBuilder.java
--- dom/org/eclipse/cdt/internal/core/dom/DOMBuilder.java 31 Mar 2003 21:04:30 -0000 1.11
+++ dom/org/eclipse/cdt/internal/core/dom/DOMBuilder.java 1 Apr 2003 16:11:39 -0000
@@ -600,7 +600,7 @@
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#enumSpecifierBegin(java.lang.Object)
*/
- public Object enumSpecifierBegin(Object container) {
+ public Object enumSpecifierBegin(Object container, Token enumKey) {
SimpleDeclaration decl = (SimpleDeclaration)container;
EnumerationSpecifier es = new EnumerationSpecifier( decl );
decl.setTypeSpecifier(es);
Index: model/org/eclipse/cdt/internal/core/model/CElement.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CElement.java,v
retrieving revision 1.8
diff -u -r1.8 CElement.java
--- model/org/eclipse/cdt/internal/core/model/CElement.java 31 Mar 2003 03:46:57 -0000 1.8
+++ model/org/eclipse/cdt/internal/core/model/CElement.java 1 Apr 2003 16:11:41 -0000
@@ -179,6 +179,10 @@
return true;
if (o instanceof CElement) {
CElement other = (CElement) o;
+ if( fName == null || other.fName == null )
+ return false;
+ if( fName.length() == 0 || other.fName.length() == 0 )
+ return false;
if (fType != other.fType)
return false;
if (other.fName != null && fName.equals(other.fName)) {
Index: parser/ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/parser/ChangeLog,v
retrieving revision 1.14
diff -u -r1.14 ChangeLog
--- parser/ChangeLog 31 Mar 2003 21:04:30 -0000 1.14
+++ parser/ChangeLog 1 Apr 2003 16:11:42 -0000
@@ -1,3 +1,10 @@
+2003-03-31 John Camelon
+ Fixed unsigned short SimpleDeclarations not showing up in the outline view.
+ Fixed default visibilities for structs in outline view.
+ Fixed bug35892.
+ Added icon-less typedefs and enums to the outline view.
+ Fixed NPEs relating to anonymous structs, unions, enums in outline view.
+
2003-03-31 Andrew Niefer
Parser Symbol Table, better support for function resolution with pointers and
references as parameters. Also support for typedefs as function parameters
Index: parser/org/eclipse/cdt/internal/core/model/EnumerationWrapper.java
===================================================================
RCS file: parser/org/eclipse/cdt/internal/core/model/EnumerationWrapper.java
diff -N parser/org/eclipse/cdt/internal/core/model/EnumerationWrapper.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ parser/org/eclipse/cdt/internal/core/model/EnumerationWrapper.java 1 Apr 2003 16:11:42 -0000
@@ -0,0 +1,82 @@
+/**********************************************************************
+ * Created on Apr 1, 2003
+ *
+ * Copyright (c) 2002,2003 Rational Software Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v0.5
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v05.html
+ *
+ * Contributors:
+ * Rational Software - Initial API and implementation
+***********************************************************************/
+package org.eclipse.cdt.internal.core.model;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.cdt.core.model.IParent;
+import org.eclipse.cdt.internal.core.parser.Token;
+import org.eclipse.cdt.internal.core.parser.util.Name;
+
+/**
+ * @author jcamelon
+ *
+ */
+public class EnumerationWrapper {
+
+ private Name name;
+ private List enumerators = new ArrayList();
+ private final IParent parent;
+ private final Token key;
+
+ public EnumerationWrapper( IParent incoming, Token enumKey )
+ {
+ this.parent= incoming;
+ key = enumKey;
+ }
+
+ /**
+ * @return Name
+ */
+ public Name getName() {
+ return name;
+ }
+
+ /**
+ * Sets the name.
+ * @param name The name to set
+ */
+ public void setName(Name name) {
+ this.name = name;
+ }
+
+
+
+ /**
+ * @return List
+ */
+ public List getEnumerators() {
+ return enumerators;
+ }
+
+ public void addEnumerator( EnumeratorWrapper in )
+ {
+ enumerators.add( in );
+ }
+
+ /**
+ * @return ICElementWrapper
+ */
+ public IParent getParent() {
+ return parent;
+ }
+
+ /**
+ * @return Token
+ */
+ public Token getClassKind() {
+ return key;
+ }
+
+}
Index: parser/org/eclipse/cdt/internal/core/model/EnumeratorWrapper.java
===================================================================
RCS file: parser/org/eclipse/cdt/internal/core/model/EnumeratorWrapper.java
diff -N parser/org/eclipse/cdt/internal/core/model/EnumeratorWrapper.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ parser/org/eclipse/cdt/internal/core/model/EnumeratorWrapper.java 1 Apr 2003 16:11:42 -0000
@@ -0,0 +1,53 @@
+/**********************************************************************
+ * Created on Apr 1, 2003
+ *
+ * Copyright (c) 2002,2003 Rational Software Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v0.5
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v05.html
+ *
+ * Contributors:
+ * Rational Software - Initial API and implementation
+***********************************************************************/
+package org.eclipse.cdt.internal.core.model;
+
+import org.eclipse.cdt.internal.core.parser.util.Name;
+
+/**
+ * @author jcamelon
+ *
+ */
+public class EnumeratorWrapper {
+
+ private final EnumerationWrapper parent;
+ private Name name;
+
+ EnumeratorWrapper( EnumerationWrapper myParent )
+ {
+ this.parent = myParent;
+ }
+
+ /**
+ * @return Name
+ */
+ public Name getName() {
+ return name;
+ }
+
+ /**
+ * @return EnumerationWrapper
+ */
+ public EnumerationWrapper getParent() {
+ return parent;
+ }
+
+ /**
+ * Sets the name.
+ * @param name The name to set
+ */
+ public void setName(Name name) {
+ this.name = name;
+ }
+
+}
Index: parser/org/eclipse/cdt/internal/core/model/ICElementWrapper.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/model/ICElementWrapper.java,v
retrieving revision 1.2
diff -u -r1.2 ICElementWrapper.java
--- parser/org/eclipse/cdt/internal/core/model/ICElementWrapper.java 4 Mar 2003 18:25:40 -0000 1.2
+++ parser/org/eclipse/cdt/internal/core/model/ICElementWrapper.java 1 Apr 2003 16:11:42 -0000
@@ -1,5 +1,7 @@
package org.eclipse.cdt.internal.core.model;
+import org.eclipse.cdt.core.model.IParent;
+
/**
* @author jcamelon
*
@@ -10,6 +12,6 @@
*/
public interface ICElementWrapper {
- public CElement getElement();
- public void setElement (CElement item);
+ public IParent getElement();
+ public void setElement (IParent item);
}
Index: parser/org/eclipse/cdt/internal/core/model/NewModelBuilder.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/model/NewModelBuilder.java,v
retrieving revision 1.14
diff -u -r1.14 NewModelBuilder.java
--- parser/org/eclipse/cdt/internal/core/model/NewModelBuilder.java 31 Mar 2003 21:04:30 -0000 1.14
+++ parser/org/eclipse/cdt/internal/core/model/NewModelBuilder.java 1 Apr 2003 16:11:43 -0000
@@ -10,6 +10,7 @@
******************************************************************************/
package org.eclipse.cdt.internal.core.model;
+import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
@@ -44,20 +45,20 @@
{
SimpleDeclarationWrapper c = (SimpleDeclarationWrapper)container;
- int kind;
- switch (classKey.getType()) {
+ SimpleDeclarationWrapper wrapper = new SimpleDeclarationWrapper();
+ wrapper.setClassKind( classKey );
+ switch( classKey.getType() )
+ {
case Token.t_class:
- kind = ICElement.C_CLASS;
+ wrapper.setCurrentVisibility( AccessSpecifier.v_private );
break;
case Token.t_struct:
- kind = ICElement.C_STRUCT;
+ case Token.t_union:
+ wrapper.setCurrentVisibility( AccessSpecifier.v_public );
break;
- default:
- kind = ICElement.C_UNION;
}
- SimpleDeclarationWrapper wrapper = new SimpleDeclarationWrapper();
- wrapper.setKind( kind );
+
wrapper.setParent( c.getParent() );
return wrapper;
@@ -138,7 +139,7 @@
Object parent = wrapper.getElement();
SimpleDeclarationWrapper result = new SimpleDeclarationWrapper();
if( wrapper instanceof SimpleDeclarationWrapper ){
- result.setParent( (CElement)wrapper.getElement() );
+ result.setParent( wrapper.getElement() );
result.setCurrentVisibility(((SimpleDeclarationWrapper)wrapper).getCurrentVisibility());
} else if ( wrapper instanceof TranslationUnitWrapper )
result.setParent( (TranslationUnit)wrapper.getElement());
@@ -331,13 +332,36 @@
*/
public void classSpecifierSafe(Object classSpecifier) {
SimpleDeclarationWrapper wrapper = (SimpleDeclarationWrapper)classSpecifier;
- Structure elem = new Structure( wrapper.getParent(), wrapper.getKind(), null );
+ int kind;
+
+ switch( wrapper.getClassKind().getType() )
+ {
+ case Token.t_class:
+ kind = ICElement.C_CLASS;
+ break;
+ case Token.t_struct:
+ kind = ICElement.C_STRUCT;
+ break;
+ default:
+ kind = ICElement.C_UNION;
+ break;
+ }
+ Structure elem = new Structure( (CElement)wrapper.getParent(), kind, null );
wrapper.setElement( elem );
- wrapper.getParent().addChild(elem);
- String name = wrapper.getName().toString();
- elem.setElementName( name );
- elem.setIdPos(wrapper.getName().getStartOffset(), name.length());
- elem.setPos(wrapper.getName().getStartOffset(), name.length());
+ ((Parent)wrapper.getParent()).addChild(elem);
+
+ String elementName = ( wrapper.getName() == null ) ? "" : wrapper.getName().toString();
+ elem.setElementName( elementName );
+ if( wrapper.getName() != null )
+ {
+ elem.setIdPos(wrapper.getName().getStartOffset(), elementName.length());
+ elem.setPos(wrapper.getName().getStartOffset(), elementName.length());
+ }
+ else
+ {
+ elem.setIdPos(wrapper.getClassKind().getOffset(), wrapper.getClassKind().getLength());
+ elem.setPos(wrapper.getClassKind().getOffset(), wrapper.getClassKind().getLength());
+ }
}
/**
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#elaboratedTypeSpecifierBegin(java.lang.Object)
@@ -346,21 +370,9 @@
if( container instanceof SimpleDeclarationWrapper )
{
SimpleDeclarationWrapper c = (SimpleDeclarationWrapper)container;
-
- int kind;
- switch (classKey.getType()) {
- case Token.t_class:
- kind = ICElement.C_CLASS;
- break;
- case Token.t_struct:
- kind = ICElement.C_STRUCT;
- break;
- default:
- kind = ICElement.C_UNION;
- }
-
+
SimpleDeclarationWrapper wrapper = new SimpleDeclarationWrapper();
- wrapper.setKind( kind );
+ wrapper.setClassKind( classKey );
wrapper.setParent( c.getParent() );
return wrapper;
@@ -373,6 +385,7 @@
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#elaboratedTypeSpecifierEnd(java.lang.Object)
*/
public void elaboratedTypeSpecifierEnd(Object elab) {
+ SimpleDeclarationWrapper wrapper = (SimpleDeclarationWrapper)elab;
}
/**
@@ -640,14 +653,17 @@
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#enumSpecifierBegin(java.lang.Object)
*/
- public Object enumSpecifierBegin(Object container) {
- return null;
+ public Object enumSpecifierBegin(Object container, Token enumKey) {
+ SimpleDeclarationWrapper c = (SimpleDeclarationWrapper)container;
+ EnumerationWrapper wrapper = new EnumerationWrapper(c.getParent(), enumKey );
+ return wrapper;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#enumSpecifierId(java.lang.Object)
*/
public void enumSpecifierId(Object enumSpec) {
+ ((EnumerationWrapper)enumSpec).setName( currName );
}
/* (non-Javadoc)
@@ -661,25 +677,60 @@
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#enumSpecifierEnd(java.lang.Object)
*/
public void enumSpecifierEnd(Object enumSpec) {
+ EnumerationWrapper wrapper = (EnumerationWrapper)enumSpec;
+
+ List enumerators = wrapper.getEnumerators();
+
+ Parent realParent = (Parent)wrapper.getParent();
+ String enumName = ( wrapper.getName() == null ) ? "" : wrapper.getName().toString();
+ Enumeration enumeration = new Enumeration( (ICElement)realParent, enumName );
+ realParent.addChild( enumeration );
+
+ // create the list
+ Iterator i = enumerators.iterator();
+ while( i.hasNext())
+ {
+ EnumeratorWrapper subwrapper = (EnumeratorWrapper)i.next();
+ Enumerator enumerator = new Enumerator( enumeration, subwrapper.getName().toString() );
+ enumeration.addChild( enumerator );
+ }
+
+ // do the offsets
+ if( wrapper.getName() != null )
+ {
+ elem.setIdPos(wrapper.getName().getStartOffset(), enumName.length());
+ elem.setPos(wrapper.getName().getStartOffset(), enumName.length());
+ }
+ else
+ {
+ elem.setIdPos(wrapper.getClassKind().getOffset(), wrapper.getClassKind().getLength());
+ elem.setPos(wrapper.getClassKind().getOffset(), wrapper.getClassKind().getLength());
+ }
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#enumDefinitionBegin(java.lang.Object)
*/
public Object enumDefinitionBegin(Object enumSpec) {
- return null;
+ EnumerationWrapper wrapper = (EnumerationWrapper)enumSpec;
+ EnumeratorWrapper result = new EnumeratorWrapper(wrapper);
+ return result;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#enumDefinitionId(java.lang.Object)
*/
public void enumDefinitionId(Object enumDefn) {
+ EnumeratorWrapper wrapper = (EnumeratorWrapper)enumDefn;
+ wrapper.setName( currName );
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#enumDefinitionEnd(java.lang.Object)
*/
public void enumDefinitionEnd(Object enumDefn) {
+ EnumeratorWrapper wrapper = (EnumeratorWrapper)enumDefn;
+ wrapper.getParent().addEnumerator( wrapper );
}
/* (non-Javadoc)
@@ -687,7 +738,6 @@
*/
public void asmDefinition(Object container, String assemblyCode) {
// TODO Auto-generated method stub
-
}
/* (non-Javadoc)
Index: parser/org/eclipse/cdt/internal/core/model/SimpleDeclarationWrapper.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/model/SimpleDeclarationWrapper.java,v
retrieving revision 1.13
diff -u -r1.13 SimpleDeclarationWrapper.java
--- parser/org/eclipse/cdt/internal/core/model/SimpleDeclarationWrapper.java 29 Mar 2003 05:35:48 -0000 1.13
+++ parser/org/eclipse/cdt/internal/core/model/SimpleDeclarationWrapper.java 1 Apr 2003 16:11:43 -0000
@@ -3,8 +3,10 @@
import java.util.LinkedList;
import java.util.List;
+import org.eclipse.cdt.core.model.IParent;
import org.eclipse.cdt.core.model.IStructure;
import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.internal.core.parser.Token;
import org.eclipse.cdt.internal.core.parser.util.AccessSpecifier;
import org.eclipse.cdt.internal.core.parser.util.DeclSpecifier;
import org.eclipse.cdt.internal.core.parser.util.Name;
@@ -19,13 +21,13 @@
*/
public class SimpleDeclarationWrapper extends DeclSpecifier implements DeclSpecifier.Container, ICElementWrapper {
- private CElement element = null;
- private CElement parent = null;
- int kind;
+ private IParent element = null;
+ private IParent parent = null;
+
private Name name = null;
private boolean functionDefinition = false;
- public SimpleDeclarationWrapper( CElement item )
+ public SimpleDeclarationWrapper( IParent item )
{
this.element = item;
}
@@ -38,7 +40,7 @@
* Returns the item.
* @return CElement
*/
- public CElement getElement() {
+ public IParent getElement() {
return element;
}
@@ -46,15 +48,15 @@
* Sets the item.
* @param item The item to set
*/
- public void setElement (CElement item) {
- this.element = (CElement)item;
+ public void setElement (IParent item) {
+ this.element = (IParent)item;
}
/**
* Returns the parent.
* @return CElement
*/
- public CElement getParent() {
+ public IParent getParent() {
return parent;
}
@@ -62,7 +64,7 @@
* Sets the parent.
* @param parent The parent to set
*/
- public void setParent(CElement parent) {
+ public void setParent(IParent parent) {
this.parent = parent;
}
@@ -71,7 +73,7 @@
// creates the appropriate C Elements
List declaratorList = getDeclarators();
Declarator [] declarators = (Declarator []) declaratorList.toArray( new Declarator[ declaratorList.size() ] );
- CElement parentElement = getParent();
+ CElement parentElement = (CElement)getParent();
for( int i = 0; i < declarators.length; ++i )
{
@@ -80,6 +82,7 @@
// instantiate the right element
List clause =currentDeclarator.getParameterDeclarationClause();
+ String declaratorName = ( currentDeclarator.getName() == null ) ? "" : currentDeclarator.getName().toString();
if( clause == null && !isTypedef())
{
// TODO - this was to get rid of the NULL pointer we've been seeing
@@ -89,24 +92,23 @@
// this is an attribute or a varaible
if( parentElement instanceof IStructure )
{
- declaration = createField( parentElement, currentDeclarator.getName().toString() );
+ declaration = createField( parentElement, declaratorName );
}
else if( parentElement instanceof ITranslationUnit )
{
if(isExtern())
{
- declaration = createVariableDeclaration( parentElement, currentDeclarator.getName().toString() );
+ declaration = createVariableDeclaration( parentElement, declaratorName );
}
else
{
- declaration = createVariable( parentElement, currentDeclarator.getName().toString() );
+ declaration = createVariable( parentElement, declaratorName );
}
}
}
else if( isTypedef() )
{
- // do nothing just yet
- //TODO : update this -- typedefs do not have a parameterdeclarationclause
+ declaration = createTypedef( parentElement, declaratorName );
}
else
{
@@ -114,7 +116,7 @@
// this is a function or a method
if( parentElement instanceof IStructure )
{
- declaration = createMethodDeclaration( parentElement, currentDeclarator.getName().toString(), parameters );
+ declaration = createMethodDeclaration( parentElement, declaratorName, parameters );
}
else if( parentElement instanceof ITranslationUnit )
@@ -124,18 +126,27 @@
// if it belongs to a class, then create a method
// else create a function
// this will not be known until we have cross reference information
- declaration = createFunction( parentElement, currentDeclarator.getName().toString(), parameters );
+ declaration = createFunction( parentElement, declaratorName, parameters );
}
else
{
- declaration = createFunctionDeclaration( parentElement, currentDeclarator.getName().toString(), parameters );
+ declaration = createFunctionDeclaration( parentElement, declaratorName, parameters );
}
}
}
- // hook up the offsets
- declaration.setIdPos( currentDeclarator.getName().getStartOffset(), currentDeclarator.getName().toString().length());
- declaration.setPos( currentDeclarator.getName().getStartOffset(), currentDeclarator.getName().toString().length() );
+
+ if( currentDeclarator.getName() != null )
+ {
+ // hook up the offsets
+ declaration.setIdPos( currentDeclarator.getName().getStartOffset(), declaratorName.length());
+ declaration.setPos( currentDeclarator.getName().getStartOffset(), declaratorName.length() );
+ }
+ else
+ {
+ declaration.setIdPos( classKind.getOffset(), classKind.getImage().toString().length());
+ declaration.setPos( classKind.getOffset(), classKind.getImage().toString().length());
+ }
// add to parent
parentElement.addChild( declaration );
@@ -144,6 +155,7 @@
}
List declarators = new LinkedList();
+ String [] myString;
public void addDeclarator( Object in )
{
@@ -197,21 +209,7 @@
this.name = name;
}
- /**
- * Returns the kind.
- * @return int
- */
- public int getKind() {
- return kind;
- }
-
- /**
- * Sets the kind.
- * @param kind The kind to set
- */
- public void setKind(int kind) {
- this.kind = kind;
- }
+ private Token classKind;
/**
* Returns the functionDefinition.
@@ -262,6 +260,12 @@
return newElement;
}
+ private CElement createTypedef(CElement parent, String name){
+ CElement typedef = new TypeDef( parent, name );
+ return typedef;
+ }
+
+
/**
* Creates a Variable and fills its info
* @param parent
@@ -385,6 +389,21 @@
newElement.setVolatile(isVolatile());
newElement.setStatic(isStatic());
return newElement;
+ }
+
+ /**
+ * @return Token
+ */
+ public Token getClassKind() {
+ return classKind;
+ }
+
+ /**
+ * Sets the classKind.
+ * @param classKind The classKind to set
+ */
+ public void setClassKind(Token classKind) {
+ this.classKind = classKind;
}
}
Index: parser/org/eclipse/cdt/internal/core/model/TranslationUnitWrapper.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/model/TranslationUnitWrapper.java,v
retrieving revision 1.2
diff -u -r1.2 TranslationUnitWrapper.java
--- parser/org/eclipse/cdt/internal/core/model/TranslationUnitWrapper.java 4 Mar 2003 18:25:40 -0000 1.2
+++ parser/org/eclipse/cdt/internal/core/model/TranslationUnitWrapper.java 1 Apr 2003 16:11:44 -0000
@@ -1,5 +1,7 @@
package org.eclipse.cdt.internal.core.model;
+import org.eclipse.cdt.core.model.IParent;
+
/**
* @author jcamelon
*
@@ -15,13 +17,13 @@
/**
* @see org.eclipse.cdt.internal.core.model.IWrapper#getElement()
*/
- public CElement getElement() {
+ public IParent getElement() {
return unit;
}
/**
* @see org.eclipse.cdt.internal.core.model.IWrapper#setElement(java.lang.Object)
*/
- public void setElement(CElement item) {
+ public void setElement(IParent item) {
unit = (TranslationUnit)item;
}
Index: parser/org/eclipse/cdt/internal/core/parser/ExpressionEvaluator.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ExpressionEvaluator.java,v
retrieving revision 1.12
diff -u -r1.12 ExpressionEvaluator.java
--- parser/org/eclipse/cdt/internal/core/parser/ExpressionEvaluator.java 31 Mar 2003 21:04:29 -0000 1.12
+++ parser/org/eclipse/cdt/internal/core/parser/ExpressionEvaluator.java 1 Apr 2003 16:11:44 -0000
@@ -513,7 +513,7 @@
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#enumSpecifierBegin(java.lang.Object)
*/
- public Object enumSpecifierBegin(Object container) {
+ public Object enumSpecifierBegin(Object container, Token enumKey) {
return null;
}
Index: parser/org/eclipse/cdt/internal/core/parser/IParserCallback.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/IParserCallback.java,v
retrieving revision 1.11
diff -u -r1.11 IParserCallback.java
--- parser/org/eclipse/cdt/internal/core/parser/IParserCallback.java 31 Mar 2003 21:04:30 -0000 1.11
+++ parser/org/eclipse/cdt/internal/core/parser/IParserCallback.java 1 Apr 2003 16:11:45 -0000
@@ -96,7 +96,7 @@
public void usingDeclarationAbort( Object declaration );
public void usingDeclarationEnd( Object declaration );
- public Object enumSpecifierBegin( Object container );
+ public Object enumSpecifierBegin( Object container, Token enumKey );
public void enumSpecifierId( Object enumSpec );
public void enumSpecifierAbort( Object enumSpec );
public void enumSpecifierEnd( Object enumSpec );
Index: parser/org/eclipse/cdt/internal/core/parser/NullParserCallback.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/NullParserCallback.java,v
retrieving revision 1.11
diff -u -r1.11 NullParserCallback.java
--- parser/org/eclipse/cdt/internal/core/parser/NullParserCallback.java 31 Mar 2003 21:04:29 -0000 1.11
+++ parser/org/eclipse/cdt/internal/core/parser/NullParserCallback.java 1 Apr 2003 16:11:45 -0000
@@ -413,7 +413,7 @@
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#enumSpecifierBegin(java.lang.Object)
*/
- public Object enumSpecifierBegin(Object container) {
+ public Object enumSpecifierBegin(Object container, Token enumKey) {
// TODO Auto-generated method stub
return null;
}
Index: parser/org/eclipse/cdt/internal/core/parser/Parser.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Parser.java,v
retrieving revision 1.17
diff -u -r1.17 Parser.java
--- parser/org/eclipse/cdt/internal/core/parser/Parser.java 31 Mar 2003 21:04:29 -0000 1.17
+++ parser/org/eclipse/cdt/internal/core/parser/Parser.java 1 Apr 2003 16:11:46 -0000
@@ -670,9 +670,9 @@
case Token.t_volatile:
case Token.t_signed:
case Token.t_unsigned:
- case Token.t_short:
try{ callback.simpleDeclSpecifier(decl, consume());} catch( Exception e ) {}
break;
+ case Token.t_short:
case Token.t_char:
case Token.t_wchar_t:
case Token.t_bool:
@@ -1157,10 +1157,8 @@
*/
protected void enumSpecifier( Object owner ) throws Backtrack
{
- consume( Token.t_enum );
-
Object enumSpecifier = null;
- try{ enumSpecifier = callback.enumSpecifierBegin( owner );} catch( Exception e ) {}
+ try{ enumSpecifier = callback.enumSpecifierBegin( owner, consume( Token.t_enum ) );} catch( Exception e ) {}
if( LT(1) == Token.tIDENTIFIER )
{
Index: parser/org/eclipse/cdt/internal/core/parser/Scanner.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Scanner.java,v
retrieving revision 1.10
diff -u -r1.10 Scanner.java
--- parser/org/eclipse/cdt/internal/core/parser/Scanner.java 31 Mar 2003 21:04:29 -0000 1.10
+++ parser/org/eclipse/cdt/internal/core/parser/Scanner.java 1 Apr 2003 16:11:46 -0000
@@ -871,6 +871,14 @@
}
} else {
switch (c) {
+ case '\'' :
+ c = getChar();
+ int next = getChar();
+ if( next == '\'' )
+ return newToken( Token.tCHAR, new Character( (char)c ).toString(), currentContext );
+ else
+ if( throwExceptionOnBadCharacterRead )
+ throw new ScannerException( "Invalid character '" + (char)c + "' read @ offset " + currentContext.getOffset() + " of file " + currentContext.getFilename() );
case ':' :
c = getChar();
switch (c) {
@@ -1185,7 +1193,7 @@
default :
// Bad character
if( throwExceptionOnBadCharacterRead )
- throw new ScannerException( "Invalid character read @ offset " + currentContext.getOffset() + " of file " + currentContext.getFilename() );
+ throw new ScannerException( "Invalid character '" + (char)c + "' read @ offset " + currentContext.getOffset() + " of file " + currentContext.getFilename() );
break;
}
Index: parser/org/eclipse/cdt/internal/core/parser/Token.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Token.java,v
retrieving revision 1.5
diff -u -r1.5 Token.java
--- parser/org/eclipse/cdt/internal/core/parser/Token.java 31 Mar 2003 16:12:41 -0000 1.5
+++ parser/org/eclipse/cdt/internal/core/parser/Token.java 1 Apr 2003 16:11:47 -0000
@@ -175,6 +175,6 @@
static public final int tSTRING = 129;
static public final int tFLOATINGPT = 130;
static public final int tLSTRING = 131;
-
- static public final int tLAST = tLSTRING;
+ static public final int tCHAR = 132;
+ static public final int tLAST = tCHAR;
}