mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-08 18:26:01 +02:00
Patch for John Camelon:
CORE Fixed defects 36019, 36020, 36045. Finished template declarations and their callbacks for the DOM (not the Code Model). TESTS Updated ScannerTest::testSimpleIfdef() for bug36019. Updated ScannerTest::testNumerics() for bug36020. Added ScannerTest::testBug36045(). Updated DOMTests::testTemplateDeclaration() for template grammar updates.
This commit is contained in:
parent
c045393b50
commit
7081cddca6
16 changed files with 319 additions and 103 deletions
|
@ -254,7 +254,7 @@ public class DOMBuilder implements IParserCallback
|
||||||
|
|
||||||
public Object parameterDeclarationBegin( Object container )
|
public Object parameterDeclarationBegin( Object container )
|
||||||
{
|
{
|
||||||
ParameterDeclarationClause clause = (ParameterDeclarationClause)container;
|
IScope clause = (IScope)container;
|
||||||
ParameterDeclaration pd = new ParameterDeclaration();
|
ParameterDeclaration pd = new ParameterDeclaration();
|
||||||
clause.addDeclaration( pd );
|
clause.addDeclaration( pd );
|
||||||
return pd;
|
return pd;
|
||||||
|
@ -790,7 +790,7 @@ public class DOMBuilder implements IParserCallback
|
||||||
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#templateTypeParameterBegin(java.lang.Object, org.eclipse.cdt.internal.core.parser.Token)
|
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#templateTypeParameterBegin(java.lang.Object, org.eclipse.cdt.internal.core.parser.Token)
|
||||||
*/
|
*/
|
||||||
public Object templateTypeParameterBegin(Object templDecl, Token kind) {
|
public Object templateTypeParameterBegin(Object templDecl, Token kind) {
|
||||||
TemplateParameter.ITemplateParameterList list = (TemplateParameter.ITemplateParameterList)templDecl;
|
TemplateParameterList list = (TemplateParameterList)templDecl;
|
||||||
int k;
|
int k;
|
||||||
switch( kind.getType() )
|
switch( kind.getType() )
|
||||||
{
|
{
|
||||||
|
@ -800,10 +800,15 @@ public class DOMBuilder implements IParserCallback
|
||||||
case Token.t_typename:
|
case Token.t_typename:
|
||||||
k= TemplateParameter.k_typename;
|
k= TemplateParameter.k_typename;
|
||||||
break;
|
break;
|
||||||
|
case Token.t_template:
|
||||||
|
k= TemplateParameter.k_template;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
k = 0;
|
k = 0;
|
||||||
}
|
}
|
||||||
return new TemplateParameter( list, k );
|
TemplateParameter p = new TemplateParameter( k );
|
||||||
|
list.addDeclaration(p);
|
||||||
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@ -824,8 +829,6 @@ public class DOMBuilder implements IParserCallback
|
||||||
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#templateTypeParameterEnd(java.lang.Object)
|
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#templateTypeParameterEnd(java.lang.Object)
|
||||||
*/
|
*/
|
||||||
public void templateTypeParameterEnd(Object typeParm) {
|
public void templateTypeParameterEnd(Object typeParm) {
|
||||||
TemplateParameter parm = ((TemplateParameter)typeParm);
|
|
||||||
parm.getContainer().addTemplateParameter(parm);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@ -841,4 +844,20 @@ public class DOMBuilder implements IParserCallback
|
||||||
public void pointerOperatorAbort(Object ptrOperator) {
|
public void pointerOperatorAbort(Object ptrOperator) {
|
||||||
ptrOperator = null;
|
ptrOperator = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#templateParameterListBegin(java.lang.Object)
|
||||||
|
*/
|
||||||
|
public Object templateParameterListBegin(Object declaration) {
|
||||||
|
ITemplateParameterListOwner d = (ITemplateParameterListOwner)declaration;
|
||||||
|
TemplateParameterList list = new TemplateParameterList();
|
||||||
|
d.setTemplateParms(list);
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#templateParameterListEnd(java.lang.Object)
|
||||||
|
*/
|
||||||
|
public void templateParameterListEnd(Object parameterList) {
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -4,7 +4,6 @@ import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.cdt.internal.core.parser.util.*;
|
|
||||||
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;
|
import org.eclipse.cdt.internal.core.parser.util.Name;
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* Created on Mar 29, 2003
|
||||||
|
*
|
||||||
|
* Copyright (c) 2002,2003 IBM/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:
|
||||||
|
* IBM Ltd. - Rational Software - Initial API and implementation
|
||||||
|
***********************************************************************/
|
||||||
|
|
||||||
|
package org.eclipse.cdt.internal.core.dom;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jcamelon
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public interface ITemplateParameterListOwner
|
||||||
|
{
|
||||||
|
public TemplateParameterList getTemplateParms();
|
||||||
|
public void setTemplateParms(TemplateParameterList list);
|
||||||
|
}
|
||||||
|
|
|
@ -20,11 +20,12 @@ import java.util.List;
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class TemplateDeclaration extends Declaration implements IScope, TemplateParameter.ITemplateParameterList {
|
public class TemplateDeclaration extends Declaration implements IScope, ITemplateParameterListOwner {
|
||||||
|
|
||||||
private final boolean exported;
|
private final boolean exported;
|
||||||
private IScope ownerScope;
|
private IScope ownerScope;
|
||||||
private List declarations = new ArrayList();
|
private List declarations = new ArrayList();
|
||||||
|
private TemplateParameterList templateParms = null;
|
||||||
|
|
||||||
public TemplateDeclaration( IScope ownerScope, boolean exported )
|
public TemplateDeclaration( IScope ownerScope, boolean exported )
|
||||||
{
|
{
|
||||||
|
@ -60,20 +61,18 @@ public class TemplateDeclaration extends Declaration implements IScope, Template
|
||||||
return ownerScope;
|
return ownerScope;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
private List templateParameters = new ArrayList();
|
* @return
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.internal.core.dom.TemplateParameter.ITemplateParameterList#getTemplateParameters()
|
|
||||||
*/
|
*/
|
||||||
public List getTemplateParameters() {
|
public TemplateParameterList getTemplateParms() {
|
||||||
return Collections.unmodifiableList(templateParameters);
|
return templateParms;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/**
|
||||||
* @see org.eclipse.cdt.internal.core.dom.TemplateParameter.ITemplateParameterList#addTemplateParameter(org.eclipse.cdt.internal.core.dom.TemplateParameter)
|
* @param list
|
||||||
*/
|
*/
|
||||||
public void addTemplateParameter(TemplateParameter parm) {
|
public void setTemplateParms(TemplateParameterList list) {
|
||||||
templateParameters.add( parm );
|
templateParms = list;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,42 +12,29 @@
|
||||||
***********************************************************************/
|
***********************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom;
|
package org.eclipse.cdt.internal.core.dom;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.internal.core.parser.util.Name;
|
import org.eclipse.cdt.internal.core.parser.util.Name;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class TemplateParameter {
|
public class TemplateParameter extends Declaration implements ITemplateParameterListOwner {
|
||||||
|
|
||||||
public interface ITemplateParameterList {
|
|
||||||
public List getTemplateParameters();
|
|
||||||
public void addTemplateParameter( TemplateParameter parm );
|
|
||||||
}
|
|
||||||
|
|
||||||
private ITemplateParameterList container;
|
|
||||||
private final int kind;
|
private final int kind;
|
||||||
|
|
||||||
public final static int k_class = 2;
|
public final static int k_class = 2;
|
||||||
public final static int k_typename = 3;
|
public final static int k_typename = 3;
|
||||||
|
public final static int k_template = 4;
|
||||||
|
|
||||||
|
|
||||||
public TemplateParameter( ITemplateParameterList container, int kind )
|
public TemplateParameter( int kind )
|
||||||
{
|
{
|
||||||
this.container = container;
|
|
||||||
this.kind = kind;
|
this.kind = kind;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Name name = null;
|
private Name name = null;
|
||||||
private Name typeId = null;
|
private Name typeId = null;
|
||||||
/**
|
|
||||||
* @return ITemplateParameterList
|
|
||||||
*/
|
|
||||||
public ITemplateParameterList getContainer() {
|
|
||||||
return container;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return int
|
* @return int
|
||||||
|
@ -86,4 +73,20 @@ public class TemplateParameter {
|
||||||
this.typeId = typeId;
|
this.typeId = typeId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TemplateParameterList list;
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.dom.ITemplateParameterListOwner#getTemplateParms()
|
||||||
|
*/
|
||||||
|
public TemplateParameterList getTemplateParms() {
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.dom.ITemplateParameterListOwner#setTemplateParms(org.eclipse.cdt.internal.core.dom.TemplateParameterList)
|
||||||
|
*/
|
||||||
|
public void setTemplateParms(TemplateParameterList list) {
|
||||||
|
this.list = list;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,39 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* Created on Mar 29, 2003
|
||||||
|
*
|
||||||
|
* Copyright (c) 2002,2003 IBM/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:
|
||||||
|
* IBM Ltd. - Rational Software - Initial API and implementation
|
||||||
|
***********************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.core.dom;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jcamelon
|
||||||
|
*/
|
||||||
|
public class TemplateParameterList implements IScope {
|
||||||
|
|
||||||
|
private List parameters = new ArrayList();
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.dom.IScope#addDeclaration(org.eclipse.cdt.internal.core.dom.Declaration)
|
||||||
|
*/
|
||||||
|
public void addDeclaration(Declaration declaration) {
|
||||||
|
parameters.add( declaration );
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.dom.IScope#getDeclarations()
|
||||||
|
*/
|
||||||
|
public List getDeclarations() {
|
||||||
|
return Collections.unmodifiableList( parameters );
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,3 +1,7 @@
|
||||||
|
2003-04-03 John Camelon
|
||||||
|
Fixed defects 36019, 36020, 36045.
|
||||||
|
Finished template declarations and their callbacks for the DOM (not the Code Model).
|
||||||
|
|
||||||
2003-04-01 John Camelon
|
2003-04-01 John Camelon
|
||||||
Updated Scanner to convert control-characters to ' '.
|
Updated Scanner to convert control-characters to ' '.
|
||||||
Fixed logic error in SimpleDeclarationWrapper.
|
Fixed logic error in SimpleDeclarationWrapper.
|
||||||
|
|
|
@ -936,4 +936,20 @@ org.eclipse.cdt.internal.core.newparser.IParserCallback#beginSimpleDeclaration(T
|
||||||
ptrOperator = null;
|
ptrOperator = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#templateParameterListBegin(java.lang.Object)
|
||||||
|
*/
|
||||||
|
public Object templateParameterListBegin(Object declaration) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#templateParameterListEnd(java.lang.Object)
|
||||||
|
*/
|
||||||
|
public void templateParameterListEnd(Object parameterList) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -710,4 +710,17 @@ public class ExpressionEvaluator implements IParserCallback {
|
||||||
public void pointerOperatorAbort(Object ptrOperator) {
|
public void pointerOperatorAbort(Object ptrOperator) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#templateParameterListBegin(java.lang.Object)
|
||||||
|
*/
|
||||||
|
public Object templateParameterListBegin(Object declaration) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#templateParameterListEnd(java.lang.Object)
|
||||||
|
*/
|
||||||
|
public void templateParameterListEnd(Object parameterList) {
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -128,6 +128,9 @@ public interface IParserCallback {
|
||||||
public void templateDeclarationAbort( Object templateDecl );
|
public void templateDeclarationAbort( Object templateDecl );
|
||||||
public void templateDeclarationEnd( Object templateDecl );
|
public void templateDeclarationEnd( Object templateDecl );
|
||||||
|
|
||||||
|
public Object templateParameterListBegin( Object declaration );
|
||||||
|
public void templateParameterListEnd( Object parameterList );
|
||||||
|
|
||||||
public Object templateTypeParameterBegin( Object templDecl, Token kind );
|
public Object templateTypeParameterBegin( Object templDecl, Token kind );
|
||||||
public void templateTypeParameterName( Object typeParm );
|
public void templateTypeParameterName( Object typeParm );
|
||||||
public void templateTypeParameterAbort( Object typeParm );
|
public void templateTypeParameterAbort( Object typeParm );
|
||||||
|
|
|
@ -414,7 +414,6 @@ public class NullParserCallback implements IParserCallback {
|
||||||
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#enumSpecifierBegin(java.lang.Object)
|
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#enumSpecifierBegin(java.lang.Object)
|
||||||
*/
|
*/
|
||||||
public Object enumSpecifierBegin(Object container, Token enumKey) {
|
public Object enumSpecifierBegin(Object container, Token enumKey) {
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -422,31 +421,24 @@ public class NullParserCallback implements IParserCallback {
|
||||||
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#enumSpecifierId(java.lang.Object)
|
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#enumSpecifierId(java.lang.Object)
|
||||||
*/
|
*/
|
||||||
public void enumSpecifierId(Object enumSpec) {
|
public void enumSpecifierId(Object enumSpec) {
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#enumSpecifierAbort(java.lang.Object)
|
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#enumSpecifierAbort(java.lang.Object)
|
||||||
*/
|
*/
|
||||||
public void enumSpecifierAbort(Object enumSpec) {
|
public void enumSpecifierAbort(Object enumSpec) {
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#enumSpecifierEnd(java.lang.Object)
|
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#enumSpecifierEnd(java.lang.Object)
|
||||||
*/
|
*/
|
||||||
public void enumSpecifierEnd(Object enumSpec) {
|
public void enumSpecifierEnd(Object enumSpec) {
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#enumDefinitionBegin(java.lang.Object)
|
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#enumDefinitionBegin(java.lang.Object)
|
||||||
*/
|
*/
|
||||||
public Object enumDefinitionBegin(Object enumSpec) {
|
public Object enumDefinitionBegin(Object enumSpec) {
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -454,16 +446,12 @@ public class NullParserCallback implements IParserCallback {
|
||||||
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#enumDefinitionId(java.lang.Object)
|
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#enumDefinitionId(java.lang.Object)
|
||||||
*/
|
*/
|
||||||
public void enumDefinitionId(Object enumDefn) {
|
public void enumDefinitionId(Object enumDefn) {
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#enumDefinitionEnd(java.lang.Object)
|
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#enumDefinitionEnd(java.lang.Object)
|
||||||
*/
|
*/
|
||||||
public void enumDefinitionEnd(Object enumDefn) {
|
public void enumDefinitionEnd(Object enumDefn) {
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@ -611,4 +599,17 @@ public class NullParserCallback implements IParserCallback {
|
||||||
public void pointerOperatorAbort(Object ptrOperator) {
|
public void pointerOperatorAbort(Object ptrOperator) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#templateParameterListBegin(java.lang.Object)
|
||||||
|
*/
|
||||||
|
public Object templateParameterListBegin(Object declaration) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#templateParameterListEnd(java.lang.Object)
|
||||||
|
*/
|
||||||
|
public void templateParameterListEnd(Object parameterList) {
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -326,17 +326,22 @@ c, quick);
|
||||||
protected void templateParameterList( Object templateDeclaration ) throws EndOfFile, Backtrack {
|
protected void templateParameterList( Object templateDeclaration ) throws EndOfFile, Backtrack {
|
||||||
// if we have gotten this far then we have a true template-declaration
|
// if we have gotten this far then we have a true template-declaration
|
||||||
// iterate through the template parameter list
|
// iterate through the template parameter list
|
||||||
|
|
||||||
|
Object templateParameterList = null;
|
||||||
|
|
||||||
|
try { templateParameterList = callback.templateParameterListBegin( templateDeclaration ); } catch( Exception e ) {}
|
||||||
|
|
||||||
for ( ; ; )
|
for ( ; ; )
|
||||||
{
|
{
|
||||||
if( LT(1) == Token.tGT ) return;
|
if( LT(1) == Token.tGT ) return;
|
||||||
Object currentTemplateParm = null;
|
|
||||||
if( LT(1) == Token.t_class || LT(1) == Token.t_typename )
|
if( LT(1) == Token.t_class || LT(1) == Token.t_typename )
|
||||||
{
|
{
|
||||||
|
Object currentTemplateParm = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
try{
|
try{
|
||||||
currentTemplateParm = callback.templateTypeParameterBegin(
|
currentTemplateParm = callback.templateTypeParameterBegin(
|
||||||
templateDeclaration, consume() );
|
templateParameterList, consume() );
|
||||||
} catch( Exception e ) {}
|
} catch( Exception e ) {}
|
||||||
if( LT(1) == Token.tIDENTIFIER ) // optional identifier
|
if( LT(1) == Token.tIDENTIFIER ) // optional identifier
|
||||||
{
|
{
|
||||||
|
@ -359,27 +364,25 @@ c, quick);
|
||||||
}
|
}
|
||||||
else if( LT(1) == Token.t_template )
|
else if( LT(1) == Token.t_template )
|
||||||
{
|
{
|
||||||
try
|
Token kind = consume( Token.t_template );
|
||||||
{
|
|
||||||
consume( Token.t_template );
|
|
||||||
consume( Token.tLT );
|
consume( Token.tLT );
|
||||||
Object newTemplateDeclaration = null;
|
Object newTemplateParm = null;
|
||||||
templateParameterList( newTemplateDeclaration );
|
try{ newTemplateParm = callback.templateTypeParameterBegin(templateParameterList,kind ); } catch( Exception e ) {}
|
||||||
|
templateParameterList( newTemplateParm );
|
||||||
consume( Token.tGT );
|
consume( Token.tGT );
|
||||||
consume( Token.t_class );
|
consume( Token.t_class );
|
||||||
if( LT(1) == Token.tIDENTIFIER ) // optional identifier
|
if( LT(1) == Token.tIDENTIFIER ) // optional identifier
|
||||||
{
|
{
|
||||||
identifier();
|
identifier();
|
||||||
|
try{ callback.templateTypeParameterName( newTemplateParm );} catch( Exception e ) {}
|
||||||
if( LT(1) == Token.tASSIGN ) // optional = type-id
|
if( LT(1) == Token.tASSIGN ) // optional = type-id
|
||||||
{
|
{
|
||||||
consume( Token.tASSIGN );
|
consume( Token.tASSIGN );
|
||||||
// id-expression()
|
name();
|
||||||
|
try{ callback.templateTypeParameterInitialTypeId( newTemplateParm );} catch( Exception e ) {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
try{ callback.templateTypeParameterEnd( newTemplateParm );} catch( Exception e ) {}
|
||||||
catch( Backtrack bt )
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if( LT(1) == Token.tCOMMA )
|
else if( LT(1) == Token.tCOMMA )
|
||||||
{
|
{
|
||||||
|
@ -388,7 +391,7 @@ c, quick);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
parameterDeclaration( templateDeclaration );
|
parameterDeclaration( templateParameterList );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1069,7 +1072,7 @@ c, quick);
|
||||||
switch (LT(1)) {
|
switch (LT(1)) {
|
||||||
case Token.tLPAREN:
|
case Token.tLPAREN:
|
||||||
// temporary fix for initializer/function declaration ambiguity
|
// temporary fix for initializer/function declaration ambiguity
|
||||||
if( LT(2) != Token.tINTEGER )
|
if( LT(2) != Token.tINTEGER && LT(2) != Token.t_false && LT(2) != Token.t_true )
|
||||||
{
|
{
|
||||||
// parameterDeclarationClause
|
// parameterDeclarationClause
|
||||||
Object clause = null;
|
Object clause = null;
|
||||||
|
@ -1983,11 +1986,12 @@ c, quick);
|
||||||
switch (type) {
|
switch (type) {
|
||||||
// TO DO: we need more literals...
|
// TO DO: we need more literals...
|
||||||
case Token.tINTEGER:
|
case Token.tINTEGER:
|
||||||
try{ callback.expressionTerminal(expression, consume());} catch( Exception e ) {}
|
|
||||||
return;
|
|
||||||
case Token.tSTRING:
|
case Token.tSTRING:
|
||||||
|
case Token.t_false:
|
||||||
|
case Token.t_true:
|
||||||
try{ callback.expressionTerminal(expression, consume());} catch( Exception e ) {}
|
try{ callback.expressionTerminal(expression, consume());} catch( Exception e ) {}
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case Token.tIDENTIFIER:
|
case Token.tIDENTIFIER:
|
||||||
try{ callback.expressionTerminal(expression, consume());} catch( Exception e ) {}
|
try{ callback.expressionTerminal(expression, consume());} catch( Exception e ) {}
|
||||||
return;
|
return;
|
||||||
|
@ -2068,7 +2072,7 @@ c, quick);
|
||||||
throw e;
|
throw e;
|
||||||
} catch (ScannerException e) {
|
} catch (ScannerException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return null;
|
return fetchToken();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -359,7 +359,12 @@ public class Scanner implements IScanner {
|
||||||
callback = c;
|
callback = c;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getChar() {
|
private int getChar()
|
||||||
|
{
|
||||||
|
return getChar( false );
|
||||||
|
}
|
||||||
|
|
||||||
|
private int getChar( boolean insideString ) {
|
||||||
int c = NOCHAR;
|
int c = NOCHAR;
|
||||||
if (currentContext == null)
|
if (currentContext == null)
|
||||||
// past the end of file
|
// past the end of file
|
||||||
|
@ -392,16 +397,18 @@ public class Scanner implements IScanner {
|
||||||
}
|
}
|
||||||
} while (!done);
|
} while (!done);
|
||||||
|
|
||||||
|
if( ! insideString )
|
||||||
|
{
|
||||||
if (c == '\\') {
|
if (c == '\\') {
|
||||||
c = getChar();
|
c = getChar(false);
|
||||||
if (c == '\r') {
|
if (c == '\r') {
|
||||||
c = getChar();
|
c = getChar(false);
|
||||||
if (c == '\n')
|
if (c == '\n')
|
||||||
c = getChar();
|
c = getChar(false);
|
||||||
} else if (c == '\n')
|
} else if (c == '\n')
|
||||||
c = getChar();
|
c = getChar(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -448,9 +455,31 @@ public class Scanner implements IScanner {
|
||||||
|
|
||||||
while (c != NOCHAR) {
|
while (c != NOCHAR) {
|
||||||
if ( ! passOnToClient ) {
|
if ( ! passOnToClient ) {
|
||||||
while (c != '#') {
|
|
||||||
|
int state = 0;
|
||||||
|
|
||||||
|
while (c != NOCHAR && c != '#' )
|
||||||
|
{
|
||||||
c = getChar();
|
c = getChar();
|
||||||
|
if( c == '/' )
|
||||||
|
{
|
||||||
|
c = getChar();
|
||||||
|
if( c == '/' )
|
||||||
|
{
|
||||||
|
while (c != '\n' && c != NOCHAR)
|
||||||
|
c = getChar();
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
else if( c == '*' )
|
||||||
|
{
|
||||||
|
skipOverMultilineComment();
|
||||||
|
c = getChar();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if( c == NOCHAR ) continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((c == ' ') || (c == '\r') || (c == '\t') || (c == '\n')) {
|
if ((c == ' ') || (c == '\r') || (c == '\t') || (c == '\n')) {
|
||||||
|
@ -476,11 +505,15 @@ public class Scanner implements IScanner {
|
||||||
|
|
||||||
// string
|
// string
|
||||||
StringBuffer buff = new StringBuffer();
|
StringBuffer buff = new StringBuffer();
|
||||||
c = getChar();
|
int previous = c;
|
||||||
|
c = getChar(true);
|
||||||
|
|
||||||
while (c != '"' && c != '\n') {
|
for( ; ; )
|
||||||
|
{
|
||||||
|
if( ( c == '"' && previous != '\\' )|| ( c == '\n') )break;
|
||||||
buff.append((char) c);
|
buff.append((char) c);
|
||||||
c = getChar();
|
previous = c;
|
||||||
|
c = getChar(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (c != '\n')
|
if (c != '\n')
|
||||||
|
@ -608,7 +641,12 @@ public class Scanner implements IScanner {
|
||||||
if( c == '.' )
|
if( c == '.' )
|
||||||
{
|
{
|
||||||
buff.append( (char)c);
|
buff.append( (char)c);
|
||||||
if( floatingPoint || hex ) throw new ScannerException( "Invalid floating point @ offset " + currentContext.getOffset() );
|
if( floatingPoint || hex ) {
|
||||||
|
if( buff.toString().equals( "..") && getChar() == '.' )
|
||||||
|
return newToken( Token.tELIPSE, "..." );
|
||||||
|
throw new ScannerException( "Invalid floating point @ offset " + currentContext.getOffset() );
|
||||||
|
}
|
||||||
|
|
||||||
floatingPoint = true;
|
floatingPoint = true;
|
||||||
c= getChar();
|
c= getChar();
|
||||||
while ((c >= '0' && c <= '9') )
|
while ((c >= '0' && c <= '9') )
|
||||||
|
@ -1205,7 +1243,7 @@ public class Scanner implements IScanner {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (throwExceptionOnEOFWithoutBalancedEndifs && (getDepth() != 0))
|
if (throwExceptionOnEOFWithoutBalancedEndifs && ( getDepth() != 0))
|
||||||
throw new ScannerException("End of file encountered without terminating #endif");
|
throw new ScannerException("End of file encountered without terminating #endif");
|
||||||
|
|
||||||
// we're done
|
// we're done
|
||||||
|
|
|
@ -1,8 +1,14 @@
|
||||||
|
2003-04-03 John Camelon
|
||||||
|
Updated ScannerTest::testSimpleIfdef() for bug36019.
|
||||||
|
Updated ScannerTest::testNumerics() for bug36020.
|
||||||
|
Added ScannerTest::testBug36045().
|
||||||
|
Updated DOMTests::testTemplateDeclaration() for template grammar updates.
|
||||||
|
|
||||||
2003-04-01 Andrew Niefer
|
2003-04-01 Andrew Niefer
|
||||||
ParserSymbolTableTest. modifications to using declaration tests to reflect changes in the
|
ParserSymbolTableTest. modifications to using declaration tests to reflect changes in the
|
||||||
symbol table. Also added testUserDefinedConversionSequences()
|
symbol table. Also added testUserDefinedConversionSequences()
|
||||||
|
|
||||||
2003-04-01
|
2003-04-01 John Camelon
|
||||||
Added testBug35906() to DOMTests.
|
Added testBug35906() to DOMTests.
|
||||||
|
|
||||||
2003-03-31 John Camelon
|
2003-03-31 John Camelon
|
||||||
|
|
|
@ -893,26 +893,53 @@ public class DOMTests extends TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testTemplateDeclaration() throws Exception {
|
public void testTemplateDeclaration() throws Exception {
|
||||||
TranslationUnit tu = parse( "template<class T, typename Tibor = junk, class, typename> class myarray { /* ... */ };");
|
TranslationUnit tu = parse( "template<class T, typename Tibor = junk, class, typename, int x, float y,template <class Y> class, template<class A> class AClass> class myarray { /* ... */ };");
|
||||||
assertEquals( tu.getDeclarations().size(), 1 );
|
assertEquals( tu.getDeclarations().size(), 1 );
|
||||||
TemplateDeclaration declaration = (TemplateDeclaration)tu.getDeclarations().get(0);
|
TemplateDeclaration declaration = (TemplateDeclaration)tu.getDeclarations().get(0);
|
||||||
assertEquals( declaration.getTemplateParameters().size(), 4 );
|
assertEquals( declaration.getTemplateParms().getDeclarations().size(), 8 );
|
||||||
TemplateParameter parameter = (TemplateParameter)declaration.getTemplateParameters().get(0);
|
TemplateParameter parameter = (TemplateParameter)declaration.getTemplateParms().getDeclarations().get(0);
|
||||||
assertEquals( parameter.getKind(), TemplateParameter.k_class);
|
assertEquals( parameter.getKind(), TemplateParameter.k_class);
|
||||||
assertEquals( parameter.getName().toString(), "T" );
|
assertEquals( parameter.getName().toString(), "T" );
|
||||||
assertNull( parameter.getTypeId());
|
assertNull( parameter.getTypeId());
|
||||||
parameter = (TemplateParameter)declaration.getTemplateParameters().get(1);
|
parameter = (TemplateParameter)declaration.getTemplateParms().getDeclarations().get(1);
|
||||||
assertEquals( parameter.getKind(), TemplateParameter.k_typename);
|
assertEquals( parameter.getKind(), TemplateParameter.k_typename);
|
||||||
assertEquals( parameter.getName().toString(), "Tibor" );
|
assertEquals( parameter.getName().toString(), "Tibor" );
|
||||||
assertEquals( parameter.getTypeId().toString(), "junk");
|
assertEquals( parameter.getTypeId().toString(), "junk");
|
||||||
parameter = (TemplateParameter)declaration.getTemplateParameters().get(2);
|
parameter = (TemplateParameter)declaration.getTemplateParms().getDeclarations().get(2);
|
||||||
assertEquals( parameter.getKind(), TemplateParameter.k_class);
|
assertEquals( parameter.getKind(), TemplateParameter.k_class);
|
||||||
assertNull( parameter.getName() );
|
assertNull( parameter.getName() );
|
||||||
assertNull( parameter.getTypeId());
|
assertNull( parameter.getTypeId());
|
||||||
parameter = (TemplateParameter)declaration.getTemplateParameters().get(3);
|
parameter = (TemplateParameter)declaration.getTemplateParms().getDeclarations().get(3);
|
||||||
assertEquals( parameter.getKind(), TemplateParameter.k_typename);
|
assertEquals( parameter.getKind(), TemplateParameter.k_typename);
|
||||||
assertNull( parameter.getName() );
|
assertNull( parameter.getName() );
|
||||||
assertNull( parameter.getTypeId());
|
assertNull( parameter.getTypeId());
|
||||||
|
ParameterDeclaration decl = (ParameterDeclaration)declaration.getTemplateParms().getDeclarations().get(4);
|
||||||
|
assertEquals( decl.getDeclSpecifier().getType(), DeclSpecifier.t_int );
|
||||||
|
assertEquals( 1, decl.getDeclarators().size() );
|
||||||
|
assertEquals( "x", ((Declarator)decl.getDeclarators().get(0)).getName().toString() );
|
||||||
|
|
||||||
|
decl = (ParameterDeclaration)declaration.getTemplateParms().getDeclarations().get(5);
|
||||||
|
assertEquals( decl.getDeclSpecifier().getType(), DeclSpecifier.t_float );
|
||||||
|
assertEquals( 1, decl.getDeclarators().size() );
|
||||||
|
assertEquals( "y", ((Declarator)decl.getDeclarators().get(0)).getName().toString() );
|
||||||
|
|
||||||
|
parameter = (TemplateParameter)declaration.getTemplateParms().getDeclarations().get(6);
|
||||||
|
assertEquals( parameter.getKind(), TemplateParameter.k_template );
|
||||||
|
assertEquals( parameter.getTemplateParms().getDeclarations().size(), 1 );
|
||||||
|
assertNull( parameter.getName() );
|
||||||
|
TemplateParameter subParameter = (TemplateParameter)parameter.getTemplateParms().getDeclarations().get(0);
|
||||||
|
assertEquals( subParameter.getKind(), TemplateParameter.k_class );
|
||||||
|
assertEquals( subParameter.getName().toString(), "Y" );
|
||||||
|
assertNull( subParameter.getTypeId() );
|
||||||
|
|
||||||
|
parameter = (TemplateParameter)declaration.getTemplateParms().getDeclarations().get(7);
|
||||||
|
assertEquals( parameter.getKind(), TemplateParameter.k_template );
|
||||||
|
assertEquals( parameter.getTemplateParms().getDeclarations().size(), 1 );
|
||||||
|
subParameter = (TemplateParameter)parameter.getTemplateParms().getDeclarations().get(0);
|
||||||
|
assertEquals( subParameter.getKind(), TemplateParameter.k_class );
|
||||||
|
assertEquals( subParameter.getName().toString(), "A" );
|
||||||
|
assertNull( subParameter.getTypeId() );
|
||||||
|
assertEquals( parameter.getName().toString(), "AClass" );
|
||||||
assertEquals( declaration.getDeclarations().size(), 1 );
|
assertEquals( declaration.getDeclarations().size(), 1 );
|
||||||
SimpleDeclaration myArray = (SimpleDeclaration)declaration.getDeclarations().get(0);
|
SimpleDeclaration myArray = (SimpleDeclaration)declaration.getDeclarations().get(0);
|
||||||
ClassSpecifier classSpec = (ClassSpecifier)myArray.getTypeSpecifier();
|
ClassSpecifier classSpec = (ClassSpecifier)myArray.getTypeSpecifier();
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package org.eclipse.cdt.core.parser.tests;
|
package org.eclipse.cdt.core.parser.tests;
|
||||||
|
|
||||||
import java.io.StringReader;
|
import java.io.StringReader;
|
||||||
|
import java.io.StringWriter;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import junit.framework.Test;
|
import junit.framework.Test;
|
||||||
|
@ -219,13 +220,14 @@ public class ScannerTestCase extends TestCase
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
initializeScanner("3.0 0.9 .5 3. 4E5 2.01E-03");
|
initializeScanner("3.0 0.9 .5 3. 4E5 2.01E-03 ...");
|
||||||
validateFloatingPointLiteral( "3.0");
|
validateFloatingPointLiteral( "3.0");
|
||||||
validateFloatingPointLiteral( "0.9");
|
validateFloatingPointLiteral( "0.9");
|
||||||
validateFloatingPointLiteral( ".5");
|
validateFloatingPointLiteral( ".5");
|
||||||
validateFloatingPointLiteral( "3.");
|
validateFloatingPointLiteral( "3.");
|
||||||
validateFloatingPointLiteral( "4E5");
|
validateFloatingPointLiteral( "4E5");
|
||||||
validateFloatingPointLiteral( "2.01E-03" );
|
validateFloatingPointLiteral( "2.01E-03" );
|
||||||
|
validateToken( Token.tELIPSE );
|
||||||
validateEOF();
|
validateEOF();
|
||||||
}
|
}
|
||||||
catch( ScannerException se )
|
catch( ScannerException se )
|
||||||
|
@ -511,6 +513,9 @@ public class ScannerTestCase extends TestCase
|
||||||
validateToken(Token.tSEMI);
|
validateToken(Token.tSEMI);
|
||||||
validateEOF();
|
validateEOF();
|
||||||
|
|
||||||
|
initializeScanner( "/* NB: This is #if 0'd out */");
|
||||||
|
validateEOF();
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
@ -1066,10 +1071,10 @@ public class ScannerTestCase extends TestCase
|
||||||
try {
|
try {
|
||||||
Token t= scanner.nextToken();
|
Token t= scanner.nextToken();
|
||||||
if( lString )
|
if( lString )
|
||||||
assertTrue(t.type == Token.tLSTRING);
|
assertTrue(t.getType() == Token.tLSTRING);
|
||||||
else
|
else
|
||||||
assertTrue(t.type == Token.tSTRING);
|
assertTrue(t.getType() == Token.tSTRING);
|
||||||
assertTrue(t.image.equals(expectedImage));
|
assertTrue(t.getImage().equals(expectedImage));
|
||||||
} catch (Parser.EndOfFile e) {
|
} catch (Parser.EndOfFile e) {
|
||||||
assertTrue(false);
|
assertTrue(false);
|
||||||
}
|
}
|
||||||
|
@ -1138,7 +1143,7 @@ public class ScannerTestCase extends TestCase
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void test35892()
|
public void testBug35892()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -1152,11 +1157,15 @@ public class ScannerTestCase extends TestCase
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// public void testStringConcatenation()
|
// public void testBug36047()
|
||||||
// {
|
// {
|
||||||
// try
|
// try
|
||||||
// {
|
// {
|
||||||
// initializeScanner("# define MAD_VERSION_STRINGIZE(str) #str" );
|
// StringWriter writer = new StringWriter();
|
||||||
|
// writer.write( "# define MAD_VERSION_STRINGIZE(str) #str\n" );
|
||||||
|
// writer.write( "# define MAD_VERSION_STRING(num) MAD_VERSION_STRINGIZE(num)\n" );
|
||||||
|
// writer.write( "# define MAD_VERSION MAD_VERSION_STRING(MAD_VERSION_MAJOR) \".\"\n" );
|
||||||
|
// initializeScanner( writer.toString() );
|
||||||
// validateEOF();
|
// validateEOF();
|
||||||
// }
|
// }
|
||||||
// catch( ScannerException se )
|
// catch( ScannerException se )
|
||||||
|
@ -1165,6 +1174,17 @@ public class ScannerTestCase extends TestCase
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
public void testBug36045() throws Exception
|
||||||
|
{
|
||||||
|
StringBuffer buffer = new StringBuffer();
|
||||||
|
buffer.append( '"' );
|
||||||
|
buffer.append( '\\');
|
||||||
|
buffer.append( '"');
|
||||||
|
buffer.append( '"');
|
||||||
|
initializeScanner( buffer.toString());
|
||||||
|
validateString( "\\\"");
|
||||||
|
}
|
||||||
|
|
||||||
public void testConditionalWithBraces()
|
public void testConditionalWithBraces()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|
Loading…
Add table
Reference in a new issue