1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Further Scanner2 work and improvements.

This commit is contained in:
John Camelon 2004-07-29 14:31:21 +00:00
parent 9b08f32b17
commit d134c5e5d3
4 changed files with 25 additions and 8 deletions

View file

@ -12,6 +12,7 @@ package org.eclipse.cdt.core.parser.tests;
import java.util.Iterator;
import org.eclipse.cdt.core.parser.ParserFactory;
import org.eclipse.cdt.core.parser.ast.IASTAbstractTypeSpecifierDeclaration;
import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier;
import org.eclipse.cdt.core.parser.ast.IASTExpression;
@ -248,7 +249,10 @@ public class CompleteParseASTExpressionTest extends CompleteParseBaseTest{
i = getDeclarations( test );
IASTVariable someInt = (IASTVariable) i.next();
IASTExpression exp = someInt.getInitializerClause().getAssigmentExpression();
assertEquals( exp.toString(), "foo(int(3), short(4), double(3.0), float(4.0), char('a'), wchar_t('a'), signed(2), unsigned(3), bool(false), long(3))" ); //$NON-NLS-1$
if( ParserFactory.USE_NEW_SCANNER )
assertEquals( exp.toString(), "foo(int(3), short(4), double(3.0), float(4.0), char('a'), wchar_t('a'), signed(2), unsigned(3), bool(false), long(3L))" ); //$NON-NLS-1$
else
assertEquals( exp.toString(), "foo(int(3), short(4), double(3.0), float(4.0), char('a'), wchar_t('a'), signed(2), unsigned(3), bool(false), long(3))" ); //$NON-NLS-1$
}
// Kind POSTFIX_TYPENAME_IDENTIFIER

View file

@ -337,14 +337,24 @@ public class ASTUtil {
return expression.getLiteralString();
StringBuffer buffer = new StringBuffer();
boolean quoted = false;
String literalString = expression.getLiteralString();
if( kind == Kind.PRIMARY_CHAR_LITERAL ){
buffer.append( '\'' );
buffer.append( expression.getLiteralString() );
buffer.append( '\'' );
quoted = ( literalString.charAt(0) == literalString.charAt(literalString.length() - 1 ) &&
literalString.charAt(0) == '\'' );
if( !quoted )
buffer.append( '\'' );
buffer.append( literalString );
if( !quoted )
buffer.append( '\'' );
} else if( kind == Kind.PRIMARY_STRING_LITERAL ) {
buffer.append( '"' );
quoted = ( literalString.charAt(0) == literalString.charAt(literalString.length() - 1 ) &&
literalString.charAt(0) == '\"' );
if( !quoted )
buffer.append( '"' );
buffer.append( expression.getLiteralString() );
buffer.append( '"' );
if( !quoted )
buffer.append( '"' );
}
return buffer.toString();
}

View file

@ -1320,7 +1320,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
parameters = expResultList.getResultList();
}else {
parameters = new ArrayList();
parameters = new ArrayList(1);
parameters.add(expResult.getResult());
}
if( functionScope.equals( startingScope ) )

View file

@ -10,6 +10,7 @@
***********************************************************************/
package org.eclipse.cdt.internal.core.parser.token;
import org.eclipse.cdt.core.parser.ParserFactory;
import org.eclipse.cdt.internal.core.parser.scanner.ContextStack;
import org.eclipse.cdt.internal.core.parser.scanner.IScannerContext;
@ -76,6 +77,8 @@ public class ImagedToken extends SimpleToken {
public int getLength() {
if( getCharImage() == null )
return 0;
if( ParserFactory.USE_NEW_SCANNER )
return getCharImage().length;
switch( getType() )
{
case tSTRING: