mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-09 10:46:02 +02:00
Patch for John Camelon:
- see ChangeLogs
This commit is contained in:
parent
5dfe2bf8c4
commit
e8808fb009
15 changed files with 292 additions and 37 deletions
|
@ -3,7 +3,6 @@ package org.eclipse.cdt.internal.core.dom;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.IScope;
|
|
||||||
import org.eclipse.cdt.internal.core.parser.util.Name;
|
import org.eclipse.cdt.internal.core.parser.util.Name;
|
||||||
|
|
||||||
public class ClassSpecifier extends TypeSpecifier implements IScope {
|
public class ClassSpecifier extends TypeSpecifier implements IScope {
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package org.eclipse.cdt.internal.core.dom;
|
package org.eclipse.cdt.internal.core.dom;
|
||||||
|
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.IScope;
|
|
||||||
import org.eclipse.cdt.internal.core.parser.IParserCallback;
|
import org.eclipse.cdt.internal.core.parser.IParserCallback;
|
||||||
import org.eclipse.cdt.internal.core.parser.Token;
|
import org.eclipse.cdt.internal.core.parser.Token;
|
||||||
import org.eclipse.cdt.internal.core.parser.util.DeclSpecifier;
|
import org.eclipse.cdt.internal.core.parser.util.DeclSpecifier;
|
||||||
|
@ -277,4 +276,51 @@ public class DOMBuilder implements IParserCallback
|
||||||
public void expressionEnd(Object expression) {
|
public void expressionEnd(Object expression) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#classSpecifierAbort(java.lang.Object)
|
||||||
|
*/
|
||||||
|
public void classSpecifierAbort(Object classSpecifier) {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#classSpecifierSafe(java.lang.Object)
|
||||||
|
*/
|
||||||
|
public void classSpecifierSafe(Object classSpecifier) {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#elaboratedTypeSpecifierBegin(java.lang.Object)
|
||||||
|
*/
|
||||||
|
public Object elaboratedTypeSpecifierBegin(Object container, Token classKey) {
|
||||||
|
int kind = ClassSpecifier.t_struct;
|
||||||
|
|
||||||
|
switch (classKey.getType()) {
|
||||||
|
case Token.t_class:
|
||||||
|
kind = ClassSpecifier.t_class;
|
||||||
|
break;
|
||||||
|
case Token.t_struct:
|
||||||
|
kind = ClassSpecifier.t_struct;
|
||||||
|
break;
|
||||||
|
case Token.t_union:
|
||||||
|
kind = ClassSpecifier.t_union;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
ElaboratedTypeSpecifier elab = new ElaboratedTypeSpecifier( kind, (SimpleDeclaration)container );
|
||||||
|
return elab;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#elaboratedTypeSpecifierEnd(java.lang.Object)
|
||||||
|
*/
|
||||||
|
public void elaboratedTypeSpecifierEnd(Object elab) {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#elaboratedTypeSpecifierName(java.lang.Object)
|
||||||
|
*/
|
||||||
|
public void elaboratedTypeSpecifierName(Object elab) {
|
||||||
|
((ElaboratedTypeSpecifier)elab).setName( currName );
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -0,0 +1,49 @@
|
||||||
|
package org.eclipse.cdt.internal.core.dom;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.internal.core.parser.util.Name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jcamelon
|
||||||
|
*
|
||||||
|
* To change this generated comment edit the template variable
|
||||||
|
"typecomment":
|
||||||
|
* Window>Preferences>Java>Templates.
|
||||||
|
* To enable and disable the creation of type comments go to
|
||||||
|
* Window>Preferences>Java>Code Generation.
|
||||||
|
*/
|
||||||
|
public class ElaboratedTypeSpecifier extends TypeSpecifier {
|
||||||
|
|
||||||
|
public static final int t_class = 0;
|
||||||
|
public static final int t_struct = 1;
|
||||||
|
public static final int t_union = 2;
|
||||||
|
public static final int t_enum = 3;
|
||||||
|
|
||||||
|
private final int classKey;
|
||||||
|
public int getClassKey() { return classKey; }
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.eclipse.cdt.internal.core.dom.TypeSpecifier#getDeclaration()
|
||||||
|
*/
|
||||||
|
public SimpleDeclaration getDeclaration() {
|
||||||
|
return super.getDeclaration();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.eclipse.cdt.internal.core.dom.TypeSpecifier#setDeclaration(org.eclipse.cdt.internal.core.dom.SimpleDeclaration)
|
||||||
|
*/
|
||||||
|
public void setDeclaration(SimpleDeclaration declaration) {
|
||||||
|
super.setDeclaration(declaration);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ElaboratedTypeSpecifier(int classKey, SimpleDeclaration declaration) {
|
||||||
|
super(declaration);
|
||||||
|
this.classKey = classKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Name name;
|
||||||
|
public void setName(Name n) { name = n; }
|
||||||
|
public Name getName() { return name; }
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -1,13 +1,11 @@
|
||||||
package org.eclipse.cdt.core.dom;
|
package org.eclipse.cdt.internal.core.dom;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.cdt.internal.core.dom.Declaration;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A scope contains a set of declarations that are defined in that scope.
|
* A scope contains a set of declarations that are defined in that
|
||||||
*/
|
scope. */ public interface IScope {
|
||||||
public interface IScope {
|
|
||||||
|
|
||||||
public void addDeclaration(Declaration declaration);
|
public void addDeclaration(Declaration declaration);
|
||||||
public List getDeclarations();
|
public List getDeclarations();
|
|
@ -3,7 +3,6 @@ package org.eclipse.cdt.internal.core.dom;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.IScope;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
|
|
|
@ -3,7 +3,6 @@ package org.eclipse.cdt.internal.core.dom;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.IScope;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,3 +1,8 @@
|
||||||
|
2003-03-13 John Camelon
|
||||||
|
Moved ## token to IScanner from Scanner.
|
||||||
|
Updated IParserCallback and implementations to deal with Elaborated Type Specifiers.
|
||||||
|
Moved IScope into the internal DOM package.
|
||||||
|
|
||||||
2003-03-11 John Camelon
|
2003-03-11 John Camelon
|
||||||
added ChangeLog to parser directory
|
added ChangeLog to parser directory
|
||||||
updated IParserCallback (and all implementors) for expressions
|
updated IParserCallback (and all implementors) for expressions
|
||||||
|
|
|
@ -35,8 +35,6 @@ public class NewModelBuilder implements IParserCallback {
|
||||||
return translationUnit;
|
return translationUnit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private Token classKey;
|
|
||||||
/**
|
/**
|
||||||
* @see org.eclipse.cdt.core.newparser.IParserCallback#beginClass(String, String)
|
* @see org.eclipse.cdt.core.newparser.IParserCallback#beginClass(String, String)
|
||||||
*/
|
*/
|
||||||
|
@ -55,24 +53,21 @@ public class NewModelBuilder implements IParserCallback {
|
||||||
default:
|
default:
|
||||||
kind = ICElement.C_UNION;
|
kind = ICElement.C_UNION;
|
||||||
}
|
}
|
||||||
this.classKey = classKey;
|
|
||||||
|
|
||||||
Structure elem = new Structure( c.getParent(), kind, null );
|
SimpleDeclarationWrapper wrapper = new SimpleDeclarationWrapper();
|
||||||
c.getParent().addChild(elem);
|
wrapper.setKind( kind );
|
||||||
return new SimpleDeclarationWrapper( elem );
|
wrapper.setParent( c.getParent() );
|
||||||
|
|
||||||
|
return wrapper;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.eclipse.cdt.internal.core.newparser.IParserCallback#classSpecifierName()
|
* @see org.eclipse.cdt.internal.core.newparser.IParserCallback#classSpecifierName()
|
||||||
*/
|
*/
|
||||||
public void classSpecifierName(Object classSpecifier) {
|
public void classSpecifierName(Object classSpecifier)
|
||||||
|
{
|
||||||
SimpleDeclarationWrapper container = (SimpleDeclarationWrapper)classSpecifier;
|
SimpleDeclarationWrapper wrapper = (SimpleDeclarationWrapper)classSpecifier;
|
||||||
String name = currName.toString();
|
wrapper.setName( currName );
|
||||||
Structure elem = ((Structure)container.getElement());
|
|
||||||
elem.setElementName( name );
|
|
||||||
elem.setIdPos(currName.getStartOffset(), name.length());
|
|
||||||
elem.setPos(currName.getStartOffset(), name.length());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -312,4 +307,43 @@ org.eclipse.cdt.internal.core.newparser.IParserCallback#beginSimpleDeclaration(T
|
||||||
public void expressionEnd(Object expression) {
|
public void expressionEnd(Object expression) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#classSpecifierAbort(java.lang.Object)
|
||||||
|
*/
|
||||||
|
public void classSpecifierAbort(Object classSpecifier) {
|
||||||
|
classSpecifier = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#classSpecifierSafe(java.lang.Object)
|
||||||
|
*/
|
||||||
|
public void classSpecifierSafe(Object classSpecifier) {
|
||||||
|
SimpleDeclarationWrapper wrapper = (SimpleDeclarationWrapper)classSpecifier;
|
||||||
|
Structure elem = new Structure( wrapper.getParent(), wrapper.getKind(), null );
|
||||||
|
wrapper.setElement( elem );
|
||||||
|
wrapper.getParent().addChild(elem);
|
||||||
|
String name = currName.toString();
|
||||||
|
elem.setElementName( name );
|
||||||
|
elem.setIdPos(currName.getStartOffset(), name.length());
|
||||||
|
elem.setPos(currName.getStartOffset(), name.length());
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#elaboratedTypeSpecifierBegin(java.lang.Object)
|
||||||
|
*/
|
||||||
|
public Object elaboratedTypeSpecifierBegin(Object container, Token classKey) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#elaboratedTypeSpecifierEnd(java.lang.Object)
|
||||||
|
*/
|
||||||
|
public void elaboratedTypeSpecifierEnd(Object elab) {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#elaboratedTypeSpecifierName(java.lang.Object)
|
||||||
|
*/
|
||||||
|
public void elaboratedTypeSpecifierName(Object elab) {
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ import java.util.List;
|
||||||
import org.eclipse.cdt.core.model.IStructure;
|
import org.eclipse.cdt.core.model.IStructure;
|
||||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||||
import org.eclipse.cdt.internal.core.parser.util.DeclSpecifier;
|
import org.eclipse.cdt.internal.core.parser.util.DeclSpecifier;
|
||||||
|
import org.eclipse.cdt.internal.core.parser.util.Name;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
|
@ -19,6 +20,8 @@ public class SimpleDeclarationWrapper extends DeclSpecifier implements DeclSpeci
|
||||||
|
|
||||||
private CElement element = null;
|
private CElement element = null;
|
||||||
private CElement parent = null;
|
private CElement parent = null;
|
||||||
|
int kind;
|
||||||
|
private Name name = null;
|
||||||
|
|
||||||
public SimpleDeclarationWrapper( CElement item )
|
public SimpleDeclarationWrapper( CElement item )
|
||||||
{
|
{
|
||||||
|
@ -162,4 +165,36 @@ public class SimpleDeclarationWrapper extends DeclSpecifier implements DeclSpeci
|
||||||
declarators.remove( declarator );
|
declarators.remove( declarator );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the name.
|
||||||
|
* @return Name
|
||||||
|
*/
|
||||||
|
public Name getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the name.
|
||||||
|
* @param name The name to set
|
||||||
|
*/
|
||||||
|
public void setName(Name name) {
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -269,4 +269,35 @@ public class ExpressionEvaluator implements IParserCallback {
|
||||||
public void expressionEnd(Object expression) {
|
public void expressionEnd(Object expression) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#classSpecifierAbort(java.lang.Object)
|
||||||
|
*/
|
||||||
|
public void classSpecifierAbort(Object classSpecifier) {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#classSpecifierSafe(java.lang.Object)
|
||||||
|
*/
|
||||||
|
public void classSpecifierSafe(Object classSpecifier) {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#elaboratedTypeSpecifierBegin(java.lang.Object)
|
||||||
|
*/
|
||||||
|
public Object elaboratedTypeSpecifierBegin(Object container, Token classKey) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#elaboratedTypeSpecifierEnd(java.lang.Object)
|
||||||
|
*/
|
||||||
|
public void elaboratedTypeSpecifierEnd(Object elab) {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#elaboratedTypeSpecifierName(java.lang.Object)
|
||||||
|
*/
|
||||||
|
public void elaboratedTypeSpecifierName(Object container) {
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,6 +43,8 @@ public interface IParserCallback {
|
||||||
|
|
||||||
public Object classSpecifierBegin(Object container, Token classKey);
|
public Object classSpecifierBegin(Object container, Token classKey);
|
||||||
public void classSpecifierName(Object classSpecifier);
|
public void classSpecifierName(Object classSpecifier);
|
||||||
|
public void classSpecifierAbort( Object classSpecifier );
|
||||||
|
public void classSpecifierSafe( Object classSpecifier );
|
||||||
public void classSpecifierEnd(Object classSpecifier);
|
public void classSpecifierEnd(Object classSpecifier);
|
||||||
|
|
||||||
public Object baseSpecifierBegin( Object containingClassSpec );
|
public Object baseSpecifierBegin( Object containingClassSpec );
|
||||||
|
@ -51,8 +53,12 @@ public interface IParserCallback {
|
||||||
public void baseSpecifierVirtual( Object baseSpecifier, boolean virtual );
|
public void baseSpecifierVirtual( Object baseSpecifier, boolean virtual );
|
||||||
public void baseSpecifierEnd( Object baseSpecifier );
|
public void baseSpecifierEnd( Object baseSpecifier );
|
||||||
|
|
||||||
public Object expressionBegin( Object container );
|
public Object expressionBegin( Object container );
|
||||||
public void expressionOperator(Token operator) throws Exception;
|
public void expressionOperator(Token operator) throws Exception;
|
||||||
public void expressionTerminal(Token terminal) throws Exception;
|
public void expressionTerminal(Token terminal) throws Exception;
|
||||||
public void expressionEnd(Object expression );
|
public void expressionEnd(Object expression );
|
||||||
|
|
||||||
|
public Object elaboratedTypeSpecifierBegin( Object container, Token classKey );
|
||||||
|
public void elaboratedTypeSpecifierName( Object elab );
|
||||||
|
public void elaboratedTypeSpecifierEnd( Object elab );
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,8 @@ import java.util.List;
|
||||||
*/
|
*/
|
||||||
public interface IScanner {
|
public interface IScanner {
|
||||||
|
|
||||||
|
public static final int tPOUNDPOUND = -6;
|
||||||
|
|
||||||
public IScanner initialize( Reader sourceToBeRead, String fileName );
|
public IScanner initialize( Reader sourceToBeRead, String fileName );
|
||||||
|
|
||||||
public void addDefinition(String key, IMacroDescriptor macroToBeAdded );
|
public void addDefinition(String key, IMacroDescriptor macroToBeAdded );
|
||||||
|
|
|
@ -184,4 +184,36 @@ public class NullParserCallback implements IParserCallback {
|
||||||
public void expressionEnd(Object expression) {
|
public void expressionEnd(Object expression) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#classSpecifierAbort(java.lang.Object)
|
||||||
|
*/
|
||||||
|
public void classSpecifierAbort(Object classSpecifier) {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#classSpecifierSafe(java.lang.Object)
|
||||||
|
*/
|
||||||
|
public void classSpecifierSafe(Object classSpecifier) {
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#elaboratedTypeSpecifierBegin(java.lang.Object)
|
||||||
|
*/
|
||||||
|
public Object elaboratedTypeSpecifierBegin(Object container, Token classKey) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#elaboratedTypeSpecifierEnd(java.lang.Object)
|
||||||
|
*/
|
||||||
|
public void elaboratedTypeSpecifierEnd(Object elab) {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#elaboratedTypeSpecifierName(java.lang.Object)
|
||||||
|
*/
|
||||||
|
public void elaboratedTypeSpecifierName(Object elab) {
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -84,7 +84,7 @@ c, quick);
|
||||||
lastToken = currToken;
|
lastToken = currToken;
|
||||||
declaration( translationUnit );
|
declaration( translationUnit );
|
||||||
if( currToken == lastToken )
|
if( currToken == lastToken )
|
||||||
skipToNextSemi();
|
consumeToNextSemicolon();
|
||||||
} catch (Backtrack b) {
|
} catch (Backtrack b) {
|
||||||
// Mark as failure and try to reach a recovery point
|
// Mark as failure and try to reach a recovery point
|
||||||
parsePassed = false;
|
parsePassed = false;
|
||||||
|
@ -92,7 +92,7 @@ c, quick);
|
||||||
if (lastBacktrack != null && lastBacktrack == LA(1)) {
|
if (lastBacktrack != null && lastBacktrack == LA(1)) {
|
||||||
// we haven't progressed from the last backtrack
|
// we haven't progressed from the last backtrack
|
||||||
// try and find tne next definition
|
// try and find tne next definition
|
||||||
skipToNextSemi();
|
consumeToNextSemicolon();
|
||||||
} else {
|
} else {
|
||||||
// start again from here
|
// start again from here
|
||||||
lastBacktrack = LA(1);
|
lastBacktrack = LA(1);
|
||||||
|
@ -102,7 +102,7 @@ c, quick);
|
||||||
callback.translationUnitEnd(translationUnit);
|
callback.translationUnitEnd(translationUnit);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void skipToNextSemi() {
|
protected void consumeToNextSemicolon() {
|
||||||
for (int t = LT(1); t != Token.tEOF; t = LT(1)) {
|
for (int t = LT(1); t != Token.tEOF; t = LT(1)) {
|
||||||
consume();
|
consume();
|
||||||
// TO DO: we should really check for matching braces too
|
// TO DO: we should really check for matching braces too
|
||||||
|
@ -338,8 +338,20 @@ c, quick);
|
||||||
case Token.t_class:
|
case Token.t_class:
|
||||||
case Token.t_struct:
|
case Token.t_struct:
|
||||||
case Token.t_union:
|
case Token.t_union:
|
||||||
classSpecifier(decl);
|
try
|
||||||
return;
|
{
|
||||||
|
classSpecifier(decl);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
catch( Backtrack bt )
|
||||||
|
{
|
||||||
|
// this is an elaborated class specifier
|
||||||
|
Object elab = callback.elaboratedTypeSpecifierBegin( decl, consume() );
|
||||||
|
name();
|
||||||
|
callback.elaboratedTypeSpecifierName( elab );
|
||||||
|
callback.elaboratedTypeSpecifierEnd( elab );
|
||||||
|
|
||||||
|
}
|
||||||
case Token.t_enum:
|
case Token.t_enum:
|
||||||
enumSpecifier(decl);
|
enumSpecifier(decl);
|
||||||
break;
|
break;
|
||||||
|
@ -638,6 +650,7 @@ c, quick);
|
||||||
public void classSpecifier( Object owner ) throws Exception {
|
public void classSpecifier( Object owner ) throws Exception {
|
||||||
Token classKey = null;
|
Token classKey = null;
|
||||||
|
|
||||||
|
Token mark = mark();
|
||||||
// class key
|
// class key
|
||||||
switch (LT(1)) {
|
switch (LT(1)) {
|
||||||
case Token.t_class:
|
case Token.t_class:
|
||||||
|
@ -656,8 +669,17 @@ c, quick);
|
||||||
name();
|
name();
|
||||||
callback.classSpecifierName(classSpec);
|
callback.classSpecifierName(classSpec);
|
||||||
}
|
}
|
||||||
|
|
||||||
//currRegion.put(name.getImage(), classKey);
|
if( LT(1) != Token.tCOLON && LT(1) != Token.tLBRACE )
|
||||||
|
{
|
||||||
|
// this is not a classSpecification
|
||||||
|
callback.classSpecifierAbort( classSpec );
|
||||||
|
classSpec = null;
|
||||||
|
backup( mark );
|
||||||
|
throw backtrack;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
callback.classSpecifierSafe( classSpec );
|
||||||
|
|
||||||
// base clause
|
// base clause
|
||||||
if (LT(1) == Token.tCOLON) {
|
if (LT(1) == Token.tCOLON) {
|
||||||
|
@ -693,7 +715,7 @@ c, quick);
|
||||||
declaration(classSpec);
|
declaration(classSpec);
|
||||||
}
|
}
|
||||||
if (lastToken == currToken)
|
if (lastToken == currToken)
|
||||||
skipToNextSemi();
|
consumeToNextSemicolon();
|
||||||
}
|
}
|
||||||
// consume the }
|
// consume the }
|
||||||
consume();
|
consume();
|
||||||
|
|
|
@ -325,8 +325,6 @@ public class Scanner implements IScanner {
|
||||||
private static final String DEFINED = "defined";
|
private static final String DEFINED = "defined";
|
||||||
private static final String POUND_DEFINE = "#define ";
|
private static final String POUND_DEFINE = "#define ";
|
||||||
|
|
||||||
public static final int tPOUNDPOUND = -6;
|
|
||||||
|
|
||||||
private IScannerContext currentContext;
|
private IScannerContext currentContext;
|
||||||
private Stack contextStack = new Stack();
|
private Stack contextStack = new Stack();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue