mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-08 10:16:03 +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 )
|
||||
{
|
||||
ParameterDeclarationClause clause = (ParameterDeclarationClause)container;
|
||||
IScope clause = (IScope)container;
|
||||
ParameterDeclaration pd = new ParameterDeclaration();
|
||||
clause.addDeclaration( 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)
|
||||
*/
|
||||
public Object templateTypeParameterBegin(Object templDecl, Token kind) {
|
||||
TemplateParameter.ITemplateParameterList list = (TemplateParameter.ITemplateParameterList)templDecl;
|
||||
TemplateParameterList list = (TemplateParameterList)templDecl;
|
||||
int k;
|
||||
switch( kind.getType() )
|
||||
{
|
||||
|
@ -800,10 +800,15 @@ public class DOMBuilder implements IParserCallback
|
|||
case Token.t_typename:
|
||||
k= TemplateParameter.k_typename;
|
||||
break;
|
||||
case Token.t_template:
|
||||
k= TemplateParameter.k_template;
|
||||
break;
|
||||
default:
|
||||
k = 0;
|
||||
}
|
||||
return new TemplateParameter( list, k );
|
||||
TemplateParameter p = new TemplateParameter( k );
|
||||
list.addDeclaration(p);
|
||||
return p;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
@ -824,8 +829,6 @@ public class DOMBuilder implements IParserCallback
|
|||
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#templateTypeParameterEnd(java.lang.Object)
|
||||
*/
|
||||
public void templateTypeParameterEnd(Object typeParm) {
|
||||
TemplateParameter parm = ((TemplateParameter)typeParm);
|
||||
parm.getContainer().addTemplateParameter(parm);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
@ -841,4 +844,20 @@ public class DOMBuilder implements IParserCallback
|
|||
public void pointerOperatorAbort(Object ptrOperator) {
|
||||
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.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.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
|
||||
*
|
||||
*/
|
||||
public class TemplateDeclaration extends Declaration implements IScope, TemplateParameter.ITemplateParameterList {
|
||||
public class TemplateDeclaration extends Declaration implements IScope, ITemplateParameterListOwner {
|
||||
|
||||
private final boolean exported;
|
||||
private IScope ownerScope;
|
||||
private List declarations = new ArrayList();
|
||||
private TemplateParameterList templateParms = null;
|
||||
|
||||
public TemplateDeclaration( IScope ownerScope, boolean exported )
|
||||
{
|
||||
|
@ -60,20 +61,18 @@ public class TemplateDeclaration extends Declaration implements IScope, Template
|
|||
return ownerScope;
|
||||
}
|
||||
|
||||
|
||||
private List templateParameters = new ArrayList();
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.dom.TemplateParameter.ITemplateParameterList#getTemplateParameters()
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public List getTemplateParameters() {
|
||||
return Collections.unmodifiableList(templateParameters);
|
||||
public TemplateParameterList getTemplateParms() {
|
||||
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) {
|
||||
templateParameters.add( parm );
|
||||
public void setTemplateParms(TemplateParameterList list) {
|
||||
templateParms = list;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -12,42 +12,29 @@
|
|||
***********************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.internal.core.parser.util.Name;
|
||||
|
||||
/**
|
||||
* @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;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
private Name name = null;
|
||||
private Name typeId = null;
|
||||
/**
|
||||
* @return ITemplateParameterList
|
||||
*/
|
||||
public ITemplateParameterList getContainer() {
|
||||
return container;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return int
|
||||
|
@ -86,4 +73,20 @@ public class TemplateParameter {
|
|||
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
|
||||
Updated Scanner to convert control-characters to ' '.
|
||||
Fixed logic error in SimpleDeclarationWrapper.
|
||||
|
|
|
@ -936,4 +936,20 @@ org.eclipse.cdt.internal.core.newparser.IParserCallback#beginSimpleDeclaration(T
|
|||
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) {
|
||||
}
|
||||
|
||||
/* (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 templateDeclarationEnd( Object templateDecl );
|
||||
|
||||
public Object templateParameterListBegin( Object declaration );
|
||||
public void templateParameterListEnd( Object parameterList );
|
||||
|
||||
public Object templateTypeParameterBegin( Object templDecl, Token kind );
|
||||
public void templateTypeParameterName( 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)
|
||||
*/
|
||||
public Object enumSpecifierBegin(Object container, Token enumKey) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -422,31 +421,24 @@ public class NullParserCallback implements IParserCallback {
|
|||
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#enumSpecifierId(java.lang.Object)
|
||||
*/
|
||||
public void enumSpecifierId(Object enumSpec) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#enumSpecifierAbort(java.lang.Object)
|
||||
*/
|
||||
public void enumSpecifierAbort(Object enumSpec) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#enumSpecifierEnd(java.lang.Object)
|
||||
*/
|
||||
public void enumSpecifierEnd(Object enumSpec) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#enumDefinitionBegin(java.lang.Object)
|
||||
*/
|
||||
public Object enumDefinitionBegin(Object enumSpec) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -454,16 +446,12 @@ public class NullParserCallback implements IParserCallback {
|
|||
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#enumDefinitionId(java.lang.Object)
|
||||
*/
|
||||
public void enumDefinitionId(Object enumDefn) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#enumDefinitionEnd(java.lang.Object)
|
||||
*/
|
||||
public void enumDefinitionEnd(Object enumDefn) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
@ -611,4 +599,17 @@ public class NullParserCallback implements IParserCallback {
|
|||
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 {
|
||||
// if we have gotten this far then we have a true template-declaration
|
||||
// iterate through the template parameter list
|
||||
|
||||
Object templateParameterList = null;
|
||||
|
||||
try { templateParameterList = callback.templateParameterListBegin( templateDeclaration ); } catch( Exception e ) {}
|
||||
|
||||
for ( ; ; )
|
||||
{
|
||||
if( LT(1) == Token.tGT ) return;
|
||||
Object currentTemplateParm = null;
|
||||
if( LT(1) == Token.t_class || LT(1) == Token.t_typename )
|
||||
{
|
||||
Object currentTemplateParm = null;
|
||||
try
|
||||
{
|
||||
try{
|
||||
currentTemplateParm = callback.templateTypeParameterBegin(
|
||||
templateDeclaration, consume() );
|
||||
templateParameterList, consume() );
|
||||
} catch( Exception e ) {}
|
||||
if( LT(1) == Token.tIDENTIFIER ) // optional identifier
|
||||
{
|
||||
|
@ -359,27 +364,25 @@ c, quick);
|
|||
}
|
||||
else if( LT(1) == Token.t_template )
|
||||
{
|
||||
try
|
||||
Token kind = consume( Token.t_template );
|
||||
consume( Token.tLT );
|
||||
Object newTemplateParm = null;
|
||||
try{ newTemplateParm = callback.templateTypeParameterBegin(templateParameterList,kind ); } catch( Exception e ) {}
|
||||
templateParameterList( newTemplateParm );
|
||||
consume( Token.tGT );
|
||||
consume( Token.t_class );
|
||||
if( LT(1) == Token.tIDENTIFIER ) // optional identifier
|
||||
{
|
||||
consume( Token.t_template );
|
||||
consume( Token.tLT );
|
||||
Object newTemplateDeclaration = null;
|
||||
templateParameterList( newTemplateDeclaration );
|
||||
consume( Token.tGT );
|
||||
consume( Token.t_class );
|
||||
if( LT(1) == Token.tIDENTIFIER ) // optional identifier
|
||||
identifier();
|
||||
try{ callback.templateTypeParameterName( newTemplateParm );} catch( Exception e ) {}
|
||||
if( LT(1) == Token.tASSIGN ) // optional = type-id
|
||||
{
|
||||
identifier();
|
||||
if( LT(1) == Token.tASSIGN ) // optional = type-id
|
||||
{
|
||||
consume( Token.tASSIGN );
|
||||
// id-expression()
|
||||
}
|
||||
consume( Token.tASSIGN );
|
||||
name();
|
||||
try{ callback.templateTypeParameterInitialTypeId( newTemplateParm );} catch( Exception e ) {}
|
||||
}
|
||||
}
|
||||
catch( Backtrack bt )
|
||||
{
|
||||
}
|
||||
try{ callback.templateTypeParameterEnd( newTemplateParm );} catch( Exception e ) {}
|
||||
}
|
||||
else if( LT(1) == Token.tCOMMA )
|
||||
{
|
||||
|
@ -388,7 +391,7 @@ c, quick);
|
|||
}
|
||||
else
|
||||
{
|
||||
parameterDeclaration( templateDeclaration );
|
||||
parameterDeclaration( templateParameterList );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1069,7 +1072,7 @@ c, quick);
|
|||
switch (LT(1)) {
|
||||
case Token.tLPAREN:
|
||||
// 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
|
||||
Object clause = null;
|
||||
|
@ -1983,11 +1986,12 @@ c, quick);
|
|||
switch (type) {
|
||||
// TO DO: we need more literals...
|
||||
case Token.tINTEGER:
|
||||
try{ callback.expressionTerminal(expression, consume());} catch( Exception e ) {}
|
||||
return;
|
||||
case Token.tSTRING:
|
||||
case Token.t_false:
|
||||
case Token.t_true:
|
||||
try{ callback.expressionTerminal(expression, consume());} catch( Exception e ) {}
|
||||
return;
|
||||
|
||||
case Token.tIDENTIFIER:
|
||||
try{ callback.expressionTerminal(expression, consume());} catch( Exception e ) {}
|
||||
return;
|
||||
|
@ -2068,7 +2072,7 @@ c, quick);
|
|||
throw e;
|
||||
} catch (ScannerException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
return fetchToken();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -359,7 +359,12 @@ public class Scanner implements IScanner {
|
|||
callback = c;
|
||||
}
|
||||
|
||||
private int getChar() {
|
||||
private int getChar()
|
||||
{
|
||||
return getChar( false );
|
||||
}
|
||||
|
||||
private int getChar( boolean insideString ) {
|
||||
int c = NOCHAR;
|
||||
if (currentContext == null)
|
||||
// past the end of file
|
||||
|
@ -392,16 +397,18 @@ public class Scanner implements IScanner {
|
|||
}
|
||||
} while (!done);
|
||||
|
||||
if (c == '\\') {
|
||||
c = getChar();
|
||||
if (c == '\r') {
|
||||
c = getChar();
|
||||
if (c == '\n')
|
||||
c = getChar();
|
||||
} else if (c == '\n')
|
||||
c = getChar();
|
||||
if( ! insideString )
|
||||
{
|
||||
if (c == '\\') {
|
||||
c = getChar(false);
|
||||
if (c == '\r') {
|
||||
c = getChar(false);
|
||||
if (c == '\n')
|
||||
c = getChar(false);
|
||||
} else if (c == '\n')
|
||||
c = getChar(false);
|
||||
}
|
||||
}
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
|
@ -448,9 +455,31 @@ public class Scanner implements IScanner {
|
|||
|
||||
while (c != NOCHAR) {
|
||||
if ( ! passOnToClient ) {
|
||||
while (c != '#') {
|
||||
|
||||
int state = 0;
|
||||
|
||||
while (c != NOCHAR && c != '#' )
|
||||
{
|
||||
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')) {
|
||||
|
@ -475,12 +504,16 @@ public class Scanner implements IScanner {
|
|||
}
|
||||
|
||||
// string
|
||||
StringBuffer buff = new StringBuffer();
|
||||
c = getChar();
|
||||
StringBuffer buff = new StringBuffer();
|
||||
int previous = c;
|
||||
c = getChar(true);
|
||||
|
||||
while (c != '"' && c != '\n') {
|
||||
for( ; ; )
|
||||
{
|
||||
if( ( c == '"' && previous != '\\' )|| ( c == '\n') )break;
|
||||
buff.append((char) c);
|
||||
c = getChar();
|
||||
previous = c;
|
||||
c = getChar(true);
|
||||
}
|
||||
|
||||
if (c != '\n')
|
||||
|
@ -608,7 +641,12 @@ public class Scanner implements IScanner {
|
|||
if( 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;
|
||||
c= getChar();
|
||||
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");
|
||||
|
||||
// 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
|
||||
ParserSymbolTableTest. modifications to using declaration tests to reflect changes in the
|
||||
symbol table. Also added testUserDefinedConversionSequences()
|
||||
|
||||
2003-04-01
|
||||
2003-04-01 John Camelon
|
||||
Added testBug35906() to DOMTests.
|
||||
|
||||
2003-03-31 John Camelon
|
||||
|
|
|
@ -893,26 +893,53 @@ public class DOMTests extends TestCase {
|
|||
}
|
||||
|
||||
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 );
|
||||
TemplateDeclaration declaration = (TemplateDeclaration)tu.getDeclarations().get(0);
|
||||
assertEquals( declaration.getTemplateParameters().size(), 4 );
|
||||
TemplateParameter parameter = (TemplateParameter)declaration.getTemplateParameters().get(0);
|
||||
assertEquals( declaration.getTemplateParms().getDeclarations().size(), 8 );
|
||||
TemplateParameter parameter = (TemplateParameter)declaration.getTemplateParms().getDeclarations().get(0);
|
||||
assertEquals( parameter.getKind(), TemplateParameter.k_class);
|
||||
assertEquals( parameter.getName().toString(), "T" );
|
||||
assertNull( parameter.getTypeId());
|
||||
parameter = (TemplateParameter)declaration.getTemplateParameters().get(1);
|
||||
parameter = (TemplateParameter)declaration.getTemplateParms().getDeclarations().get(1);
|
||||
assertEquals( parameter.getKind(), TemplateParameter.k_typename);
|
||||
assertEquals( parameter.getName().toString(), "Tibor" );
|
||||
assertEquals( parameter.getTypeId().toString(), "junk");
|
||||
parameter = (TemplateParameter)declaration.getTemplateParameters().get(2);
|
||||
parameter = (TemplateParameter)declaration.getTemplateParms().getDeclarations().get(2);
|
||||
assertEquals( parameter.getKind(), TemplateParameter.k_class);
|
||||
assertNull( parameter.getName() );
|
||||
assertNull( parameter.getTypeId());
|
||||
parameter = (TemplateParameter)declaration.getTemplateParameters().get(3);
|
||||
parameter = (TemplateParameter)declaration.getTemplateParms().getDeclarations().get(3);
|
||||
assertEquals( parameter.getKind(), TemplateParameter.k_typename);
|
||||
assertNull( parameter.getName() );
|
||||
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 );
|
||||
SimpleDeclaration myArray = (SimpleDeclaration)declaration.getDeclarations().get(0);
|
||||
ClassSpecifier classSpec = (ClassSpecifier)myArray.getTypeSpecifier();
|
||||
|
@ -920,7 +947,7 @@ public class DOMTests extends TestCase {
|
|||
assertEquals( classSpec.getName().toString(), "myarray");
|
||||
assertEquals( 0, classSpec.getDeclarations().size() );
|
||||
}
|
||||
|
||||
|
||||
public void testStruct() throws Exception
|
||||
{
|
||||
StringWriter writer = new StringWriter();
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package org.eclipse.cdt.core.parser.tests;
|
||||
|
||||
import java.io.StringReader;
|
||||
import java.io.StringWriter;
|
||||
import java.util.List;
|
||||
|
||||
import junit.framework.Test;
|
||||
|
@ -219,13 +220,14 @@ public class ScannerTestCase extends TestCase
|
|||
{
|
||||
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( "0.9");
|
||||
validateFloatingPointLiteral( ".5");
|
||||
validateFloatingPointLiteral( "3.");
|
||||
validateFloatingPointLiteral( "4E5");
|
||||
validateFloatingPointLiteral( "2.01E-03" );
|
||||
validateToken( Token.tELIPSE );
|
||||
validateEOF();
|
||||
}
|
||||
catch( ScannerException se )
|
||||
|
@ -510,6 +512,9 @@ public class ScannerTestCase extends TestCase
|
|||
validateInteger("101");
|
||||
validateToken(Token.tSEMI);
|
||||
validateEOF();
|
||||
|
||||
initializeScanner( "/* NB: This is #if 0'd out */");
|
||||
validateEOF();
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
|
@ -1066,10 +1071,10 @@ public class ScannerTestCase extends TestCase
|
|||
try {
|
||||
Token t= scanner.nextToken();
|
||||
if( lString )
|
||||
assertTrue(t.type == Token.tLSTRING);
|
||||
assertTrue(t.getType() == Token.tLSTRING);
|
||||
else
|
||||
assertTrue(t.type == Token.tSTRING);
|
||||
assertTrue(t.image.equals(expectedImage));
|
||||
assertTrue(t.getType() == Token.tSTRING);
|
||||
assertTrue(t.getImage().equals(expectedImage));
|
||||
} catch (Parser.EndOfFile e) {
|
||||
assertTrue(false);
|
||||
}
|
||||
|
@ -1138,7 +1143,7 @@ public class ScannerTestCase extends TestCase
|
|||
}
|
||||
}
|
||||
|
||||
public void test35892()
|
||||
public void testBug35892()
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -1152,11 +1157,15 @@ public class ScannerTestCase extends TestCase
|
|||
}
|
||||
}
|
||||
|
||||
// public void testStringConcatenation()
|
||||
// public void testBug36047()
|
||||
// {
|
||||
// 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();
|
||||
// }
|
||||
// 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()
|
||||
{
|
||||
try
|
||||
|
|
Loading…
Add table
Reference in a new issue