mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-06 17:26:01 +02:00
org.eclipse.cdt.core<BR>
Restructuring of the parser extension packages. <BR> Introduce IParserExtension and IASTFactory mechanisms w/partial implementation for GCC. <BR> Introduce IGCCToken and GCCKeywords and fleshed out GCCScannerExtension implementation and interworking with Scanner. <BR> Fixed https://bugs.eclipse.org/bugs/show_bug.cgi?id=39697<BR> Fixed https://bugs.eclipse.org/bugs/show_bug.cgi?id=39695<BR> Fixed https://bugs.eclipse.org/bugs/show_bug.cgi?id=39684<BR> <BR> org.eclipse.cdt.core.tests<BR> Moved testBug39684() & testBug39695() from ASTFailedTests to QuickParseASTTests.<BR> Updated CompleteParseASTTest::testBug39697().<BR> Added CompleteParseASTTest::testBug39684() & CompleteParseASTTest::testBug39695().
This commit is contained in:
parent
b9541fc2a5
commit
b8154fb0fc
45 changed files with 1358 additions and 468 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
2004-04-20 John Camelon
|
||||||
|
Moved testBug39684() & testBug39695() from ASTFailedTests to QuickParseASTTests.
|
||||||
|
Updated CompleteParseASTTest::testBug39697().
|
||||||
|
Added CompleteParseASTTest::testBug39684() & CompleteParseASTTest::testBug39695().
|
||||||
|
|
||||||
2004-04-20 David Inglis
|
2004-04-20 David Inglis
|
||||||
The CoreModel interfaces throw much more exception, we need to log them for errors.
|
The CoreModel interfaces throw much more exception, we need to log them for errors.
|
||||||
|
|
||||||
|
|
|
@ -74,10 +74,7 @@ public class ASTFailedTests extends BaseASTTest
|
||||||
"The expected error did not occur.",
|
"The expected error did not occur.",
|
||||||
typedef.getName().equals( "name" ) );
|
typedef.getName().equals( "name" ) );
|
||||||
}
|
}
|
||||||
public void testBug39684() throws Exception
|
|
||||||
{
|
|
||||||
assertCodeFailsParse("typeof(foo(1)) bar () { return foo(1); }");
|
|
||||||
}
|
|
||||||
public void testBug39686() throws Exception
|
public void testBug39686() throws Exception
|
||||||
{
|
{
|
||||||
Writer code = new StringWriter();
|
Writer code = new StringWriter();
|
||||||
|
@ -115,10 +112,7 @@ public class ASTFailedTests extends BaseASTTest
|
||||||
assertCodeFailsParse(code.toString());
|
assertCodeFailsParse(code.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testBug39695() throws Exception
|
|
||||||
{
|
|
||||||
assertCodeFailsParse("int a = __alignof__ (int);");
|
|
||||||
}
|
|
||||||
public void testBug39695A() throws Exception
|
public void testBug39695A() throws Exception
|
||||||
{
|
{
|
||||||
assertCodeFailsParse("int foo asm (\"myfoo\") = 2;");
|
assertCodeFailsParse("int foo asm (\"myfoo\") = 2;");
|
||||||
|
|
|
@ -42,6 +42,8 @@ import org.eclipse.cdt.core.parser.ast.IASTUsingDeclaration;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTUsingDirective;
|
import org.eclipse.cdt.core.parser.ast.IASTUsingDirective;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTVariable;
|
import org.eclipse.cdt.core.parser.ast.IASTVariable;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTVariableReference;
|
import org.eclipse.cdt.core.parser.ast.IASTVariableReference;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.gcc.IASTGCCExpression;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.gcc.IASTGCCSimpleTypeSpecifier;
|
||||||
import org.eclipse.cdt.internal.core.parser.ParserException;
|
import org.eclipse.cdt.internal.core.parser.ParserException;
|
||||||
|
|
||||||
|
|
||||||
|
@ -1532,25 +1534,27 @@ public class CompleteParseASTTest extends CompleteParseBaseTest
|
||||||
IASTVariable signedInt = (IASTVariable) i.next();
|
IASTVariable signedInt = (IASTVariable) i.next();
|
||||||
assertTrue( ((IASTSimpleTypeSpecifier) signedInt.getAbstractDeclaration().getTypeSpecifier()).isSigned() );
|
assertTrue( ((IASTSimpleTypeSpecifier) signedInt.getAbstractDeclaration().getTypeSpecifier()).isSigned() );
|
||||||
assertFalse( i.hasNext() );
|
assertFalse( i.hasNext() );
|
||||||
writer = new StringWriter();
|
for( int j = 0; j < 2; ++j )
|
||||||
writer.write( "int * __restrict__ resPointer1;\n");
|
|
||||||
writer.write( "int * __restrict resPointer2;\n");
|
|
||||||
i = parse( writer.toString(), true, ParserLanguage.C ).getDeclarations();
|
|
||||||
int count = 0;
|
|
||||||
while( i.hasNext() )
|
|
||||||
{
|
{
|
||||||
++count;
|
writer = new StringWriter();
|
||||||
IASTVariable resPointer = (IASTVariable) i.next();
|
writer.write( "int * __restrict__ resPointer1;\n");
|
||||||
Iterator pOps = resPointer.getAbstractDeclaration().getPointerOperators();
|
writer.write( "int * __restrict resPointer2;\n");
|
||||||
assertTrue( pOps.hasNext() );
|
i = parse( writer.toString(), true, ((j == 0 )? ParserLanguage.C : ParserLanguage.CPP) ).getDeclarations();
|
||||||
ASTPointerOperator op = (ASTPointerOperator) pOps.next();
|
int count = 0;
|
||||||
assertFalse( pOps.hasNext() );
|
while( i.hasNext() )
|
||||||
assertEquals( op, ASTPointerOperator.RESTRICT_POINTER );
|
{
|
||||||
}
|
++count;
|
||||||
|
IASTVariable resPointer = (IASTVariable) i.next();
|
||||||
assertEquals( count, 2 );
|
Iterator pOps = resPointer.getAbstractDeclaration().getPointerOperators();
|
||||||
}
|
assertTrue( pOps.hasNext() );
|
||||||
|
ASTPointerOperator op = (ASTPointerOperator) pOps.next();
|
||||||
|
assertFalse( pOps.hasNext() );
|
||||||
|
assertEquals( op, ASTPointerOperator.RESTRICT_POINTER );
|
||||||
|
}
|
||||||
|
|
||||||
|
assertEquals( count, 2 );
|
||||||
|
}
|
||||||
|
}
|
||||||
public void testBug59149() throws Exception
|
public void testBug59149() throws Exception
|
||||||
{
|
{
|
||||||
Writer writer = new StringWriter();
|
Writer writer = new StringWriter();
|
||||||
|
@ -1560,5 +1564,20 @@ public class CompleteParseASTTest extends CompleteParseBaseTest
|
||||||
Iterator i = parse( writer.toString() ).getDeclarations();
|
Iterator i = parse( writer.toString() ).getDeclarations();
|
||||||
IASTClassSpecifier A = (IASTClassSpecifier) ((IASTAbstractTypeSpecifierDeclaration)i.next()).getTypeSpecifier();
|
IASTClassSpecifier A = (IASTClassSpecifier) ((IASTAbstractTypeSpecifierDeclaration)i.next()).getTypeSpecifier();
|
||||||
IASTClassSpecifier B = (IASTClassSpecifier) ((IASTAbstractTypeSpecifierDeclaration)i.next()).getTypeSpecifier();
|
IASTClassSpecifier B = (IASTClassSpecifier) ((IASTAbstractTypeSpecifierDeclaration)i.next()).getTypeSpecifier();
|
||||||
}
|
}
|
||||||
|
public void testBug39695() throws Exception
|
||||||
|
{
|
||||||
|
Iterator i = parse("int a = __alignof__ (int);").getDeclarations();
|
||||||
|
IASTVariable a = (IASTVariable) i.next();
|
||||||
|
assertFalse( i.hasNext() );
|
||||||
|
assertEquals( a.getInitializerClause().getAssigmentExpression().getExpressionKind(), IASTGCCExpression.Kind.UNARY_ALIGNOF_TYPEID );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testBug39684() throws Exception
|
||||||
|
{
|
||||||
|
IASTFunction bar = (IASTFunction) parse("typeof(foo(1)) bar () { return foo(1); }").getDeclarations().next();
|
||||||
|
|
||||||
|
IASTSimpleTypeSpecifier simpleTypeSpec = ((IASTSimpleTypeSpecifier)bar.getReturnType().getTypeSpecifier());
|
||||||
|
assertEquals( simpleTypeSpec.getType(), IASTGCCSimpleTypeSpecifier.Type.TYPEOF );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2177,4 +2177,14 @@ public class QuickParseASTTests extends BaseASTTest
|
||||||
assertTrue( f.isFriend() );
|
assertTrue( f.isFriend() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testBug39695() throws Exception
|
||||||
|
{
|
||||||
|
parse("int a = __alignof__ (int);");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testBug39684() throws Exception
|
||||||
|
{
|
||||||
|
parse("typeof(foo(1)) bar () { return foo(1); }");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,3 +1,11 @@
|
||||||
|
2004-04-20 John Camelon
|
||||||
|
Restructuring of the parser extension packages.
|
||||||
|
Introduce IParserExtension and IASTFactory mechanisms w/partial implementation for GCC.
|
||||||
|
Introduce IGCCToken and GCCKeywords and fleshed out GCCScannerExtension implementation and interworking with Scanner.
|
||||||
|
Fixed https://bugs.eclipse.org/bugs/show_bug.cgi?id=39697
|
||||||
|
Fixed https://bugs.eclipse.org/bugs/show_bug.cgi?id=39695
|
||||||
|
Fixed https://bugs.eclipse.org/bugs/show_bug.cgi?id=39684
|
||||||
|
|
||||||
2004-04-19 Andrew Niefer
|
2004-04-19 Andrew Niefer
|
||||||
fix bug 59149 [Parser] Redundant friend declaration fails parse
|
fix bug 59149 [Parser] Redundant friend declaration fails parse
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* Copyright (c) 2002,2003 Rational Software Corporation and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Common Public License v0.5
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/cpl-v05.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* IBM Rational Software - Initial API and implementation */
|
||||||
|
|
||||||
|
package org.eclipse.cdt.core.parser;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jcamelon
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class GCCKeywords {
|
||||||
|
|
||||||
|
public static final String TYPEOF = "typeof"; //$NON-NLS-1$
|
||||||
|
public static final String __ALIGNOF__ = "__alignof__"; //$NON-NLS-1$
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,22 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* Copyright (c) 2002,2003 Rational Software Corporation and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Common Public License v0.5
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/cpl-v05.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* IBM Rational Software - Initial API and implementation */
|
||||||
|
|
||||||
|
package org.eclipse.cdt.core.parser;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jcamelon
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public interface IGCCToken extends IToken {
|
||||||
|
|
||||||
|
public static final int t_typeof = tLAST + 1;
|
||||||
|
public static final int t___alignof__ = tLAST + 2;
|
||||||
|
|
||||||
|
}
|
|
@ -15,6 +15,7 @@ import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTFactory;
|
import org.eclipse.cdt.core.parser.ast.IASTFactory;
|
||||||
import org.eclipse.cdt.core.parser.extension.ExtensionDialect;
|
import org.eclipse.cdt.core.parser.extension.ExtensionDialect;
|
||||||
|
import org.eclipse.cdt.core.parser.extension.IParserExtension;
|
||||||
import org.eclipse.cdt.core.parser.extension.IParserExtensionFactory;
|
import org.eclipse.cdt.core.parser.extension.IParserExtensionFactory;
|
||||||
import org.eclipse.cdt.internal.core.parser.CompleteParser;
|
import org.eclipse.cdt.internal.core.parser.CompleteParser;
|
||||||
import org.eclipse.cdt.internal.core.parser.CompletionParser;
|
import org.eclipse.cdt.internal.core.parser.CompletionParser;
|
||||||
|
@ -43,11 +44,11 @@ public class ParserFactory {
|
||||||
public static IASTFactory createASTFactory( IFilenameProvider provider, ParserMode mode, ParserLanguage language )
|
public static IASTFactory createASTFactory( IFilenameProvider provider, ParserMode mode, ParserLanguage language )
|
||||||
{
|
{
|
||||||
if( mode == ParserMode.QUICK_PARSE )
|
if( mode == ParserMode.QUICK_PARSE )
|
||||||
return new QuickParseASTFactory( extensionFactory.createASTExtensionFactory( ParserMode.QUICK_PARSE ) );
|
return new QuickParseASTFactory();
|
||||||
else if( mode == ParserMode.EXPRESSION_PARSE )
|
else if( mode == ParserMode.EXPRESSION_PARSE )
|
||||||
return new ExpressionParseASTFactory( extensionFactory.createASTExtensionFactory( ParserMode.EXPRESSION_PARSE ) );
|
return new ExpressionParseASTFactory( extensionFactory.createASTExtension( mode ));
|
||||||
else
|
else
|
||||||
return new CompleteParseASTFactory( provider, language, mode, extensionFactory.createASTExtensionFactory( ParserMode.COMPLETE_PARSE ) );
|
return new CompleteParseASTFactory( provider, language, mode, extensionFactory.createASTExtension( mode ));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IParser createParser( IScanner scanner, ISourceElementRequestor callback, ParserMode mode, ParserLanguage language, IParserLogService log ) throws ParserFactoryError
|
public static IParser createParser( IScanner scanner, ISourceElementRequestor callback, ParserMode mode, ParserLanguage language, IParserLogService log ) throws ParserFactoryError
|
||||||
|
@ -57,16 +58,17 @@ public class ParserFactory {
|
||||||
IParserLogService logService = ( log == null ) ? createDefaultLogService() : log;
|
IParserLogService logService = ( log == null ) ? createDefaultLogService() : log;
|
||||||
ParserMode ourMode = ( (mode == null )? ParserMode.COMPLETE_PARSE : mode );
|
ParserMode ourMode = ( (mode == null )? ParserMode.COMPLETE_PARSE : mode );
|
||||||
ISourceElementRequestor ourCallback = (( callback == null) ? new NullSourceElementRequestor() : callback );
|
ISourceElementRequestor ourCallback = (( callback == null) ? new NullSourceElementRequestor() : callback );
|
||||||
|
IParserExtension extension = extensionFactory.createParserExtension();
|
||||||
if( ourMode == ParserMode.COMPLETE_PARSE)
|
if( ourMode == ParserMode.COMPLETE_PARSE)
|
||||||
return new CompleteParser( scanner, ourCallback, language, logService );
|
return new CompleteParser( scanner, ourCallback, language, logService, extension);
|
||||||
else if( ourMode == ParserMode.STRUCTURAL_PARSE )
|
else if( ourMode == ParserMode.STRUCTURAL_PARSE )
|
||||||
return new StructuralParser( scanner, ourCallback, language, logService );
|
return new StructuralParser( scanner, ourCallback, language, logService, extension );
|
||||||
else if( ourMode == ParserMode.COMPLETION_PARSE )
|
else if( ourMode == ParserMode.COMPLETION_PARSE )
|
||||||
return new CompletionParser( scanner, ourCallback, language, logService );
|
return new CompletionParser( scanner, ourCallback, language, logService, extension );
|
||||||
else if (ourMode == ParserMode.SELECTION_PARSE )
|
else if (ourMode == ParserMode.SELECTION_PARSE )
|
||||||
return new SelectionParser( scanner, ourCallback, language, logService );
|
return new SelectionParser( scanner, ourCallback, language, logService, extension );
|
||||||
else
|
else
|
||||||
return new QuickParser( scanner, ourCallback, language, logService );
|
return new QuickParser( scanner, ourCallback, language, logService, extension );
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IScanner createScanner( Reader input, String fileName, IScannerInfo config, ParserMode mode, ParserLanguage language, ISourceElementRequestor requestor, IParserLogService log, List workingCopies ) throws ParserFactoryError
|
public static IScanner createScanner( Reader input, String fileName, IScannerInfo config, ParserMode mode, ParserLanguage language, ISourceElementRequestor requestor, IParserLogService log, List workingCopies ) throws ParserFactoryError
|
||||||
|
|
|
@ -111,11 +111,13 @@ public interface IASTExpression extends ISourceElementCallbackDelegate
|
||||||
public static final Kind ASSIGNMENTEXPRESSION_XOR = new Kind( 83 );
|
public static final Kind ASSIGNMENTEXPRESSION_XOR = new Kind( 83 );
|
||||||
public static final Kind EXPRESSIONLIST = new Kind( 84 );
|
public static final Kind EXPRESSIONLIST = new Kind( 84 );
|
||||||
|
|
||||||
|
protected static final int LAST_KIND = 84;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param enumValue
|
* @param enumValue
|
||||||
*/
|
*/
|
||||||
private Kind(int enumValue)
|
protected Kind(int enumValue)
|
||||||
{
|
{
|
||||||
super(enumValue);
|
super(enumValue);
|
||||||
}
|
}
|
||||||
|
@ -216,7 +218,11 @@ public interface IASTExpression extends ISourceElementCallbackDelegate
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public String getKindName() {
|
public String getKindName() {
|
||||||
return (String) names.get(this);
|
|
||||||
|
Object check = names.get(this);
|
||||||
|
if( check != null )
|
||||||
|
return (String) check;
|
||||||
|
return "EXTENSION SPECIFIED"; //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isPostfixMemberReference()
|
public boolean isPostfixMemberReference()
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
* IBM Rational Software - Initial API and implementation
|
* IBM Rational Software - Initial API and implementation
|
||||||
***********************************************************************/
|
***********************************************************************/
|
||||||
package org.eclipse.cdt.core.parser.ast;
|
package org.eclipse.cdt.core.parser.ast;
|
||||||
|
import java.util.Hashtable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.parser.IMacroDescriptor;
|
import org.eclipse.cdt.core.parser.IMacroDescriptor;
|
||||||
|
@ -153,7 +154,7 @@ public interface IASTFactory
|
||||||
boolean isLong,
|
boolean isLong,
|
||||||
boolean isSigned,
|
boolean isSigned,
|
||||||
boolean isUnsigned,
|
boolean isUnsigned,
|
||||||
boolean isTypename, boolean isComplex, boolean isImaginary, boolean isGlobal ) throws ASTSemanticException;
|
boolean isTypename, boolean isComplex, boolean isImaginary, boolean isGlobal, Hashtable extensionParms ) throws ASTSemanticException;
|
||||||
|
|
||||||
public IASTFunction createFunction(
|
public IASTFunction createFunction(
|
||||||
IASTScope scope,
|
IASTScope scope,
|
||||||
|
|
|
@ -31,6 +31,8 @@ public interface IASTSimpleTypeSpecifier extends IASTTypeSpecifier
|
||||||
public static final Type CLASS_OR_TYPENAME = new Type( 8 );
|
public static final Type CLASS_OR_TYPENAME = new Type( 8 );
|
||||||
public static final Type TEMPLATE = new Type( 9 );
|
public static final Type TEMPLATE = new Type( 9 );
|
||||||
public static final Type _BOOL = new Type( 10 );
|
public static final Type _BOOL = new Type( 10 );
|
||||||
|
|
||||||
|
protected static final int LAST_TYPE = 10;
|
||||||
/**
|
/**
|
||||||
* @param enumValue
|
* @param enumValue
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,23 +0,0 @@
|
||||||
/*******************************************************************************
|
|
||||||
* Copyright (c) 2000 - 2004 IBM Corporation and others.
|
|
||||||
* All rights reserved. This program and the accompanying materials
|
|
||||||
* are made available under the terms of the Common Public License v1.0
|
|
||||||
* which accompanies this distribution, and is available at
|
|
||||||
* http://www.eclipse.org/legal/cpl-v10.html
|
|
||||||
*
|
|
||||||
* Contributors:
|
|
||||||
* IBM Corporation - initial API and implementation
|
|
||||||
*******************************************************************************/
|
|
||||||
package org.eclipse.cdt.core.parser.ast.extension;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.core.parser.ast.ASTExpressionEvaluationException;
|
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTExpression;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author jcamelon
|
|
||||||
*/
|
|
||||||
public interface IASTExpressionExtension {
|
|
||||||
|
|
||||||
public void setExpression(IASTExpression expression );
|
|
||||||
public int evaluateExpression() throws ASTExpressionEvaluationException;
|
|
||||||
}
|
|
|
@ -1,21 +0,0 @@
|
||||||
/*******************************************************************************
|
|
||||||
* Copyright (c) 2000 - 2004 IBM Corporation and others.
|
|
||||||
* All rights reserved. This program and the accompanying materials
|
|
||||||
* are made available under the terms of the Common Public License v1.0
|
|
||||||
* which accompanies this distribution, and is available at
|
|
||||||
* http://www.eclipse.org/legal/cpl-v10.html
|
|
||||||
*
|
|
||||||
* Contributors:
|
|
||||||
* IBM Corporation - initial API and implementation
|
|
||||||
*******************************************************************************/
|
|
||||||
package org.eclipse.cdt.core.parser.ast.extension;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.core.parser.ast.ASTNotImplementedException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author jcamelon
|
|
||||||
*/
|
|
||||||
public interface IASTExtensionFactory {
|
|
||||||
|
|
||||||
public IASTExpressionExtension createExpressionExtension( ) throws ASTNotImplementedException;
|
|
||||||
}
|
|
|
@ -0,0 +1,34 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* Copyright (c) 2002,2003 Rational Software Corporation and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Common Public License v0.5
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/cpl-v05.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* IBM Rational Software - Initial API and implementation */
|
||||||
|
|
||||||
|
package org.eclipse.cdt.core.parser.ast.gcc;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTExpression;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jcamelon
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public interface IASTGCCExpression extends IASTExpression {
|
||||||
|
|
||||||
|
public static class Kind extends IASTExpression.Kind
|
||||||
|
{
|
||||||
|
public static final Kind UNARY_ALIGNOF_UNARYEXPRESSION = new Kind( LAST_KIND + 1 );
|
||||||
|
public static final Kind UNARY_ALIGNOF_TYPEID = new Kind( LAST_KIND + 2 );
|
||||||
|
public static final Kind UNARY_TYPEOF_UNARYEXPRESSION = new Kind( LAST_KIND + 3 );
|
||||||
|
public static final Kind UNARY_TYPEOF_TYPEID = new Kind( LAST_KIND + 4 );
|
||||||
|
|
||||||
|
protected Kind( int kind )
|
||||||
|
{
|
||||||
|
super( kind );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,36 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* Copyright (c) 2002,2003 Rational Software Corporation and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Common Public License v0.5
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/cpl-v05.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* IBM Rational Software - Initial API and implementation */
|
||||||
|
|
||||||
|
package org.eclipse.cdt.core.parser.ast.gcc;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTExpression;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTSimpleTypeSpecifier;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jcamelon
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public interface IASTGCCSimpleTypeSpecifier extends IASTSimpleTypeSpecifier {
|
||||||
|
|
||||||
|
public static class Type extends IASTSimpleTypeSpecifier.Type
|
||||||
|
{
|
||||||
|
public static final Type TYPEOF = new Type( LAST_TYPE + 1 );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param enumValue
|
||||||
|
*/
|
||||||
|
protected Type(int enumValue) {
|
||||||
|
super(enumValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public IASTExpression getTypeOfExpression();
|
||||||
|
}
|
|
@ -0,0 +1,64 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* Copyright (c) 2002,2003 Rational Software Corporation and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Common Public License v0.5
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/cpl-v05.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* IBM Rational Software - Initial API and implementation */
|
||||||
|
|
||||||
|
package org.eclipse.cdt.core.parser.extension;
|
||||||
|
|
||||||
|
import java.util.Hashtable;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.parser.ITokenDuple;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTExpression;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTScope;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTSimpleTypeSpecifier;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTTypeId;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTExpression.IASTNewExpressionDescriptor;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTExpression.Kind;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTSimpleTypeSpecifier.Type;
|
||||||
|
import org.eclipse.cdt.internal.core.parser.pst.ParserSymbolTable;
|
||||||
|
import org.eclipse.cdt.internal.core.parser.pst.TypeInfo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jcamelon
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public interface IASTFactoryExtension {
|
||||||
|
|
||||||
|
public boolean overrideCreateExpressionMethod();
|
||||||
|
public IASTExpression createExpression(
|
||||||
|
IASTScope scope,
|
||||||
|
IASTExpression.Kind kind,
|
||||||
|
IASTExpression lhs,
|
||||||
|
IASTExpression rhs,
|
||||||
|
IASTExpression thirdExpression,
|
||||||
|
IASTTypeId typeId,
|
||||||
|
ITokenDuple idExpression, String literal, IASTNewExpressionDescriptor newDescriptor);
|
||||||
|
|
||||||
|
public boolean canHandleExpressionKind( IASTExpression.Kind kind );
|
||||||
|
/**
|
||||||
|
* @param kind
|
||||||
|
* @param lhs
|
||||||
|
* @param rhs
|
||||||
|
* @param typeId
|
||||||
|
* @return TODO
|
||||||
|
*/
|
||||||
|
public TypeInfo getExpressionResultType(Kind kind, IASTExpression lhs, IASTExpression rhs, IASTTypeId typeId);
|
||||||
|
|
||||||
|
public boolean overrideCreateSimpleTypeSpecifierMethod(Type type);
|
||||||
|
|
||||||
|
public IASTSimpleTypeSpecifier createSimpleTypeSpecifier(
|
||||||
|
ParserSymbolTable pst,
|
||||||
|
IASTScope scope,
|
||||||
|
IASTSimpleTypeSpecifier.Type kind,
|
||||||
|
ITokenDuple typeName,
|
||||||
|
boolean isShort,
|
||||||
|
boolean isLong,
|
||||||
|
boolean isSigned,
|
||||||
|
boolean isUnsigned, boolean isTypename, boolean isComplex, boolean isImaginary, boolean isGlobal, Hashtable extensionParms );
|
||||||
|
|
||||||
|
}
|
|
@ -10,9 +10,44 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.core.parser.extension;
|
package org.eclipse.cdt.core.parser.extension;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.parser.IToken;
|
||||||
|
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.ASTPointerOperator;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTExpression;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTScope;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTCompletionNode.CompletionKind;
|
||||||
|
import org.eclipse.cdt.internal.core.parser.DeclarationWrapper;
|
||||||
|
import org.eclipse.cdt.internal.core.parser.IParserData;
|
||||||
|
import org.eclipse.cdt.internal.core.parser.Parser;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
*/
|
*/
|
||||||
public interface IParserExtension {
|
public interface IParserExtension {
|
||||||
|
|
||||||
|
public boolean isValidCVModifier( ParserLanguage language, int tokenType );
|
||||||
|
public ASTPointerOperator getPointerOperator( ParserLanguage language, int tokenType );
|
||||||
|
|
||||||
|
public boolean isValidUnaryExpressionStart( int tokenType );
|
||||||
|
public IASTExpression parseUnaryExpression( IASTScope scope, IParserData data, CompletionKind kind );
|
||||||
|
/**
|
||||||
|
* @param i
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public boolean canHandleDeclSpecifierSequence(int tokenType );
|
||||||
|
|
||||||
|
public interface IDeclSpecifierExtensionResult
|
||||||
|
{
|
||||||
|
public IToken getFirstToken();
|
||||||
|
public IToken getLastToken();
|
||||||
|
public Parser.Flags getFlags();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param parser
|
||||||
|
* @param flags
|
||||||
|
* @param sdw
|
||||||
|
* @return TODO
|
||||||
|
*/
|
||||||
|
public IDeclSpecifierExtensionResult handleDeclSpecifierSequence(IParserData parser, Parser.Flags flags, DeclarationWrapper sdw, CompletionKind kind );
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,6 @@ package org.eclipse.cdt.core.parser.extension;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.parser.ParserFactoryError;
|
import org.eclipse.cdt.core.parser.ParserFactoryError;
|
||||||
import org.eclipse.cdt.core.parser.ParserMode;
|
import org.eclipse.cdt.core.parser.ParserMode;
|
||||||
import org.eclipse.cdt.core.parser.ast.extension.IASTExtensionFactory;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -21,6 +20,6 @@ import org.eclipse.cdt.core.parser.ast.extension.IASTExtensionFactory;
|
||||||
public interface IParserExtensionFactory {
|
public interface IParserExtensionFactory {
|
||||||
|
|
||||||
public IScannerExtension createScannerExtension() throws ParserFactoryError;
|
public IScannerExtension createScannerExtension() throws ParserFactoryError;
|
||||||
public IASTExtensionFactory createASTExtensionFactory(ParserMode mode) throws ParserFactoryError;
|
|
||||||
public IParserExtension createParserExtension() throws ParserFactoryError;
|
public IParserExtension createParserExtension() throws ParserFactoryError;
|
||||||
|
public IASTFactoryExtension createASTExtension(ParserMode mode);
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,20 +10,23 @@
|
||||||
***********************************************************************/
|
***********************************************************************/
|
||||||
package org.eclipse.cdt.core.parser.extension;
|
package org.eclipse.cdt.core.parser.extension;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.parser.IToken;
|
||||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||||
|
import org.eclipse.cdt.internal.core.parser.scanner.IScannerData;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
*/
|
*/
|
||||||
public interface IScannerExtension extends Cloneable {
|
public interface IScannerExtension {
|
||||||
|
|
||||||
public Object clone( );
|
|
||||||
|
|
||||||
public String initializeMacroValue( String original );
|
public String initializeMacroValue( IScannerData scannerData, String original );
|
||||||
public void setupBuiltInMacros(ParserLanguage language);
|
public void setupBuiltInMacros(IScannerData scannerData, ParserLanguage language);
|
||||||
|
|
||||||
public boolean canHandlePreprocessorDirective( String directive );
|
public boolean canHandlePreprocessorDirective( String directive );
|
||||||
public void handlePreprocessorDirective( String directive, String restOfLine );
|
public void handlePreprocessorDirective( IScannerData scannerData, String directive, String restOfLine );
|
||||||
|
|
||||||
|
public boolean isExtensionKeyword(String tokenImage);
|
||||||
|
public IToken createExtensionToken(String image, IScannerData scannerData);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return
|
* @return
|
||||||
|
|
|
@ -22,6 +22,7 @@ import org.eclipse.cdt.core.parser.ParserMode;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTCompletionNode;
|
import org.eclipse.cdt.core.parser.ast.IASTCompletionNode;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTNode;
|
import org.eclipse.cdt.core.parser.ast.IASTNode;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTScope;
|
import org.eclipse.cdt.core.parser.ast.IASTScope;
|
||||||
|
import org.eclipse.cdt.core.parser.extension.IParserExtension;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
|
@ -35,8 +36,8 @@ public class CompleteParser extends Parser {
|
||||||
* @param language
|
* @param language
|
||||||
* @param log
|
* @param log
|
||||||
*/
|
*/
|
||||||
public CompleteParser(IScanner scanner, ISourceElementRequestor callback, ParserLanguage language, IParserLogService log) {
|
public CompleteParser(IScanner scanner, ISourceElementRequestor callback, ParserLanguage language, IParserLogService log, IParserExtension extension ) {
|
||||||
super(scanner, callback, language, log);
|
super(scanner, callback, language, log, extension );
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void handleFunctionBody(IASTScope scope) throws BacktrackException, EndOfFileException
|
protected void handleFunctionBody(IASTScope scope) throws BacktrackException, EndOfFileException
|
||||||
|
|
|
@ -32,6 +32,7 @@ import org.eclipse.cdt.core.parser.ast.IASTCompletionNode;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTNode;
|
import org.eclipse.cdt.core.parser.ast.IASTNode;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTScope;
|
import org.eclipse.cdt.core.parser.ast.IASTScope;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTCompletionNode.CompletionKind;
|
import org.eclipse.cdt.core.parser.ast.IASTCompletionNode.CompletionKind;
|
||||||
|
import org.eclipse.cdt.core.parser.extension.IParserExtension;
|
||||||
import org.eclipse.cdt.internal.core.parser.ast.ASTCompletionNode;
|
import org.eclipse.cdt.internal.core.parser.ast.ASTCompletionNode;
|
||||||
import org.eclipse.cdt.internal.core.parser.token.KeywordSets.Key;
|
import org.eclipse.cdt.internal.core.parser.token.KeywordSets.Key;
|
||||||
|
|
||||||
|
@ -46,8 +47,8 @@ public class CompletionParser extends ContextualParser implements IParser {
|
||||||
* @param language
|
* @param language
|
||||||
* @param log
|
* @param log
|
||||||
*/
|
*/
|
||||||
public CompletionParser(IScanner scanner, ISourceElementRequestor callback, ParserLanguage language, IParserLogService log) {
|
public CompletionParser(IScanner scanner, ISourceElementRequestor callback, ParserLanguage language, IParserLogService log, IParserExtension extension ) {
|
||||||
super(scanner, callback, language, log);
|
super(scanner, callback, language, log, extension );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
|
|
@ -25,6 +25,7 @@ import org.eclipse.cdt.core.parser.ast.IASTExpression;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTNode;
|
import org.eclipse.cdt.core.parser.ast.IASTNode;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTScope;
|
import org.eclipse.cdt.core.parser.ast.IASTScope;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTCompletionNode.CompletionKind;
|
import org.eclipse.cdt.core.parser.ast.IASTCompletionNode.CompletionKind;
|
||||||
|
import org.eclipse.cdt.core.parser.extension.IParserExtension;
|
||||||
import org.eclipse.cdt.internal.core.parser.token.KeywordSets;
|
import org.eclipse.cdt.internal.core.parser.token.KeywordSets;
|
||||||
import org.eclipse.cdt.internal.core.parser.token.TokenDuple;
|
import org.eclipse.cdt.internal.core.parser.token.TokenDuple;
|
||||||
import org.eclipse.cdt.internal.core.parser.token.TokenFactory;
|
import org.eclipse.cdt.internal.core.parser.token.TokenFactory;
|
||||||
|
@ -45,8 +46,8 @@ public class ContextualParser extends CompleteParser {
|
||||||
IScanner scanner,
|
IScanner scanner,
|
||||||
ISourceElementRequestor callback,
|
ISourceElementRequestor callback,
|
||||||
ParserLanguage language,
|
ParserLanguage language,
|
||||||
IParserLogService log) {
|
IParserLogService log, IParserExtension extension ) {
|
||||||
super(scanner, callback, language, log);
|
super(scanner, callback, language, log, extension );
|
||||||
}
|
}
|
||||||
|
|
||||||
protected IASTScope scope;
|
protected IASTScope scope;
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
package org.eclipse.cdt.internal.core.parser;
|
package org.eclipse.cdt.internal.core.parser;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.Hashtable;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -84,6 +85,39 @@ public class DeclarationWrapper implements IDeclaratorOwner
|
||||||
{
|
{
|
||||||
return scope;
|
return scope;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public DeclarationWrapper( DeclarationWrapper wrapper )
|
||||||
|
{
|
||||||
|
this( wrapper.getScope(), wrapper.getStartingOffset(), wrapper.getStartingLine(), wrapper.getOwnerTemplate() );
|
||||||
|
setAuto( wrapper.isAuto() );
|
||||||
|
setComplex( wrapper.isComplex() );
|
||||||
|
setConst( wrapper.isConst() );
|
||||||
|
setEndingOffsetAndLineNumber( wrapper.getEndOffset(), wrapper.getEndLine() );
|
||||||
|
setExplicit( wrapper.isExplicit() );
|
||||||
|
setExtern(wrapper.isExtern() );
|
||||||
|
setFriend(wrapper.isFriend());
|
||||||
|
setGloballyQualified( wrapper.isGloballyQualified() );
|
||||||
|
setImaginary( wrapper.isImaginary() );
|
||||||
|
setInline( wrapper.isInline());
|
||||||
|
setLong( wrapper.isLong() );
|
||||||
|
setMutable( wrapper.isMutable() );
|
||||||
|
setName( wrapper.getName() );
|
||||||
|
setRegister(wrapper.isRegister() );
|
||||||
|
setRestrict( wrapper.isRestrict() );
|
||||||
|
setShort(wrapper.isShort());
|
||||||
|
setSigned(wrapper.isSigned());
|
||||||
|
setSimpleType(wrapper.getSimpleType());
|
||||||
|
setStatic(wrapper.isStatic());
|
||||||
|
setTypedef(wrapper.isTypedef());
|
||||||
|
setTypenamed(wrapper.isTypeNamed());
|
||||||
|
setTypeName(wrapper.getName());
|
||||||
|
setTypeSpecifier(wrapper.getTypeSpecifier());
|
||||||
|
setUnsigned(wrapper.isUnsigned());
|
||||||
|
setVirtual(wrapper.isVirtual());
|
||||||
|
setVolatile(wrapper.isVolatile());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param scope
|
* @param scope
|
||||||
*/
|
*/
|
||||||
|
@ -755,4 +789,18 @@ public class DeclarationWrapper implements IDeclaratorOwner
|
||||||
public boolean isGloballyQualified(){
|
public boolean isGloballyQualified(){
|
||||||
return global;
|
return global;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Hashtable extensionParameters = new Hashtable();
|
||||||
|
/**
|
||||||
|
* @param key
|
||||||
|
* @param typeOfExpression
|
||||||
|
*/
|
||||||
|
public void setExtensionParameter(String key, Object value) {
|
||||||
|
extensionParameters.put( key, value );
|
||||||
|
}
|
||||||
|
|
||||||
|
public Hashtable getExtensionParameters()
|
||||||
|
{
|
||||||
|
return extensionParameters;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,6 +39,7 @@ import org.eclipse.cdt.core.parser.ast.IASTSimpleTypeSpecifier;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTTypeId;
|
import org.eclipse.cdt.core.parser.ast.IASTTypeId;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTCompletionNode.CompletionKind;
|
import org.eclipse.cdt.core.parser.ast.IASTCompletionNode.CompletionKind;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTExpression.Kind;
|
import org.eclipse.cdt.core.parser.ast.IASTExpression.Kind;
|
||||||
|
import org.eclipse.cdt.core.parser.extension.IParserExtension;
|
||||||
import org.eclipse.cdt.internal.core.parser.token.KeywordSets;
|
import org.eclipse.cdt.internal.core.parser.token.KeywordSets;
|
||||||
import org.eclipse.cdt.internal.core.parser.token.SimpleToken;
|
import org.eclipse.cdt.internal.core.parser.token.SimpleToken;
|
||||||
import org.eclipse.cdt.internal.core.parser.token.TokenDuple;
|
import org.eclipse.cdt.internal.core.parser.token.TokenDuple;
|
||||||
|
@ -48,29 +49,146 @@ import org.eclipse.cdt.internal.core.parser.util.TraceUtil;
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
*/
|
*/
|
||||||
public class ExpressionParser implements IExpressionParser {
|
public class ExpressionParser implements IExpressionParser, IParserData {
|
||||||
|
|
||||||
protected static final String EMPTY_STRING = ""; //$NON-NLS-1$
|
protected static final String EMPTY_STRING = ""; //$NON-NLS-1$
|
||||||
protected final IParserLogService log;
|
|
||||||
private static int FIRST_ERROR_OFFSET_UNSET = -1;
|
private static int FIRST_ERROR_OFFSET_UNSET = -1;
|
||||||
protected int firstErrorOffset = FIRST_ERROR_OFFSET_UNSET;
|
|
||||||
protected boolean parsePassed = true;
|
protected boolean parsePassed = true;
|
||||||
|
protected int firstErrorOffset = FIRST_ERROR_OFFSET_UNSET;
|
||||||
|
protected static BacktrackException backtrack = new BacktrackException();
|
||||||
|
protected final IParserExtension extension;
|
||||||
|
|
||||||
|
//TODO this stuff needs to be encapsulated by IParserData
|
||||||
|
protected final IParserLogService log;
|
||||||
protected ParserLanguage language = ParserLanguage.CPP;
|
protected ParserLanguage language = ParserLanguage.CPP;
|
||||||
protected IASTFactory astFactory = null;
|
protected IASTFactory astFactory = null;
|
||||||
|
protected IScanner scanner;
|
||||||
|
protected IToken currToken;
|
||||||
|
protected IToken lastToken;
|
||||||
|
private boolean limitReached = false;
|
||||||
private Stack templateIdScopes = null;
|
private Stack templateIdScopes = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Returns the astFactory.
|
||||||
|
*/
|
||||||
|
public IASTFactory getAstFactory() {
|
||||||
|
return astFactory;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @return Returns the log.
|
||||||
|
*/
|
||||||
|
public IParserLogService getLog() {
|
||||||
|
return log;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Look Ahead in the token list to see what is coming.
|
||||||
|
*
|
||||||
|
* @param i How far ahead do you wish to peek?
|
||||||
|
* @return the token you wish to observe
|
||||||
|
* @throws EndOfFileException if looking ahead encounters EOF, throw EndOfFile
|
||||||
|
*/
|
||||||
|
public IToken LA(int i) throws EndOfFileException {
|
||||||
|
|
||||||
|
if (parserTimeout()){
|
||||||
|
throw new ParseError( ParseError.ParseErrorKind.TIMEOUT );
|
||||||
|
}
|
||||||
|
|
||||||
|
if (i < 1) // can't go backwards
|
||||||
|
return null;
|
||||||
|
if (currToken == null)
|
||||||
|
currToken = fetchToken();
|
||||||
|
IToken retToken = currToken;
|
||||||
|
for (; i > 1; --i)
|
||||||
|
{
|
||||||
|
retToken = retToken.getNext();
|
||||||
|
if (retToken == null)
|
||||||
|
retToken = fetchToken();
|
||||||
|
}
|
||||||
|
return retToken;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Look ahead in the token list and return the token type.
|
||||||
|
*
|
||||||
|
* @param i How far ahead do you wish to peek?
|
||||||
|
* @return The type of that token
|
||||||
|
* @throws EndOfFileException if looking ahead encounters EOF, throw EndOfFile
|
||||||
|
*/
|
||||||
|
public int LT(int i) throws EndOfFileException {
|
||||||
|
return LA(i).getType();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Consume the next token available, regardless of the type.
|
||||||
|
*
|
||||||
|
* @return The token that was consumed and removed from our buffer.
|
||||||
|
* @throws EndOfFileException If there is no token to consume.
|
||||||
|
*/
|
||||||
|
public IToken consume() throws EndOfFileException {
|
||||||
|
|
||||||
|
if (currToken == null)
|
||||||
|
currToken = fetchToken();
|
||||||
|
if (currToken != null)
|
||||||
|
lastToken = currToken;
|
||||||
|
currToken = currToken.getNext();
|
||||||
|
handleNewToken( lastToken );
|
||||||
|
return lastToken;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Consume the next token available only if the type is as specified.
|
||||||
|
*
|
||||||
|
* @param type The type of token that you are expecting.
|
||||||
|
* @return the token that was consumed and removed from our buffer.
|
||||||
|
* @throws BacktrackException If LT(1) != type
|
||||||
|
*/
|
||||||
|
public IToken consume(int type) throws EndOfFileException, BacktrackException {
|
||||||
|
if (LT(1) == type)
|
||||||
|
return consume();
|
||||||
|
else
|
||||||
|
throw backtrack;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mark our place in the buffer so that we could return to it should we have to.
|
||||||
|
*
|
||||||
|
* @return The current token.
|
||||||
|
* @throws EndOfFileException If there are no more tokens.
|
||||||
|
*/
|
||||||
|
public IToken mark() throws EndOfFileException {
|
||||||
|
if (currToken == null)
|
||||||
|
currToken = fetchToken();
|
||||||
|
return currToken;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Rollback to a previous point, reseting the queue of tokens.
|
||||||
|
*
|
||||||
|
* @param mark The point that we wish to restore to.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public void backup(IToken mark) {
|
||||||
|
currToken = (SimpleToken)mark;
|
||||||
|
lastToken = null; // this is not entirely right ...
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @param extension TODO
|
||||||
* @param scanner2
|
* @param scanner2
|
||||||
* @param callback
|
* @param callback
|
||||||
* @param language2
|
* @param language2
|
||||||
* @param log2
|
* @param log2
|
||||||
*/
|
*/
|
||||||
public ExpressionParser(IScanner scanner, ParserLanguage language, IParserLogService log) {
|
public ExpressionParser(IScanner scanner, ParserLanguage language, IParserLogService log, IParserExtension extension) {
|
||||||
this.scanner = scanner;
|
this.scanner = scanner;
|
||||||
this.language = language;
|
this.language = language;
|
||||||
this.log = log;
|
this.log = log;
|
||||||
|
this.extension = extension;
|
||||||
setupASTFactory(scanner, language);
|
setupASTFactory(scanner, language);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -439,10 +557,23 @@ public class ExpressionParser implements IExpressionParser {
|
||||||
declarator.addPointerOperator(ASTPointerOperator.RESTRICT_POINTER);
|
declarator.addPointerOperator(ASTPointerOperator.RESTRICT_POINTER);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
if( extension.isValidCVModifier( language, IToken.t_restrict ))
|
||||||
|
{
|
||||||
|
result = consume( IToken.t_restrict );
|
||||||
|
declarator.addPointerOperator( extension.getPointerOperator(language, IToken.t_restrict ));
|
||||||
|
break;
|
||||||
|
}
|
||||||
throw backtrack;
|
throw backtrack;
|
||||||
|
}
|
||||||
|
|
||||||
default :
|
default :
|
||||||
|
if( extension.isValidCVModifier( language, LT(1)))
|
||||||
|
{
|
||||||
|
result = consume();
|
||||||
|
declarator.addPointerOperator( extension.getPointerOperator( language, result.getType() ));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -954,7 +1085,7 @@ public class ExpressionParser implements IExpressionParser {
|
||||||
* @param methodName
|
* @param methodName
|
||||||
* @param e
|
* @param e
|
||||||
*/
|
*/
|
||||||
protected void logException(String methodName, Exception e) {
|
public void logException(String methodName, Exception e) {
|
||||||
if( !(e instanceof EndOfFileException ))
|
if( !(e instanceof EndOfFileException ))
|
||||||
{
|
{
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuffer buffer = new StringBuffer();
|
||||||
|
@ -1340,7 +1471,7 @@ public class ExpressionParser implements IExpressionParser {
|
||||||
* @param completionKind TODO
|
* @param completionKind TODO
|
||||||
* @throws BacktrackException
|
* @throws BacktrackException
|
||||||
*/
|
*/
|
||||||
protected IASTTypeId typeId(IASTScope scope, boolean skipArrayModifiers, CompletionKind completionKind) throws EndOfFileException, BacktrackException {
|
public IASTTypeId typeId(IASTScope scope, boolean skipArrayModifiers, CompletionKind completionKind) throws EndOfFileException, BacktrackException {
|
||||||
IToken mark = mark();
|
IToken mark = mark();
|
||||||
IToken start = mark;
|
IToken start = mark;
|
||||||
ITokenDuple name = null;
|
ITokenDuple name = null;
|
||||||
|
@ -1796,7 +1927,7 @@ public class ExpressionParser implements IExpressionParser {
|
||||||
* @param expression
|
* @param expression
|
||||||
* @throws BacktrackException
|
* @throws BacktrackException
|
||||||
*/
|
*/
|
||||||
protected IASTExpression unaryExpression(IASTScope scope, CompletionKind kind) throws EndOfFileException, BacktrackException {
|
public IASTExpression unaryExpression(IASTScope scope, CompletionKind kind) throws EndOfFileException, BacktrackException {
|
||||||
switch (LT(1))
|
switch (LT(1))
|
||||||
{
|
{
|
||||||
case IToken.tSTAR :
|
case IToken.tSTAR :
|
||||||
|
@ -1914,6 +2045,11 @@ public class ExpressionParser implements IExpressionParser {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
default :
|
default :
|
||||||
|
if( extension.isValidUnaryExpressionStart( LT(1)))
|
||||||
|
{
|
||||||
|
IASTExpression extensionExpression = extension.parseUnaryExpression(scope,this,kind);
|
||||||
|
if( extensionExpression != null ) return extensionExpression;
|
||||||
|
}
|
||||||
return postfixExpression(scope,kind);
|
return postfixExpression(scope,kind);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2606,12 +2742,6 @@ public class ExpressionParser implements IExpressionParser {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static BacktrackException backtrack = new BacktrackException();
|
|
||||||
protected IScanner scanner;
|
|
||||||
protected IToken currToken;
|
|
||||||
protected IToken lastToken;
|
|
||||||
private boolean limitReached = false;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetches a token from the scanner.
|
* Fetches a token from the scanner.
|
||||||
*
|
*
|
||||||
|
@ -2652,98 +2782,6 @@ public class ExpressionParser implements IExpressionParser {
|
||||||
throw new EndOfFileException();
|
throw new EndOfFileException();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Look Ahead in the token list to see what is coming.
|
|
||||||
*
|
|
||||||
* @param i How far ahead do you wish to peek?
|
|
||||||
* @return the token you wish to observe
|
|
||||||
* @throws EndOfFileException if looking ahead encounters EOF, throw EndOfFile
|
|
||||||
*/
|
|
||||||
protected IToken LA(int i) throws EndOfFileException {
|
|
||||||
|
|
||||||
if (parserTimeout()){
|
|
||||||
throw new ParseError( ParseError.ParseErrorKind.TIMEOUT );
|
|
||||||
}
|
|
||||||
|
|
||||||
if (i < 1) // can't go backwards
|
|
||||||
return null;
|
|
||||||
if (currToken == null)
|
|
||||||
currToken = fetchToken();
|
|
||||||
IToken retToken = currToken;
|
|
||||||
for (; i > 1; --i)
|
|
||||||
{
|
|
||||||
retToken = retToken.getNext();
|
|
||||||
if (retToken == null)
|
|
||||||
retToken = fetchToken();
|
|
||||||
}
|
|
||||||
return retToken;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Look ahead in the token list and return the token type.
|
|
||||||
*
|
|
||||||
* @param i How far ahead do you wish to peek?
|
|
||||||
* @return The type of that token
|
|
||||||
* @throws EndOfFileException if looking ahead encounters EOF, throw EndOfFile
|
|
||||||
*/
|
|
||||||
protected int LT(int i) throws EndOfFileException {
|
|
||||||
return LA(i).getType();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Consume the next token available, regardless of the type.
|
|
||||||
*
|
|
||||||
* @return The token that was consumed and removed from our buffer.
|
|
||||||
* @throws EndOfFileException If there is no token to consume.
|
|
||||||
*/
|
|
||||||
protected IToken consume() throws EndOfFileException {
|
|
||||||
|
|
||||||
if (currToken == null)
|
|
||||||
currToken = fetchToken();
|
|
||||||
if (currToken != null)
|
|
||||||
lastToken = currToken;
|
|
||||||
currToken = currToken.getNext();
|
|
||||||
handleNewToken( lastToken );
|
|
||||||
return lastToken;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Consume the next token available only if the type is as specified.
|
|
||||||
*
|
|
||||||
* @param type The type of token that you are expecting.
|
|
||||||
* @return the token that was consumed and removed from our buffer.
|
|
||||||
* @throws BacktrackException If LT(1) != type
|
|
||||||
*/
|
|
||||||
protected IToken consume(int type) throws EndOfFileException, BacktrackException {
|
|
||||||
if (LT(1) == type)
|
|
||||||
return consume();
|
|
||||||
else
|
|
||||||
throw backtrack;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Mark our place in the buffer so that we could return to it should we have to.
|
|
||||||
*
|
|
||||||
* @return The current token.
|
|
||||||
* @throws EndOfFileException If there are no more tokens.
|
|
||||||
*/
|
|
||||||
protected IToken mark() throws EndOfFileException {
|
|
||||||
if (currToken == null)
|
|
||||||
currToken = fetchToken();
|
|
||||||
return currToken;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Rollback to a previous point, reseting the queue of tokens.
|
|
||||||
*
|
|
||||||
* @param mark The point that we wish to restore to.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
protected void backup(IToken mark) {
|
|
||||||
currToken = (SimpleToken)mark;
|
|
||||||
lastToken = null; // this is not entirely right ...
|
|
||||||
}
|
|
||||||
|
|
||||||
protected IASTExpression assignmentOperatorExpression(IASTScope scope, IASTExpression.Kind kind, IASTExpression lhs, CompletionKind completionKind) throws EndOfFileException, BacktrackException {
|
protected IASTExpression assignmentOperatorExpression(IASTScope scope, IASTExpression.Kind kind, IASTExpression lhs, CompletionKind completionKind) throws EndOfFileException, BacktrackException {
|
||||||
consume();
|
consume();
|
||||||
IASTExpression assignmentExpression = assignmentExpression(scope,completionKind);
|
IASTExpression assignmentExpression = assignmentExpression(scope,completionKind);
|
||||||
|
@ -2841,4 +2879,10 @@ public class ExpressionParser implements IExpressionParser {
|
||||||
protected boolean parserTimeout(){
|
protected boolean parserTimeout(){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.parser.IParserData#getLastToken()
|
||||||
|
*/
|
||||||
|
public IToken getLastToken() {
|
||||||
|
return lastToken;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,322 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* Copyright (c) 2002,2003 Rational Software Corporation and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Common Public License v0.5
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/cpl-v05.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* IBM Rational Software - Initial API and implementation */
|
||||||
|
|
||||||
|
package org.eclipse.cdt.internal.core.parser;
|
||||||
|
|
||||||
|
import java.util.Hashtable;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.parser.BacktrackException;
|
||||||
|
import org.eclipse.cdt.core.parser.EndOfFileException;
|
||||||
|
import org.eclipse.cdt.core.parser.Enum;
|
||||||
|
import org.eclipse.cdt.core.parser.IGCCToken;
|
||||||
|
import org.eclipse.cdt.core.parser.IToken;
|
||||||
|
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.ASTPointerOperator;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.ASTSemanticException;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTCompletionNode;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTExpression;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTScope;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTTypeId;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTCompletionNode.CompletionKind;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.gcc.IASTGCCExpression;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.gcc.IASTGCCSimpleTypeSpecifier;
|
||||||
|
import org.eclipse.cdt.core.parser.extension.IParserExtension;
|
||||||
|
import org.eclipse.cdt.internal.core.parser.Parser.Flags;
|
||||||
|
import org.eclipse.cdt.internal.core.parser.ast.complete.gcc.ASTGCCSimpleTypeSpecifier;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jcamelon
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class GCCParserExtension implements IParserExtension {
|
||||||
|
|
||||||
|
private static final String EMPTY_STRING = "";
|
||||||
|
protected static BacktrackException backtrack = new BacktrackException();
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.extension.IParserExtension#isValidCVModifier(org.eclipse.cdt.core.parser.ParserLanguage, int)
|
||||||
|
*/
|
||||||
|
public boolean isValidCVModifier(ParserLanguage language, int tokenType) {
|
||||||
|
if( tokenType == IToken.t_restrict && language == ParserLanguage.CPP )
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.extension.IParserExtension#getPointerOperator(org.eclipse.cdt.core.parser.ParserLanguage, int)
|
||||||
|
*/
|
||||||
|
public ASTPointerOperator getPointerOperator(ParserLanguage language, int tokenType) {
|
||||||
|
if( tokenType == IToken.t_restrict && language == ParserLanguage.CPP )
|
||||||
|
return ASTPointerOperator.RESTRICT_POINTER;
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.extension.IParserExtension#isValidUnaryExpressionStart(int)
|
||||||
|
*/
|
||||||
|
public boolean isValidUnaryExpressionStart(int tokenType) {
|
||||||
|
switch( tokenType )
|
||||||
|
{
|
||||||
|
case IGCCToken.t___alignof__:
|
||||||
|
case IGCCToken.t_typeof:
|
||||||
|
return true;
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.extension.IParserExtension#parseUnaryExpression(org.eclipse.cdt.internal.core.parser.IParserData)
|
||||||
|
*/
|
||||||
|
public IASTExpression parseUnaryExpression(IASTScope scope, IParserData data, IASTCompletionNode.CompletionKind kind) {
|
||||||
|
try {
|
||||||
|
switch( data.LT(1))
|
||||||
|
{
|
||||||
|
case IGCCToken.t___alignof__:
|
||||||
|
return performUnaryExpression( data, scope, kind, UnaryExpressionKind.ALIGNOF );
|
||||||
|
case IGCCToken.t_typeof:
|
||||||
|
return performUnaryExpression( data, scope, kind, UnaryExpressionKind.TYPEOF );
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} catch (EndOfFileException e) {
|
||||||
|
//TODO
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected static class UnaryExpressionKind extends Enum
|
||||||
|
{
|
||||||
|
public static final UnaryExpressionKind ALIGNOF = new UnaryExpressionKind( 1 );
|
||||||
|
public static final UnaryExpressionKind TYPEOF = new UnaryExpressionKind( 2 );
|
||||||
|
/**
|
||||||
|
* @param enumValue
|
||||||
|
*/
|
||||||
|
protected UnaryExpressionKind(int enumValue) {
|
||||||
|
super(enumValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param data
|
||||||
|
* @param scope
|
||||||
|
* @param kind
|
||||||
|
* @param type TODO
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
protected IASTExpression performUnaryExpression(IParserData data, IASTScope scope, CompletionKind kind, UnaryExpressionKind type) {
|
||||||
|
IToken startingPoint = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if( type == UnaryExpressionKind.ALIGNOF )
|
||||||
|
startingPoint = data.consume(IGCCToken.t___alignof__);
|
||||||
|
else if( type == UnaryExpressionKind.TYPEOF )
|
||||||
|
startingPoint = data.consume(IGCCToken.t_typeof );
|
||||||
|
} catch( BacktrackException b )
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
} catch (EndOfFileException e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
IToken mark = data.mark();
|
||||||
|
IASTTypeId d = null;
|
||||||
|
IASTExpression unaryExpression = null;
|
||||||
|
if (data.LT(1) == IToken.tLPAREN)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
data.consume(IToken.tLPAREN);
|
||||||
|
d = data.typeId(scope, false, CompletionKind.TYPE_REFERENCE);
|
||||||
|
data.consume(IToken.tRPAREN);
|
||||||
|
}
|
||||||
|
catch (BacktrackException bt)
|
||||||
|
{
|
||||||
|
data.backup(mark);
|
||||||
|
d = null;
|
||||||
|
unaryExpression = data.unaryExpression(scope,kind);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
unaryExpression = data.unaryExpression(scope,kind);
|
||||||
|
}
|
||||||
|
if (d != null & unaryExpression == null)
|
||||||
|
try
|
||||||
|
{
|
||||||
|
IASTExpression.Kind expKind = null;
|
||||||
|
if( type == UnaryExpressionKind.ALIGNOF )
|
||||||
|
expKind = IASTGCCExpression.Kind.UNARY_ALIGNOF_TYPEID;
|
||||||
|
else if( type == UnaryExpressionKind.TYPEOF )
|
||||||
|
expKind = IASTGCCExpression.Kind.UNARY_TYPEOF_TYPEID;
|
||||||
|
return data.getAstFactory().createExpression(
|
||||||
|
scope,
|
||||||
|
expKind,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
d,
|
||||||
|
null, EMPTY_STRING, null);
|
||||||
|
}
|
||||||
|
catch (ASTSemanticException e)
|
||||||
|
{
|
||||||
|
data.backup( startingPoint );
|
||||||
|
return null;
|
||||||
|
} catch (Exception e)
|
||||||
|
{
|
||||||
|
data.logException( "unaryExpression_1::createExpression()", e ); //$NON-NLS-1$
|
||||||
|
data.backup( startingPoint );
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
else if (unaryExpression != null && d == null)
|
||||||
|
try
|
||||||
|
{
|
||||||
|
IASTExpression.Kind expKind = null;
|
||||||
|
if( type == UnaryExpressionKind.ALIGNOF )
|
||||||
|
expKind = IASTGCCExpression.Kind.UNARY_ALIGNOF_UNARYEXPRESSION;
|
||||||
|
else if( type == UnaryExpressionKind.TYPEOF )
|
||||||
|
expKind = IASTGCCExpression.Kind.UNARY_TYPEOF_UNARYEXPRESSION;
|
||||||
|
|
||||||
|
return data.getAstFactory().createExpression(
|
||||||
|
scope,
|
||||||
|
expKind,
|
||||||
|
unaryExpression,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null, EMPTY_STRING, null);
|
||||||
|
}
|
||||||
|
catch (ASTSemanticException e1)
|
||||||
|
{
|
||||||
|
data.backup( startingPoint );
|
||||||
|
return null;
|
||||||
|
} catch (Exception e)
|
||||||
|
{
|
||||||
|
data.logException( "unaryExpression_1::createExpression()", e ); //$NON-NLS-1$
|
||||||
|
data.backup( startingPoint );
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
catch( BacktrackException bt )
|
||||||
|
{
|
||||||
|
data.backup( startingPoint );
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
catch( EndOfFileException eof )
|
||||||
|
{
|
||||||
|
data.backup( startingPoint );
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.extension.IParserExtension#canHandleDeclSpecifierSequence(int)
|
||||||
|
*/
|
||||||
|
public boolean canHandleDeclSpecifierSequence(int tokenType) {
|
||||||
|
switch( tokenType )
|
||||||
|
{
|
||||||
|
case IGCCToken.t_typeof:
|
||||||
|
return true;
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.extension.IParserExtension#handleDeclSpecifierSequence(org.eclipse.cdt.internal.core.parser.IParserData, org.eclipse.cdt.core.model.Flags, org.eclipse.cdt.internal.core.parser.DeclarationWrapper)
|
||||||
|
*/
|
||||||
|
public IDeclSpecifierExtensionResult handleDeclSpecifierSequence(IParserData data, Parser.Flags flags, DeclarationWrapper sdw, CompletionKind kind) {
|
||||||
|
IToken startingPoint = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
startingPoint = data.mark();
|
||||||
|
} catch( EndOfFileException eof )
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
switch( data.LT(1))
|
||||||
|
{
|
||||||
|
case IGCCToken.t_typeof:
|
||||||
|
IASTExpression typeOfExpression = performUnaryExpression( data, sdw.getScope(), kind, UnaryExpressionKind.TYPEOF );
|
||||||
|
if( typeOfExpression != null )
|
||||||
|
{
|
||||||
|
sdw.setSimpleType( IASTGCCSimpleTypeSpecifier.Type.TYPEOF );
|
||||||
|
flags.setEncounteredRawType(true);
|
||||||
|
Hashtable params = new Hashtable();
|
||||||
|
params.put( ASTGCCSimpleTypeSpecifier.TYPEOF_EXRESSION, typeOfExpression );
|
||||||
|
sdw.setExtensionParameter( ASTGCCSimpleTypeSpecifier.TYPEOF_EXRESSION, typeOfExpression );
|
||||||
|
return new GCCDeclSpecifierExtensionResult( startingPoint, data.getLastToken(), flags, params );
|
||||||
|
}
|
||||||
|
data.backup( startingPoint );
|
||||||
|
return null;
|
||||||
|
default:
|
||||||
|
data.backup( startingPoint );
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// catch( BacktrackException bt )
|
||||||
|
// {
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
catch( EndOfFileException eof )
|
||||||
|
{
|
||||||
|
data.backup( startingPoint );
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public class GCCDeclSpecifierExtensionResult implements IDeclSpecifierExtensionResult
|
||||||
|
{
|
||||||
|
private final IToken first;
|
||||||
|
private final IToken last;
|
||||||
|
private final Flags flags;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param startingPoint
|
||||||
|
* @param token
|
||||||
|
* @param flags
|
||||||
|
*/
|
||||||
|
public GCCDeclSpecifierExtensionResult(IToken startingPoint, IToken token, Flags flags, Hashtable params) {
|
||||||
|
first = startingPoint;
|
||||||
|
last = token;
|
||||||
|
this.flags = flags;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.extension.IParserExtension.IDeclSpecifierExtensionResult#getFirstToken()
|
||||||
|
*/
|
||||||
|
public IToken getFirstToken() {
|
||||||
|
return first;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.extension.IParserExtension.IDeclSpecifierExtensionResult#getLastToken()
|
||||||
|
*/
|
||||||
|
public IToken getLastToken() {
|
||||||
|
return last;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.extension.IParserExtension.IDeclSpecifierExtensionResult#getFlags()
|
||||||
|
*/
|
||||||
|
public Flags getFlags() {
|
||||||
|
return flags;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,101 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* Copyright (c) 2002,2003 Rational Software Corporation and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Common Public License v0.5
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/cpl-v05.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* IBM Rational Software - Initial API and implementation */
|
||||||
|
package org.eclipse.cdt.internal.core.parser;
|
||||||
|
import org.eclipse.cdt.core.parser.BacktrackException;
|
||||||
|
import org.eclipse.cdt.core.parser.EndOfFileException;
|
||||||
|
import org.eclipse.cdt.core.parser.IParserLogService;
|
||||||
|
import org.eclipse.cdt.core.parser.IToken;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTExpression;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTFactory;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTScope;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTTypeId;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTCompletionNode.CompletionKind;
|
||||||
|
/**
|
||||||
|
* @author jcamelon
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public interface IParserData {
|
||||||
|
/**
|
||||||
|
* @return Returns the astFactory.
|
||||||
|
*/
|
||||||
|
public abstract IASTFactory getAstFactory();
|
||||||
|
/**
|
||||||
|
* @return Returns the log.
|
||||||
|
*/
|
||||||
|
public abstract IParserLogService getLog();
|
||||||
|
/**
|
||||||
|
* Look Ahead in the token list to see what is coming.
|
||||||
|
*
|
||||||
|
* @param i How far ahead do you wish to peek?
|
||||||
|
* @return the token you wish to observe
|
||||||
|
* @throws EndOfFileException if looking ahead encounters EOF, throw EndOfFile
|
||||||
|
*/
|
||||||
|
public abstract IToken LA(int i) throws EndOfFileException;
|
||||||
|
/**
|
||||||
|
* Look ahead in the token list and return the token type.
|
||||||
|
*
|
||||||
|
* @param i How far ahead do you wish to peek?
|
||||||
|
* @return The type of that token
|
||||||
|
* @throws EndOfFileException if looking ahead encounters EOF, throw EndOfFile
|
||||||
|
*/
|
||||||
|
public abstract int LT(int i) throws EndOfFileException;
|
||||||
|
/**
|
||||||
|
* Consume the next token available, regardless of the type.
|
||||||
|
*
|
||||||
|
* @return The token that was consumed and removed from our buffer.
|
||||||
|
* @throws EndOfFileException If there is no token to consume.
|
||||||
|
*/
|
||||||
|
public abstract IToken consume() throws EndOfFileException;
|
||||||
|
/**
|
||||||
|
* Consume the next token available only if the type is as specified.
|
||||||
|
*
|
||||||
|
* @param type The type of token that you are expecting.
|
||||||
|
* @return the token that was consumed and removed from our buffer.
|
||||||
|
* @throws BacktrackException If LT(1) != type
|
||||||
|
*/
|
||||||
|
public abstract IToken consume(int type) throws EndOfFileException,
|
||||||
|
BacktrackException;
|
||||||
|
/**
|
||||||
|
* Mark our place in the buffer so that we could return to it should we have to.
|
||||||
|
*
|
||||||
|
* @return The current token.
|
||||||
|
* @throws EndOfFileException If there are no more tokens.
|
||||||
|
*/
|
||||||
|
public abstract IToken mark() throws EndOfFileException;
|
||||||
|
/**
|
||||||
|
* Rollback to a previous point, reseting the queue of tokens.
|
||||||
|
*
|
||||||
|
* @param mark The point that we wish to restore to.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public abstract void backup(IToken mark);
|
||||||
|
/**
|
||||||
|
* @param string
|
||||||
|
* @param e
|
||||||
|
*/
|
||||||
|
public abstract void logException(String string, Exception e);
|
||||||
|
/**
|
||||||
|
* @param scope
|
||||||
|
* @param b
|
||||||
|
* @param kind
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public IASTTypeId typeId(IASTScope scope, boolean b, CompletionKind kind) throws EndOfFileException, BacktrackException;
|
||||||
|
/**
|
||||||
|
* @param scope
|
||||||
|
* @param kind
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public IASTExpression unaryExpression(IASTScope scope, CompletionKind kind) throws EndOfFileException, BacktrackException;
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public IToken getLastToken();
|
||||||
|
}
|
|
@ -21,18 +21,22 @@ import org.eclipse.cdt.core.parser.IScanner;
|
||||||
import org.eclipse.cdt.core.parser.ParserFactory;
|
import org.eclipse.cdt.core.parser.ParserFactory;
|
||||||
import org.eclipse.cdt.core.parser.ParserFactoryError;
|
import org.eclipse.cdt.core.parser.ParserFactoryError;
|
||||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||||
|
import org.eclipse.cdt.core.parser.extension.ExtensionDialect;
|
||||||
|
import org.eclipse.cdt.core.parser.extension.IParserExtensionFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
*/
|
*/
|
||||||
public class InternalParserUtil extends ParserFactory {
|
public class InternalParserUtil extends ParserFactory {
|
||||||
|
|
||||||
|
private static IParserExtensionFactory extensionFactory = new ParserExtensionFactory( ExtensionDialect.GCC );
|
||||||
|
|
||||||
public static IExpressionParser createExpressionParser( IScanner scanner, ParserLanguage language, IParserLogService log ) throws ParserFactoryError
|
public static IExpressionParser createExpressionParser( IScanner scanner, ParserLanguage language, IParserLogService log ) throws ParserFactoryError
|
||||||
{
|
{
|
||||||
if( scanner == null ) throw new ParserFactoryError( ParserFactoryError.Kind.NULL_SCANNER );
|
if( scanner == null ) throw new ParserFactoryError( ParserFactoryError.Kind.NULL_SCANNER );
|
||||||
if( language == null ) throw new ParserFactoryError( ParserFactoryError.Kind.NULL_LANGUAGE );
|
if( language == null ) throw new ParserFactoryError( ParserFactoryError.Kind.NULL_LANGUAGE );
|
||||||
IParserLogService logService = ( log == null ) ? createDefaultLogService() : log;
|
IParserLogService logService = ( log == null ) ? createDefaultLogService() : log;
|
||||||
return new ExpressionParser( scanner, language, logService );
|
return new ExpressionParser( scanner, language, logService, extensionFactory.createParserExtension() );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -56,6 +56,7 @@ import org.eclipse.cdt.core.parser.ast.IASTUsingDeclaration;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTUsingDirective;
|
import org.eclipse.cdt.core.parser.ast.IASTUsingDirective;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier.ClassNameType;
|
import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier.ClassNameType;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTCompletionNode.CompletionKind;
|
import org.eclipse.cdt.core.parser.ast.IASTCompletionNode.CompletionKind;
|
||||||
|
import org.eclipse.cdt.core.parser.extension.IParserExtension;
|
||||||
import org.eclipse.cdt.internal.core.parser.token.KeywordSets;
|
import org.eclipse.cdt.internal.core.parser.token.KeywordSets;
|
||||||
import org.eclipse.cdt.internal.core.parser.token.TokenDuple;
|
import org.eclipse.cdt.internal.core.parser.token.TokenDuple;
|
||||||
import org.eclipse.cdt.internal.core.parser.token.KeywordSets.Key;
|
import org.eclipse.cdt.internal.core.parser.token.KeywordSets.Key;
|
||||||
|
@ -69,28 +70,23 @@ import org.eclipse.cdt.internal.core.parser.util.TraceUtil;
|
||||||
*
|
*
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
*/
|
*/
|
||||||
public abstract class Parser extends ExpressionParser implements IParser
|
public abstract class Parser extends ExpressionParser implements IParser
|
||||||
{
|
{
|
||||||
private static final List EMPTY_LIST = new ArrayList();
|
private static final List EMPTY_LIST = new ArrayList();
|
||||||
protected ISourceElementRequestor requestor = null;
|
protected ISourceElementRequestor requestor = null;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is the standard cosntructor that we expect the Parser to be instantiated
|
* This is the standard cosntructor that we expect the Parser to be instantiated
|
||||||
* with.
|
* with.
|
||||||
*
|
*
|
||||||
* @param s IScanner instance that has been initialized to the code input
|
|
||||||
* @param c IParserCallback instance that will receive callbacks as we parse
|
|
||||||
* @param quick Are we asking for a high level parse or not?
|
|
||||||
*/
|
*/
|
||||||
public Parser(
|
public Parser(
|
||||||
IScanner scanner,
|
IScanner scanner,
|
||||||
ISourceElementRequestor callback,
|
ISourceElementRequestor callback,
|
||||||
ParserLanguage language,
|
ParserLanguage language,
|
||||||
IParserLogService log )
|
IParserLogService log, IParserExtension extension )
|
||||||
{
|
{
|
||||||
super( scanner, language, log );
|
super( scanner, language, log, extension );
|
||||||
requestor = callback;
|
requestor = callback;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -979,7 +975,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
||||||
sdw.isTypeNamed(),
|
sdw.isTypeNamed(),
|
||||||
sdw.isComplex(),
|
sdw.isComplex(),
|
||||||
sdw.isImaginary(),
|
sdw.isImaginary(),
|
||||||
sdw.isGloballyQualified()));
|
sdw.isGloballyQualified(), sdw.getExtensionParameters()));
|
||||||
}
|
}
|
||||||
catch (Exception e1)
|
catch (Exception e1)
|
||||||
{
|
{
|
||||||
|
@ -1221,7 +1217,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
||||||
sdw.isTypeNamed(),
|
sdw.isTypeNamed(),
|
||||||
sdw.isComplex(),
|
sdw.isComplex(),
|
||||||
sdw.isImaginary(),
|
sdw.isImaginary(),
|
||||||
sdw.isGloballyQualified()));
|
sdw.isGloballyQualified(), null));
|
||||||
}
|
}
|
||||||
catch (ASTSemanticException e)
|
catch (ASTSemanticException e)
|
||||||
{
|
{
|
||||||
|
@ -1247,7 +1243,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
||||||
/**
|
/**
|
||||||
* This class represents the state and strategy for parsing declarationSpecifierSequences
|
* This class represents the state and strategy for parsing declarationSpecifierSequences
|
||||||
*/
|
*/
|
||||||
private class Flags
|
public class Flags
|
||||||
{
|
{
|
||||||
private boolean encounteredTypename = false;
|
private boolean encounteredTypename = false;
|
||||||
// have we encountered a typeName yet?
|
// have we encountered a typeName yet?
|
||||||
|
@ -1663,11 +1659,25 @@ public abstract class Parser extends ExpressionParser implements IParser
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default :
|
default :
|
||||||
|
if( extension.canHandleDeclSpecifierSequence( LT(1)))
|
||||||
|
{
|
||||||
|
IParserExtension.IDeclSpecifierExtensionResult declSpecExtResult = extension.handleDeclSpecifierSequence( this, flags, sdw, kind );
|
||||||
|
if( declSpecExtResult != null )
|
||||||
|
{
|
||||||
|
flags = declSpecExtResult.getFlags();
|
||||||
|
if( typeNameBegin == null )
|
||||||
|
typeNameBegin = declSpecExtResult.getFirstToken();
|
||||||
|
typeNameEnd = declSpecExtResult.getLastToken();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break declSpecifiers;
|
||||||
|
}
|
||||||
break declSpecifiers;
|
break declSpecifiers;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (typeNameBegin != null)
|
if (typeNameBegin != null)
|
||||||
sdw.setTypeName(new TokenDuple(typeNameBegin, typeNameEnd));
|
sdw.setTypeName(new TokenDuple(typeNameBegin, typeNameEnd));
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Parse an elaborated type specifier.
|
* Parse an elaborated type specifier.
|
||||||
|
|
|
@ -12,13 +12,12 @@ package org.eclipse.cdt.internal.core.parser;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.parser.ParserFactoryError;
|
import org.eclipse.cdt.core.parser.ParserFactoryError;
|
||||||
import org.eclipse.cdt.core.parser.ParserMode;
|
import org.eclipse.cdt.core.parser.ParserMode;
|
||||||
import org.eclipse.cdt.core.parser.ast.extension.IASTExtensionFactory;
|
|
||||||
import org.eclipse.cdt.core.parser.extension.ExtensionDialect;
|
import org.eclipse.cdt.core.parser.extension.ExtensionDialect;
|
||||||
|
import org.eclipse.cdt.core.parser.extension.IASTFactoryExtension;
|
||||||
import org.eclipse.cdt.core.parser.extension.IParserExtension;
|
import org.eclipse.cdt.core.parser.extension.IParserExtension;
|
||||||
import org.eclipse.cdt.core.parser.extension.IParserExtensionFactory;
|
import org.eclipse.cdt.core.parser.extension.IParserExtensionFactory;
|
||||||
import org.eclipse.cdt.core.parser.extension.IScannerExtension;
|
import org.eclipse.cdt.core.parser.extension.IScannerExtension;
|
||||||
import org.eclipse.cdt.internal.core.parser.ast.complete.extension.CompleteParseASTExtensionFactory;
|
import org.eclipse.cdt.internal.core.parser.ast.GCCASTExtension;
|
||||||
import org.eclipse.cdt.internal.core.parser.ast.quick.extension.QuickParseASTExtensionFactory;
|
|
||||||
import org.eclipse.cdt.internal.core.parser.scanner.GCCScannerExtension;
|
import org.eclipse.cdt.internal.core.parser.scanner.GCCScannerExtension;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -26,7 +25,6 @@ import org.eclipse.cdt.internal.core.parser.scanner.GCCScannerExtension;
|
||||||
*/
|
*/
|
||||||
public class ParserExtensionFactory implements IParserExtensionFactory {
|
public class ParserExtensionFactory implements IParserExtensionFactory {
|
||||||
|
|
||||||
|
|
||||||
private final ExtensionDialect dialect;
|
private final ExtensionDialect dialect;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -46,24 +44,22 @@ public class ParserExtensionFactory implements IParserExtensionFactory {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.parser.extension.IParserExtensionFactory#createASTExtensionFactory()
|
* @see org.eclipse.cdt.core.parser.extension.IParserExtensionFactory#createParserExtension()
|
||||||
*/
|
*/
|
||||||
public IASTExtensionFactory createASTExtensionFactory(ParserMode mode) throws ParserFactoryError {
|
public IParserExtension createParserExtension() throws ParserFactoryError
|
||||||
|
{
|
||||||
if( dialect == ExtensionDialect.GCC )
|
if( dialect == ExtensionDialect.GCC )
|
||||||
{
|
return new GCCParserExtension();
|
||||||
if( mode == ParserMode.QUICK_PARSE || mode == ParserMode.EXPRESSION_PARSE )
|
|
||||||
return new QuickParseASTExtensionFactory();
|
|
||||||
return new CompleteParseASTExtensionFactory();
|
|
||||||
}
|
|
||||||
throw new ParserFactoryError( ParserFactoryError.Kind.BAD_DIALECT );
|
throw new ParserFactoryError( ParserFactoryError.Kind.BAD_DIALECT );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.parser.extension.IParserExtensionFactory#createParserExtension()
|
* @see org.eclipse.cdt.core.parser.extension.IParserExtensionFactory#createASTExtension(org.eclipse.cdt.core.parser.ParserMode)
|
||||||
*/
|
*/
|
||||||
public IParserExtension createParserExtension() throws ParserFactoryError
|
public IASTFactoryExtension createASTExtension(ParserMode mode) {
|
||||||
{ // TODO Auto-generated method stub
|
if( dialect == ExtensionDialect.GCC )
|
||||||
return null;
|
return new GCCASTExtension( mode );
|
||||||
|
throw new ParserFactoryError( ParserFactoryError.Kind.BAD_DIALECT );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,7 @@ import org.eclipse.cdt.core.parser.ParseError.ParseErrorKind;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTCompletionNode;
|
import org.eclipse.cdt.core.parser.ast.IASTCompletionNode;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTNode;
|
import org.eclipse.cdt.core.parser.ast.IASTNode;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTScope;
|
import org.eclipse.cdt.core.parser.ast.IASTScope;
|
||||||
|
import org.eclipse.cdt.core.parser.extension.IParserExtension;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
|
@ -36,8 +37,8 @@ public class QuickParser extends Parser {
|
||||||
* @param language
|
* @param language
|
||||||
* @param log
|
* @param log
|
||||||
*/
|
*/
|
||||||
public QuickParser(IScanner scanner, ISourceElementRequestor callback, ParserLanguage language, IParserLogService log) {
|
public QuickParser(IScanner scanner, ISourceElementRequestor callback, ParserLanguage language, IParserLogService log, IParserExtension extension) {
|
||||||
super(scanner, callback, language, log);
|
super(scanner, callback, language, log, extension);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void handleFunctionBody(IASTScope scope) throws BacktrackException, EndOfFileException
|
protected void handleFunctionBody(IASTScope scope) throws BacktrackException, EndOfFileException
|
||||||
|
|
|
@ -23,6 +23,7 @@ import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTCompletionNode;
|
import org.eclipse.cdt.core.parser.ast.IASTCompletionNode;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTNode;
|
import org.eclipse.cdt.core.parser.ast.IASTNode;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTScope;
|
import org.eclipse.cdt.core.parser.ast.IASTScope;
|
||||||
|
import org.eclipse.cdt.core.parser.extension.IParserExtension;
|
||||||
import org.eclipse.cdt.internal.core.parser.token.OffsetDuple;
|
import org.eclipse.cdt.internal.core.parser.token.OffsetDuple;
|
||||||
import org.eclipse.cdt.internal.core.parser.token.TokenDuple;
|
import org.eclipse.cdt.internal.core.parser.token.TokenDuple;
|
||||||
import org.eclipse.cdt.internal.core.parser.util.TraceUtil;
|
import org.eclipse.cdt.internal.core.parser.util.TraceUtil;
|
||||||
|
@ -79,8 +80,8 @@ public class SelectionParser extends ContextualParser {
|
||||||
* @param language
|
* @param language
|
||||||
* @param log
|
* @param log
|
||||||
*/
|
*/
|
||||||
public SelectionParser(IScanner scanner, ISourceElementRequestor callback, ParserLanguage language, IParserLogService log) {
|
public SelectionParser(IScanner scanner, ISourceElementRequestor callback, ParserLanguage language, IParserLogService log, IParserExtension extension ) {
|
||||||
super(scanner, callback, language, log);
|
super(scanner, callback, language, log,extension);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
|
|
@ -24,6 +24,7 @@ import org.eclipse.cdt.core.parser.ParseError.ParseErrorKind;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTCompletionNode;
|
import org.eclipse.cdt.core.parser.ast.IASTCompletionNode;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTNode;
|
import org.eclipse.cdt.core.parser.ast.IASTNode;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTScope;
|
import org.eclipse.cdt.core.parser.ast.IASTScope;
|
||||||
|
import org.eclipse.cdt.core.parser.extension.IParserExtension;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
|
@ -36,8 +37,8 @@ public class StructuralParser extends Parser implements IParser {
|
||||||
* @param language
|
* @param language
|
||||||
* @param logService
|
* @param logService
|
||||||
*/
|
*/
|
||||||
public StructuralParser(IScanner scanner, ISourceElementRequestor ourCallback, ParserLanguage language, IParserLogService logService) {
|
public StructuralParser(IScanner scanner, ISourceElementRequestor ourCallback, ParserLanguage language, IParserLogService logService, IParserExtension extension ) {
|
||||||
super(scanner, ourCallback, language, logService);
|
super(scanner, ourCallback, language, logService, extension );
|
||||||
setupASTFactory(scanner, language );
|
setupASTFactory(scanner, language );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,132 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* Copyright (c) 2002,2003 Rational Software Corporation and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Common Public License v0.5
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/cpl-v05.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* IBM Rational Software - Initial API and implementation */
|
||||||
|
|
||||||
|
package org.eclipse.cdt.internal.core.parser.ast;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Hashtable;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.parser.ITokenDuple;
|
||||||
|
import org.eclipse.cdt.core.parser.ParserMode;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTExpression;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTScope;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTSimpleTypeSpecifier;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTTypeId;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTExpression.IASTNewExpressionDescriptor;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTExpression.Kind;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTSimpleTypeSpecifier.Type;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.gcc.IASTGCCExpression;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.gcc.IASTGCCSimpleTypeSpecifier;
|
||||||
|
import org.eclipse.cdt.core.parser.extension.IASTFactoryExtension;
|
||||||
|
import org.eclipse.cdt.internal.core.parser.ast.complete.ASTExpression;
|
||||||
|
import org.eclipse.cdt.internal.core.parser.ast.complete.ASTTypeId;
|
||||||
|
import org.eclipse.cdt.internal.core.parser.ast.complete.gcc.ASTGCCSimpleTypeSpecifier;
|
||||||
|
import org.eclipse.cdt.internal.core.parser.ast.expression.gcc.ASTGCCExpression;
|
||||||
|
import org.eclipse.cdt.internal.core.parser.pst.ISymbol;
|
||||||
|
import org.eclipse.cdt.internal.core.parser.pst.ParserSymbolTable;
|
||||||
|
import org.eclipse.cdt.internal.core.parser.pst.TypeInfo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jcamelon
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class GCCASTExtension implements IASTFactoryExtension {
|
||||||
|
private final ParserMode mode;
|
||||||
|
private static final String EMPTY_STRING = ""; //$NON-NLS-1$
|
||||||
|
private static final List EMPTY_LIST = new ArrayList( 0 );
|
||||||
|
/**
|
||||||
|
* @param mode
|
||||||
|
*/
|
||||||
|
public GCCASTExtension(ParserMode mode) {
|
||||||
|
this.mode = mode;
|
||||||
|
}
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.extension.IASTFactoryExtension#overrideExpressionFactory()
|
||||||
|
*/
|
||||||
|
public boolean overrideCreateExpressionMethod() {
|
||||||
|
if( mode == ParserMode.EXPRESSION_PARSE )
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.extension.IASTFactoryExtension#createExpression(org.eclipse.cdt.core.parser.ast.IASTScope, org.eclipse.cdt.core.parser.ast.IASTExpression.Kind, org.eclipse.cdt.core.parser.ast.IASTExpression, org.eclipse.cdt.core.parser.ast.IASTExpression, org.eclipse.cdt.core.parser.ast.IASTExpression, org.eclipse.cdt.core.parser.ast.IASTTypeId, org.eclipse.cdt.core.parser.ITokenDuple, java.lang.String, org.eclipse.cdt.core.parser.ast.IASTExpression.IASTNewExpressionDescriptor)
|
||||||
|
*/
|
||||||
|
public IASTExpression createExpression(IASTScope scope, Kind kind,
|
||||||
|
IASTExpression lhs, IASTExpression rhs,
|
||||||
|
IASTExpression thirdExpression, IASTTypeId typeId,
|
||||||
|
ITokenDuple idExpression, String literal,
|
||||||
|
IASTNewExpressionDescriptor newDescriptor)
|
||||||
|
{
|
||||||
|
return new ASTGCCExpression( kind, lhs, rhs, thirdExpression, typeId, idExpression == null ? "" : idExpression.toString(), literal, newDescriptor );
|
||||||
|
}
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.extension.IASTFactoryExtension#canHandleExpressionKind(org.eclipse.cdt.core.parser.ast.IASTExpression.Kind)
|
||||||
|
*/
|
||||||
|
public boolean canHandleExpressionKind(Kind kind) {
|
||||||
|
if( kind == IASTGCCExpression.Kind.UNARY_ALIGNOF_TYPEID ||
|
||||||
|
kind == IASTGCCExpression.Kind.UNARY_ALIGNOF_UNARYEXPRESSION ||
|
||||||
|
kind == IASTGCCExpression.Kind.UNARY_TYPEOF_UNARYEXPRESSION ||
|
||||||
|
kind == IASTGCCExpression.Kind.UNARY_TYPEOF_TYPEID )
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.extension.IASTFactoryExtension#getExpressionResultType(org.eclipse.cdt.internal.core.parser.pst.TypeInfo, org.eclipse.cdt.core.parser.ast.IASTExpression.Kind, org.eclipse.cdt.core.parser.ast.IASTExpression, org.eclipse.cdt.core.parser.ast.IASTExpression, org.eclipse.cdt.core.parser.ast.IASTExpression, org.eclipse.cdt.core.parser.ast.IASTTypeId, org.eclipse.cdt.internal.core.parser.pst.ISymbol)
|
||||||
|
*/
|
||||||
|
public TypeInfo getExpressionResultType(Kind kind, IASTExpression lhs, IASTExpression rhs, IASTTypeId typeId) {
|
||||||
|
TypeInfo info = null;
|
||||||
|
if( kind == IASTGCCExpression.Kind.UNARY_ALIGNOF_TYPEID ||
|
||||||
|
kind == IASTGCCExpression.Kind.UNARY_ALIGNOF_UNARYEXPRESSION )
|
||||||
|
{
|
||||||
|
info = new TypeInfo();
|
||||||
|
info.setType(TypeInfo.t_int);
|
||||||
|
info.setBit(true, TypeInfo.isUnsigned);
|
||||||
|
}
|
||||||
|
else if( kind == IASTGCCExpression.Kind.UNARY_TYPEOF_TYPEID )
|
||||||
|
{
|
||||||
|
if( typeId instanceof ASTTypeId )
|
||||||
|
info = new TypeInfo( ((ASTTypeId)typeId).getTypeSymbol().getTypeInfo() );
|
||||||
|
}
|
||||||
|
else if ( kind == IASTGCCExpression.Kind.UNARY_TYPEOF_UNARYEXPRESSION )
|
||||||
|
{
|
||||||
|
if( lhs instanceof ASTExpression )
|
||||||
|
info = new TypeInfo( ((ASTExpression)lhs).getResultType().getResult() );
|
||||||
|
}
|
||||||
|
|
||||||
|
if( info != null )
|
||||||
|
return info;
|
||||||
|
return new TypeInfo();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.extension.IASTFactoryExtension#overrideCreateSimpleTypeSpecifierMethod()
|
||||||
|
*/
|
||||||
|
public boolean overrideCreateSimpleTypeSpecifierMethod(Type type) {
|
||||||
|
if( type == IASTGCCSimpleTypeSpecifier.Type.TYPEOF )
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.extension.IASTFactoryExtension#createSimpleTypeSpecifier(org.eclipse.cdt.core.parser.ast.IASTScope, org.eclipse.cdt.core.parser.ast.IASTSimpleTypeSpecifier.Type, org.eclipse.cdt.core.parser.ITokenDuple, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean)
|
||||||
|
*/
|
||||||
|
public IASTSimpleTypeSpecifier createSimpleTypeSpecifier(ParserSymbolTable pst, IASTScope scope, Type kind, ITokenDuple typeName, boolean isShort, boolean isLong, boolean isSigned, boolean isUnsigned, boolean isTypename, boolean isComplex, boolean isImaginary, boolean isGlobal, Hashtable extensionParms) {
|
||||||
|
if( kind == IASTGCCSimpleTypeSpecifier.Type.TYPEOF )
|
||||||
|
{
|
||||||
|
ASTExpression typeOfExpression = (ASTExpression) extensionParms.get( ASTGCCSimpleTypeSpecifier.TYPEOF_EXRESSION );
|
||||||
|
ISymbol s = pst.newSymbol( EMPTY_STRING );
|
||||||
|
s.setTypeInfo( typeOfExpression.getResultType().getResult() );
|
||||||
|
return new ASTGCCSimpleTypeSpecifier( s, isTypename, ( typeName == null ? EMPTY_STRING : typeName.toString()), EMPTY_LIST, typeOfExpression );
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -12,6 +12,7 @@ package org.eclipse.cdt.internal.core.parser.ast.complete;
|
||||||
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Hashtable;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -71,7 +72,7 @@ import org.eclipse.cdt.core.parser.ast.IASTExpression.IASTNewExpressionDescripto
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTExpression.Kind;
|
import org.eclipse.cdt.core.parser.ast.IASTExpression.Kind;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTSimpleTypeSpecifier.Type;
|
import org.eclipse.cdt.core.parser.ast.IASTSimpleTypeSpecifier.Type;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTTemplateParameter.ParamKind;
|
import org.eclipse.cdt.core.parser.ast.IASTTemplateParameter.ParamKind;
|
||||||
import org.eclipse.cdt.core.parser.ast.extension.IASTExtensionFactory;
|
import org.eclipse.cdt.core.parser.extension.IASTFactoryExtension;
|
||||||
import org.eclipse.cdt.internal.core.parser.ast.BaseASTFactory;
|
import org.eclipse.cdt.internal.core.parser.ast.BaseASTFactory;
|
||||||
import org.eclipse.cdt.internal.core.parser.problem.IProblemFactory;
|
import org.eclipse.cdt.internal.core.parser.problem.IProblemFactory;
|
||||||
import org.eclipse.cdt.internal.core.parser.pst.ForewardDeclaredSymbolExtension;
|
import org.eclipse.cdt.internal.core.parser.pst.ForewardDeclaredSymbolExtension;
|
||||||
|
@ -109,8 +110,8 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
||||||
protected static final String EMPTY_STRING = ""; //$NON-NLS-1$
|
protected static final String EMPTY_STRING = ""; //$NON-NLS-1$
|
||||||
private final static List SUBSCRIPT;
|
private final static List SUBSCRIPT;
|
||||||
private final static IProblemFactory problemFactory = new ASTProblemFactory();
|
private final static IProblemFactory problemFactory = new ASTProblemFactory();
|
||||||
//private final IASTExtensionFactory extensionFactory;
|
|
||||||
private final IFilenameProvider fileProvider;
|
private final IFilenameProvider fileProvider;
|
||||||
|
private final IASTFactoryExtension extension;
|
||||||
|
|
||||||
static
|
static
|
||||||
{
|
{
|
||||||
|
@ -131,12 +132,12 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public CompleteParseASTFactory( IFilenameProvider filenameProvider, ParserLanguage language, ParserMode mode, IASTExtensionFactory factory )
|
public CompleteParseASTFactory( IFilenameProvider filenameProvider, ParserLanguage language, ParserMode mode, IASTFactoryExtension extension )
|
||||||
{
|
{
|
||||||
super();
|
super();
|
||||||
pst = new ParserSymbolTable( language, mode );
|
pst = new ParserSymbolTable( language, mode );
|
||||||
fileProvider = filenameProvider;
|
fileProvider = filenameProvider;
|
||||||
// extensionFactory = factory;
|
this.extension = extension;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1282,8 +1283,16 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
||||||
String literal,
|
String literal,
|
||||||
ISymbol symbol) throws ASTSemanticException{
|
ISymbol symbol) throws ASTSemanticException{
|
||||||
|
|
||||||
ExpressionResult result = null;
|
|
||||||
TypeInfo info = new TypeInfo();
|
TypeInfo info = new TypeInfo();
|
||||||
|
|
||||||
|
if( extension.canHandleExpressionKind( kind ))
|
||||||
|
{
|
||||||
|
extension.getExpressionResultType( kind, lhs, rhs, typeId );
|
||||||
|
return new ExpressionResult( info );
|
||||||
|
}
|
||||||
|
|
||||||
|
ExpressionResult result = null;
|
||||||
if( literal != null && !literal.equals(EMPTY_STRING) ){
|
if( literal != null && !literal.equals(EMPTY_STRING) ){
|
||||||
info.setDefault( literal );
|
info.setDefault( literal );
|
||||||
}
|
}
|
||||||
|
@ -1742,8 +1751,10 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
||||||
boolean isTypename,
|
boolean isTypename,
|
||||||
boolean isComplex,
|
boolean isComplex,
|
||||||
boolean isImaginary,
|
boolean isImaginary,
|
||||||
boolean isGlobal ) throws ASTSemanticException
|
boolean isGlobal, Hashtable extensionParms ) throws ASTSemanticException
|
||||||
{
|
{
|
||||||
|
if( extension.overrideCreateSimpleTypeSpecifierMethod( kind ))
|
||||||
|
return extension.createSimpleTypeSpecifier(pst, scope, kind, typeName, isShort, isLong, isSigned, isUnsigned, isTypename, isComplex, isImaginary, isGlobal, extensionParms );
|
||||||
TypeInfo.eType type = null;
|
TypeInfo.eType type = null;
|
||||||
|
|
||||||
if( kind == IASTSimpleTypeSpecifier.Type.CLASS_OR_TYPENAME )
|
if( kind == IASTSimpleTypeSpecifier.Type.CLASS_OR_TYPENAME )
|
||||||
|
@ -2209,7 +2220,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
||||||
if( references == null )
|
if( references == null )
|
||||||
{
|
{
|
||||||
references = new ArrayList();
|
references = new ArrayList();
|
||||||
if( nameDuple.length() != 1 )
|
if( nameDuple.length() > 2 ) // destructor
|
||||||
{
|
{
|
||||||
ITokenDuple leadingSegments = nameDuple.getLeadingSegments();
|
ITokenDuple leadingSegments = nameDuple.getLeadingSegments();
|
||||||
ISymbol test = lookupQualifiedName( ownerScope, leadingSegments, references, false );
|
ISymbol test = lookupQualifiedName( ownerScope, leadingSegments, references, false );
|
||||||
|
|
|
@ -1,37 +0,0 @@
|
||||||
/*******************************************************************************
|
|
||||||
* Copyright (c) 2000 - 2004 IBM Corporation and others.
|
|
||||||
* All rights reserved. This program and the accompanying materials
|
|
||||||
* are made available under the terms of the Common Public License v1.0
|
|
||||||
* which accompanies this distribution, and is available at
|
|
||||||
* http://www.eclipse.org/legal/cpl-v10.html
|
|
||||||
*
|
|
||||||
* Contributors:
|
|
||||||
* IBM Corporation - initial API and implementation
|
|
||||||
*******************************************************************************/
|
|
||||||
package org.eclipse.cdt.internal.core.parser.ast.complete.extension;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.core.parser.ast.ASTNotImplementedException;
|
|
||||||
import org.eclipse.cdt.core.parser.ast.extension.IASTExpressionExtension;
|
|
||||||
import org.eclipse.cdt.core.parser.ast.extension.IASTExtensionFactory;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author jcamelon
|
|
||||||
*/
|
|
||||||
public class CompleteParseASTExtensionFactory implements IASTExtensionFactory {
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public CompleteParseASTExtensionFactory() {
|
|
||||||
super();
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.parser.ast.extension.IASTExtensionFactory#createExpressionExtension(org.eclipse.cdt.core.parser.ast.IASTExpression)
|
|
||||||
*/
|
|
||||||
public IASTExpressionExtension createExpressionExtension()
|
|
||||||
throws ASTNotImplementedException {
|
|
||||||
throw new ASTNotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -0,0 +1,57 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* Copyright (c) 2002,2003 Rational Software Corporation and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Common Public License v0.5
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/cpl-v05.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* IBM Rational Software - Initial API and implementation */
|
||||||
|
|
||||||
|
package org.eclipse.cdt.internal.core.parser.ast.complete.gcc;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTExpression;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTSimpleTypeSpecifier;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.gcc.IASTGCCSimpleTypeSpecifier;
|
||||||
|
import org.eclipse.cdt.internal.core.parser.ast.complete.ASTSimpleTypeSpecifier;
|
||||||
|
import org.eclipse.cdt.internal.core.parser.pst.ISymbol;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jcamelon
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class ASTGCCSimpleTypeSpecifier extends ASTSimpleTypeSpecifier implements IASTGCCSimpleTypeSpecifier {
|
||||||
|
|
||||||
|
public static final String TYPEOF_EXRESSION = "TYPEOF EXPRESSION"; //$NON-NLS-1$
|
||||||
|
private final IASTExpression expression;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param s
|
||||||
|
* @param b
|
||||||
|
* @param string
|
||||||
|
* @param references
|
||||||
|
*/
|
||||||
|
public ASTGCCSimpleTypeSpecifier(ISymbol s, boolean b, String string, List references, IASTExpression typeOfExpression ) {
|
||||||
|
super(s, b, string, references);
|
||||||
|
expression = typeOfExpression;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ast.IASTSimpleTypeSpecifier#getType()
|
||||||
|
*/
|
||||||
|
public IASTSimpleTypeSpecifier.Type getType() {
|
||||||
|
if( expression != null ) return IASTGCCSimpleTypeSpecifier.Type.TYPEOF;
|
||||||
|
return super.getType();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ast.gcc.IASTGCCSimpleTypeSpecifier#getTypeOfExpression()
|
||||||
|
*/
|
||||||
|
public IASTExpression getTypeOfExpression() {
|
||||||
|
return expression;
|
||||||
|
}
|
||||||
|
}
|
|
@ -11,7 +11,6 @@ import org.eclipse.cdt.core.parser.ast.ASTExpressionEvaluationException;
|
||||||
import org.eclipse.cdt.core.parser.ast.ASTNotImplementedException;
|
import org.eclipse.cdt.core.parser.ast.ASTNotImplementedException;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTExpression;
|
import org.eclipse.cdt.core.parser.ast.IASTExpression;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTTypeId;
|
import org.eclipse.cdt.core.parser.ast.IASTTypeId;
|
||||||
import org.eclipse.cdt.core.parser.ast.extension.IASTExpressionExtension;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -25,7 +24,6 @@ public class ASTExpression implements IASTExpression {
|
||||||
private final IASTTypeId typeId;
|
private final IASTTypeId typeId;
|
||||||
private final String literal, idExpression;
|
private final String literal, idExpression;
|
||||||
private final IASTNewExpressionDescriptor newDescriptor;
|
private final IASTNewExpressionDescriptor newDescriptor;
|
||||||
private final IASTExpressionExtension extension;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param kind
|
* @param kind
|
||||||
|
@ -35,7 +33,7 @@ public class ASTExpression implements IASTExpression {
|
||||||
* @param typeId
|
* @param typeId
|
||||||
* @param literal
|
* @param literal
|
||||||
*/
|
*/
|
||||||
public ASTExpression(Kind kind, IASTExpression lhs, IASTExpression rhs, IASTExpression third, IASTTypeId typeId, String idExpression, String literal, IASTNewExpressionDescriptor newDescriptor, IASTExpressionExtension extension) {
|
public ASTExpression(Kind kind, IASTExpression lhs, IASTExpression rhs, IASTExpression third, IASTTypeId typeId, String idExpression, String literal, IASTNewExpressionDescriptor newDescriptor ) {
|
||||||
this.kind = kind;
|
this.kind = kind;
|
||||||
this.lhs =lhs;
|
this.lhs =lhs;
|
||||||
this.rhs = rhs;
|
this.rhs = rhs;
|
||||||
|
@ -44,8 +42,6 @@ public class ASTExpression implements IASTExpression {
|
||||||
this.literal = literal;
|
this.literal = literal;
|
||||||
this.newDescriptor = newDescriptor;
|
this.newDescriptor = newDescriptor;
|
||||||
this.idExpression = idExpression;
|
this.idExpression = idExpression;
|
||||||
this.extension = extension;
|
|
||||||
this.extension.setExpression(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@ -173,7 +169,7 @@ public class ASTExpression implements IASTExpression {
|
||||||
if( getExpressionKind() == IASTExpression.Kind.LOGICALOREXPRESSION )
|
if( getExpressionKind() == IASTExpression.Kind.LOGICALOREXPRESSION )
|
||||||
return( ( getLHSExpression().evaluateExpression() != 0 ) || ( getRHSExpression().evaluateExpression() != 0 ) ) ? 1 : 0 ;
|
return( ( getLHSExpression().evaluateExpression() != 0 ) || ( getRHSExpression().evaluateExpression() != 0 ) ) ? 1 : 0 ;
|
||||||
|
|
||||||
return extension.evaluateExpression();
|
throw new ASTExpressionEvaluationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.parser.ast.expression;
|
package org.eclipse.cdt.internal.core.parser.ast.expression;
|
||||||
|
|
||||||
|
import java.util.Hashtable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.parser.IMacroDescriptor;
|
import org.eclipse.cdt.core.parser.IMacroDescriptor;
|
||||||
|
@ -17,7 +18,6 @@ import org.eclipse.cdt.core.parser.IToken;
|
||||||
import org.eclipse.cdt.core.parser.ITokenDuple;
|
import org.eclipse.cdt.core.parser.ITokenDuple;
|
||||||
import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
|
import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
|
||||||
import org.eclipse.cdt.core.parser.ast.ASTClassKind;
|
import org.eclipse.cdt.core.parser.ast.ASTClassKind;
|
||||||
import org.eclipse.cdt.core.parser.ast.ASTExpressionEvaluationException;
|
|
||||||
import org.eclipse.cdt.core.parser.ast.ASTNotImplementedException;
|
import org.eclipse.cdt.core.parser.ast.ASTNotImplementedException;
|
||||||
import org.eclipse.cdt.core.parser.ast.ASTPointerOperator;
|
import org.eclipse.cdt.core.parser.ast.ASTPointerOperator;
|
||||||
import org.eclipse.cdt.core.parser.ast.ASTSemanticException;
|
import org.eclipse.cdt.core.parser.ast.ASTSemanticException;
|
||||||
|
@ -65,8 +65,7 @@ import org.eclipse.cdt.core.parser.ast.IASTExpression.IASTNewExpressionDescripto
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTExpression.Kind;
|
import org.eclipse.cdt.core.parser.ast.IASTExpression.Kind;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTSimpleTypeSpecifier.Type;
|
import org.eclipse.cdt.core.parser.ast.IASTSimpleTypeSpecifier.Type;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTTemplateParameter.ParamKind;
|
import org.eclipse.cdt.core.parser.ast.IASTTemplateParameter.ParamKind;
|
||||||
import org.eclipse.cdt.core.parser.ast.extension.IASTExpressionExtension;
|
import org.eclipse.cdt.core.parser.extension.IASTFactoryExtension;
|
||||||
import org.eclipse.cdt.core.parser.ast.extension.IASTExtensionFactory;
|
|
||||||
import org.eclipse.cdt.internal.core.parser.ast.BaseASTFactory;
|
import org.eclipse.cdt.internal.core.parser.ast.BaseASTFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -74,13 +73,15 @@ import org.eclipse.cdt.internal.core.parser.ast.BaseASTFactory;
|
||||||
*/
|
*/
|
||||||
public class ExpressionParseASTFactory extends BaseASTFactory implements IASTFactory {
|
public class ExpressionParseASTFactory extends BaseASTFactory implements IASTFactory {
|
||||||
|
|
||||||
private final IASTExtensionFactory extensionFactory;
|
|
||||||
|
|
||||||
|
private final IASTFactoryExtension extension;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param factory
|
* @param factory
|
||||||
*/
|
*/
|
||||||
public ExpressionParseASTFactory(IASTExtensionFactory factory) {
|
public ExpressionParseASTFactory( IASTFactoryExtension extension ) {
|
||||||
this.extensionFactory = factory;
|
this.extension = extension;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -378,7 +379,8 @@ public class ExpressionParseASTFactory extends BaseASTFactory implements IASTFac
|
||||||
String literal,
|
String literal,
|
||||||
IASTNewExpressionDescriptor newDescriptor)
|
IASTNewExpressionDescriptor newDescriptor)
|
||||||
throws ASTSemanticException {
|
throws ASTSemanticException {
|
||||||
try {
|
if( extension.overrideCreateExpressionMethod() )
|
||||||
|
return extension.createExpression(scope, kind, lhs, rhs, thirdExpression, typeId, idExpression, literal, newDescriptor );
|
||||||
return new ASTExpression(
|
return new ASTExpression(
|
||||||
kind,
|
kind,
|
||||||
lhs,
|
lhs,
|
||||||
|
@ -387,29 +389,8 @@ public class ExpressionParseASTFactory extends BaseASTFactory implements IASTFac
|
||||||
typeId,
|
typeId,
|
||||||
idExpression == null ? "" : idExpression.toString(), //$NON-NLS-1$
|
idExpression == null ? "" : idExpression.toString(), //$NON-NLS-1$
|
||||||
literal,
|
literal,
|
||||||
newDescriptor,
|
newDescriptor );
|
||||||
extensionFactory.createExpressionExtension());
|
|
||||||
} catch (ASTNotImplementedException e) {
|
|
||||||
return new ASTExpression(
|
|
||||||
kind,
|
|
||||||
lhs,
|
|
||||||
rhs,
|
|
||||||
thirdExpression,
|
|
||||||
typeId,
|
|
||||||
idExpression == null ? "" : idExpression.toString(), //$NON-NLS-1$
|
|
||||||
literal,
|
|
||||||
newDescriptor,
|
|
||||||
new IASTExpressionExtension() {
|
|
||||||
|
|
||||||
public void setExpression(IASTExpression expression) {
|
|
||||||
}
|
|
||||||
|
|
||||||
public int evaluateExpression()
|
|
||||||
throws ASTExpressionEvaluationException {
|
|
||||||
throw new ASTExpressionEvaluationException();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -503,7 +484,7 @@ public class ExpressionParseASTFactory extends BaseASTFactory implements IASTFac
|
||||||
boolean isTypename,
|
boolean isTypename,
|
||||||
boolean isComplex,
|
boolean isComplex,
|
||||||
boolean isImaginary,
|
boolean isImaginary,
|
||||||
boolean isGlobal)
|
boolean isGlobal, Hashtable extensionParms)
|
||||||
throws ASTSemanticException {
|
throws ASTSemanticException {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -0,0 +1,47 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* Copyright (c) 2002,2003 Rational Software Corporation and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Common Public License v0.5
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/cpl-v05.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* IBM Rational Software - Initial API and implementation */
|
||||||
|
|
||||||
|
package org.eclipse.cdt.internal.core.parser.ast.expression.gcc;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.parser.ast.ASTExpressionEvaluationException;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTExpression;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTTypeId;
|
||||||
|
import org.eclipse.cdt.internal.core.parser.ast.expression.ASTExpression;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jcamelon
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class ASTGCCExpression extends ASTExpression {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param kind
|
||||||
|
* @param lhs
|
||||||
|
* @param rhs
|
||||||
|
* @param third
|
||||||
|
* @param typeId
|
||||||
|
* @param idExpression
|
||||||
|
* @param literal
|
||||||
|
* @param newDescriptor
|
||||||
|
*/
|
||||||
|
public ASTGCCExpression(Kind kind, IASTExpression lhs, IASTExpression rhs, IASTExpression third, IASTTypeId typeId, String idExpression, String literal, IASTNewExpressionDescriptor newDescriptor) {
|
||||||
|
super(kind, lhs, rhs, third, typeId, idExpression, literal, newDescriptor);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ast.IASTExpression#evaluateExpression()
|
||||||
|
*/
|
||||||
|
public int evaluateExpression() throws ASTExpressionEvaluationException {
|
||||||
|
if( getExpressionKind() == Kind.ID_EXPRESSION )
|
||||||
|
return 0;
|
||||||
|
return super.evaluateExpression();
|
||||||
|
}
|
||||||
|
}
|
|
@ -10,12 +10,12 @@
|
||||||
***********************************************************************/
|
***********************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.parser.ast.quick;
|
package org.eclipse.cdt.internal.core.parser.ast.quick;
|
||||||
|
|
||||||
|
import java.util.Hashtable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.parser.ITokenDuple;
|
import org.eclipse.cdt.core.parser.ITokenDuple;
|
||||||
import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
|
import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
|
||||||
import org.eclipse.cdt.core.parser.ast.ASTClassKind;
|
import org.eclipse.cdt.core.parser.ast.ASTClassKind;
|
||||||
import org.eclipse.cdt.core.parser.ast.ASTExpressionEvaluationException;
|
|
||||||
import org.eclipse.cdt.core.parser.ast.ASTNotImplementedException;
|
import org.eclipse.cdt.core.parser.ast.ASTNotImplementedException;
|
||||||
import org.eclipse.cdt.core.parser.ast.ASTPointerOperator;
|
import org.eclipse.cdt.core.parser.ast.ASTPointerOperator;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTASMDefinition;
|
import org.eclipse.cdt.core.parser.ast.IASTASMDefinition;
|
||||||
|
@ -58,8 +58,6 @@ import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier.ClassNameType;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTExpression.IASTNewExpressionDescriptor;
|
import org.eclipse.cdt.core.parser.ast.IASTExpression.IASTNewExpressionDescriptor;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTExpression.Kind;
|
import org.eclipse.cdt.core.parser.ast.IASTExpression.Kind;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTSimpleTypeSpecifier.Type;
|
import org.eclipse.cdt.core.parser.ast.IASTSimpleTypeSpecifier.Type;
|
||||||
import org.eclipse.cdt.core.parser.ast.extension.IASTExpressionExtension;
|
|
||||||
import org.eclipse.cdt.core.parser.ast.extension.IASTExtensionFactory;
|
|
||||||
import org.eclipse.cdt.internal.core.parser.ast.BaseASTFactory;
|
import org.eclipse.cdt.internal.core.parser.ast.BaseASTFactory;
|
||||||
import org.eclipse.cdt.internal.core.parser.ast.expression.ASTExpression;
|
import org.eclipse.cdt.internal.core.parser.ast.expression.ASTExpression;
|
||||||
|
|
||||||
|
@ -71,12 +69,11 @@ import org.eclipse.cdt.internal.core.parser.ast.expression.ASTExpression;
|
||||||
public class QuickParseASTFactory extends BaseASTFactory implements IASTFactory {
|
public class QuickParseASTFactory extends BaseASTFactory implements IASTFactory {
|
||||||
|
|
||||||
private static final boolean CREATE_EXCESS_CONSTRUCTS = true;
|
private static final boolean CREATE_EXCESS_CONSTRUCTS = true;
|
||||||
private final IASTExtensionFactory extensionFactory;
|
|
||||||
|
|
||||||
public QuickParseASTFactory( IASTExtensionFactory extensionFactory )
|
|
||||||
|
public QuickParseASTFactory( )
|
||||||
{
|
{
|
||||||
super();
|
super();
|
||||||
this.extensionFactory = extensionFactory;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@ -162,20 +159,7 @@ public class QuickParseASTFactory extends BaseASTFactory implements IASTFactory
|
||||||
*/
|
*/
|
||||||
public IASTExpression createExpression(IASTScope scope, Kind kind, IASTExpression lhs, IASTExpression rhs, IASTExpression thirdExpression, IASTTypeId typeId, ITokenDuple idExpression, String literal, IASTNewExpressionDescriptor newDescriptor) {
|
public IASTExpression createExpression(IASTScope scope, Kind kind, IASTExpression lhs, IASTExpression rhs, IASTExpression thirdExpression, IASTTypeId typeId, ITokenDuple idExpression, String literal, IASTNewExpressionDescriptor newDescriptor) {
|
||||||
if( CREATE_EXCESS_CONSTRUCTS )
|
if( CREATE_EXCESS_CONSTRUCTS )
|
||||||
{
|
return new ASTExpression( kind, lhs, rhs, thirdExpression, typeId, idExpression == null ? "" : idExpression.toString(), literal, newDescriptor ); //$NON-NLS-1$
|
||||||
try {
|
|
||||||
return new ASTExpression( kind, lhs, rhs, thirdExpression, typeId, idExpression == null ? "" : idExpression.toString(), literal, newDescriptor, extensionFactory.createExpressionExtension() ); //$NON-NLS-1$
|
|
||||||
} catch (ASTNotImplementedException e) {
|
|
||||||
return new ASTExpression( kind, lhs, rhs, thirdExpression, typeId, idExpression == null ? "" : idExpression.toString(), literal, newDescriptor, new IASTExpressionExtension() { //$NON-NLS-1$
|
|
||||||
|
|
||||||
public void setExpression(IASTExpression expression) {
|
|
||||||
}
|
|
||||||
|
|
||||||
public int evaluateExpression() throws ASTExpressionEvaluationException {
|
|
||||||
throw new ASTExpressionEvaluationException();
|
|
||||||
} } );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -208,7 +192,7 @@ public class QuickParseASTFactory extends BaseASTFactory implements IASTFactory
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#createSimpleTypeSpecifier(org.eclipse.cdt.core.parser.ast.IASTSimpleTypeSpecifier.SimpleType, org.eclipse.cdt.core.parser.ITokenDuple)
|
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#createSimpleTypeSpecifier(org.eclipse.cdt.core.parser.ast.IASTSimpleTypeSpecifier.SimpleType, org.eclipse.cdt.core.parser.ITokenDuple)
|
||||||
*/
|
*/
|
||||||
public IASTSimpleTypeSpecifier createSimpleTypeSpecifier(IASTScope scope, Type kind, ITokenDuple typeName, boolean isShort, boolean isLong, boolean isSigned, boolean isUnsigned, boolean isTypename, boolean isComplex, boolean isImaginary, boolean isGlobal)
|
public IASTSimpleTypeSpecifier createSimpleTypeSpecifier(IASTScope scope, Type kind, ITokenDuple typeName, boolean isShort, boolean isLong, boolean isSigned, boolean isUnsigned, boolean isTypename, boolean isComplex, boolean isImaginary, boolean isGlobal, Hashtable extensionParms)
|
||||||
{
|
{
|
||||||
return new ASTSimpleTypeSpecifier( kind, typeName, isShort, isLong, isSigned, isUnsigned, isTypename, isComplex, isImaginary);
|
return new ASTSimpleTypeSpecifier( kind, typeName, isShort, isLong, isSigned, isUnsigned, isTypename, isComplex, isImaginary);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,40 +0,0 @@
|
||||||
/*******************************************************************************
|
|
||||||
* Copyright (c) 2000 - 2004 IBM Corporation and others.
|
|
||||||
* All rights reserved. This program and the accompanying materials
|
|
||||||
* are made available under the terms of the Common Public License v1.0
|
|
||||||
* which accompanies this distribution, and is available at
|
|
||||||
* http://www.eclipse.org/legal/cpl-v10.html
|
|
||||||
*
|
|
||||||
* Contributors:
|
|
||||||
* IBM Corporation - initial API and implementation
|
|
||||||
*******************************************************************************/
|
|
||||||
package org.eclipse.cdt.internal.core.parser.ast.quick.extension;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.core.parser.ast.ASTExpressionEvaluationException;
|
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTExpression;
|
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTExpression.Kind;
|
|
||||||
import org.eclipse.cdt.core.parser.ast.extension.IASTExpressionExtension;
|
|
||||||
|
|
||||||
|
|
||||||
public final class ASTExpressionExtension implements IASTExpressionExtension {
|
|
||||||
private IASTExpression expression;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param ASTExpression
|
|
||||||
*/
|
|
||||||
public ASTExpressionExtension() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public int evaluateExpression() throws ASTExpressionEvaluationException {
|
|
||||||
if( this.expression.getExpressionKind() == Kind.ID_EXPRESSION )
|
|
||||||
return 0;
|
|
||||||
throw new ASTExpressionEvaluationException();
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.parser.ast.extension.IASTExpressionExtension#setExpression(org.eclipse.cdt.core.parser.ast.IASTExpression)
|
|
||||||
*/
|
|
||||||
public void setExpression(IASTExpression expression) {
|
|
||||||
this.expression = expression;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,35 +0,0 @@
|
||||||
/*******************************************************************************
|
|
||||||
* Copyright (c) 2000 - 2004 IBM Corporation and others.
|
|
||||||
* All rights reserved. This program and the accompanying materials
|
|
||||||
* are made available under the terms of the Common Public License v1.0
|
|
||||||
* which accompanies this distribution, and is available at
|
|
||||||
* http://www.eclipse.org/legal/cpl-v10.html
|
|
||||||
*
|
|
||||||
* Contributors:
|
|
||||||
* IBM Corporation - initial API and implementation
|
|
||||||
*******************************************************************************/
|
|
||||||
package org.eclipse.cdt.internal.core.parser.ast.quick.extension;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.core.parser.ast.extension.IASTExpressionExtension;
|
|
||||||
import org.eclipse.cdt.core.parser.ast.extension.IASTExtensionFactory;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author jcamelon
|
|
||||||
*/
|
|
||||||
public class QuickParseASTExtensionFactory implements IASTExtensionFactory {
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public QuickParseASTExtensionFactory() {
|
|
||||||
super();
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.parser.ast.extension.IASTExtensionFactory#createExpressionExtension(org.eclipse.cdt.core.parser.ast.IASTExpression)
|
|
||||||
*/
|
|
||||||
public IASTExpressionExtension createExpressionExtension() {
|
|
||||||
return new ASTExpressionExtension();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -11,18 +11,24 @@
|
||||||
package org.eclipse.cdt.internal.core.parser.scanner;
|
package org.eclipse.cdt.internal.core.parser.scanner;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.parser.CodeReader;
|
import org.eclipse.cdt.core.parser.CodeReader;
|
||||||
|
import org.eclipse.cdt.core.parser.GCCKeywords;
|
||||||
|
import org.eclipse.cdt.core.parser.IGCCToken;
|
||||||
import org.eclipse.cdt.core.parser.IScanner;
|
import org.eclipse.cdt.core.parser.IScanner;
|
||||||
|
import org.eclipse.cdt.core.parser.IToken;
|
||||||
import org.eclipse.cdt.core.parser.Keywords;
|
import org.eclipse.cdt.core.parser.Keywords;
|
||||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTInclusion;
|
import org.eclipse.cdt.core.parser.ast.IASTInclusion;
|
||||||
import org.eclipse.cdt.core.parser.extension.IScannerExtension;
|
import org.eclipse.cdt.core.parser.extension.IScannerExtension;
|
||||||
import org.eclipse.cdt.internal.core.parser.scanner.ScannerUtility.InclusionParseException;
|
import org.eclipse.cdt.internal.core.parser.scanner.ScannerUtility.InclusionParseException;
|
||||||
|
import org.eclipse.cdt.internal.core.parser.token.TokenFactory;
|
||||||
import org.eclipse.cdt.internal.core.parser.util.TraceUtil;
|
import org.eclipse.cdt.internal.core.parser.util.TraceUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -31,6 +37,10 @@ import org.eclipse.cdt.internal.core.parser.util.TraceUtil;
|
||||||
public class GCCScannerExtension implements IScannerExtension {
|
public class GCCScannerExtension implements IScannerExtension {
|
||||||
|
|
||||||
|
|
||||||
|
protected static final String POUND_IDENT = "#ident"; //$NON-NLS-1$
|
||||||
|
protected static final String POUND_WARNING = "#warning"; //$NON-NLS-1$
|
||||||
|
protected static final String POUND_INCLUDE_NEXT = "#include_next"; //$NON-NLS-1$
|
||||||
|
|
||||||
private static final String __CONST__ = "__const__"; //$NON-NLS-1$
|
private static final String __CONST__ = "__const__"; //$NON-NLS-1$
|
||||||
private static final String __CONST = "__const"; //$NON-NLS-1$
|
private static final String __CONST = "__const"; //$NON-NLS-1$
|
||||||
private static final String __INLINE__ = "__inline__"; //$NON-NLS-1$
|
private static final String __INLINE__ = "__inline__"; //$NON-NLS-1$
|
||||||
|
@ -39,8 +49,9 @@ public class GCCScannerExtension implements IScannerExtension {
|
||||||
private static final String __RESTRICT = "__restrict"; //$NON-NLS-1$
|
private static final String __RESTRICT = "__restrict"; //$NON-NLS-1$
|
||||||
private static final String __RESTRICT__ = "__restrict__"; //$NON-NLS-1$
|
private static final String __RESTRICT__ = "__restrict__"; //$NON-NLS-1$
|
||||||
private static final String __ASM__ = "__asm__"; //$NON-NLS-1$
|
private static final String __ASM__ = "__asm__"; //$NON-NLS-1$
|
||||||
|
private static final String __TYPEOF__ = "__typeof__"; //$NON-NLS-1$
|
||||||
|
|
||||||
|
|
||||||
private IScannerData scannerData;
|
|
||||||
private static final String __ATTRIBUTE__ = "__attribute__"; //$NON-NLS-1$
|
private static final String __ATTRIBUTE__ = "__attribute__"; //$NON-NLS-1$
|
||||||
private static final String __DECLSPEC = "__declspec"; //$NON-NLS-1$
|
private static final String __DECLSPEC = "__declspec"; //$NON-NLS-1$
|
||||||
private static final List EMPTY_LIST = new ArrayList();
|
private static final List EMPTY_LIST = new ArrayList();
|
||||||
|
@ -48,6 +59,8 @@ public class GCCScannerExtension implements IScannerExtension {
|
||||||
private static final List simpleIdentifiersDeclSpec;
|
private static final List simpleIdentifiersDeclSpec;
|
||||||
private static final List simpleIdentifiersAttribute;
|
private static final List simpleIdentifiersAttribute;
|
||||||
|
|
||||||
|
private ParserLanguage language;
|
||||||
|
|
||||||
static
|
static
|
||||||
{
|
{
|
||||||
simpleIdentifiersDeclSpec = new ArrayList( 1 );
|
simpleIdentifiersDeclSpec = new ArrayList( 1 );
|
||||||
|
@ -59,7 +72,7 @@ public class GCCScannerExtension implements IScannerExtension {
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.parser.IScannerExtension#initializeMacroValue(java.lang.String)
|
* @see org.eclipse.cdt.core.parser.IScannerExtension#initializeMacroValue(java.lang.String)
|
||||||
*/
|
*/
|
||||||
public String initializeMacroValue(String original) {
|
public String initializeMacroValue(IScannerData scannerData, String original) {
|
||||||
if( original == null || original.trim().equals( "") ) //$NON-NLS-1$
|
if( original == null || original.trim().equals( "") ) //$NON-NLS-1$
|
||||||
return "1"; //$NON-NLS-1$
|
return "1"; //$NON-NLS-1$
|
||||||
return original;
|
return original;
|
||||||
|
@ -68,14 +81,9 @@ public class GCCScannerExtension implements IScannerExtension {
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.parser.IScannerExtension#setupBuiltInMacros()
|
* @see org.eclipse.cdt.core.parser.IScannerExtension#setupBuiltInMacros()
|
||||||
*/
|
*/
|
||||||
public void setupBuiltInMacros(ParserLanguage language) {
|
public void setupBuiltInMacros(IScannerData scannerData, ParserLanguage language) {
|
||||||
|
this.language = language;
|
||||||
if( scannerData.getScanner().getDefinition( __ATTRIBUTE__) == null )
|
|
||||||
scannerData.getScanner().addDefinition( __ATTRIBUTE__, new FunctionMacroDescriptor( __ATTRIBUTE__, simpleIdentifiersDeclSpec, EMPTY_LIST, "" )); //$NON-NLS-1$ $NON-NLS-2$
|
|
||||||
|
|
||||||
if( scannerData.getScanner().getDefinition( __DECLSPEC) == null )
|
|
||||||
scannerData.getScanner().addDefinition( __DECLSPEC, new FunctionMacroDescriptor( __ATTRIBUTE__, simpleIdentifiersDeclSpec, EMPTY_LIST, "" )); //$NON-NLS-1$ $NON-NLS-2$
|
|
||||||
|
|
||||||
if( language == ParserLanguage.CPP )
|
if( language == ParserLanguage.CPP )
|
||||||
if( scannerData.getScanner().getDefinition( IScanner.__CPLUSPLUS ) == null )
|
if( scannerData.getScanner().getDefinition( IScanner.__CPLUSPLUS ) == null )
|
||||||
scannerData.getScanner().addDefinition( IScanner.__CPLUSPLUS, new ObjectMacroDescriptor( IScanner.__CPLUSPLUS, "1")); //$NON-NLS-1$
|
scannerData.getScanner().addDefinition( IScanner.__CPLUSPLUS, new ObjectMacroDescriptor( IScanner.__CPLUSPLUS, "1")); //$NON-NLS-1$
|
||||||
|
@ -85,50 +93,45 @@ public class GCCScannerExtension implements IScannerExtension {
|
||||||
if( scannerData.getScanner().getDefinition( IScanner.__STDC_VERSION__) == null )
|
if( scannerData.getScanner().getDefinition( IScanner.__STDC_VERSION__) == null )
|
||||||
scannerData.getScanner().addDefinition( IScanner.__STDC_VERSION__, new ObjectMacroDescriptor( IScanner.__STDC_VERSION__, "199001L")); //$NON-NLS-1$
|
scannerData.getScanner().addDefinition( IScanner.__STDC_VERSION__, new ObjectMacroDescriptor( IScanner.__STDC_VERSION__, "199001L")); //$NON-NLS-1$
|
||||||
|
|
||||||
setupAlternativeKeyword(__CONST__, Keywords.CONST);
|
//TODO - these macros should not be visible as macros in the scanner's definition list
|
||||||
setupAlternativeKeyword(__CONST, Keywords.CONST);
|
//need to make a public/private table i think
|
||||||
setupAlternativeKeyword(__INLINE__, Keywords.INLINE);
|
if( scannerData.getScanner().getDefinition( __ATTRIBUTE__) == null )
|
||||||
setupAlternativeKeyword(__SIGNED__, Keywords.SIGNED);
|
scannerData.getScanner().addDefinition( __ATTRIBUTE__, new FunctionMacroDescriptor( __ATTRIBUTE__, simpleIdentifiersDeclSpec, EMPTY_LIST, "" )); //$NON-NLS-1$ $NON-NLS-2$
|
||||||
setupAlternativeKeyword(__VOLATILE__, Keywords.VOLATILE);
|
|
||||||
if( language == ParserLanguage.C )
|
if( scannerData.getScanner().getDefinition( __DECLSPEC) == null )
|
||||||
{
|
scannerData.getScanner().addDefinition( __DECLSPEC, new FunctionMacroDescriptor( __ATTRIBUTE__, simpleIdentifiersDeclSpec, EMPTY_LIST, "" )); //$NON-NLS-1$ $NON-NLS-2$
|
||||||
setupAlternativeKeyword( __RESTRICT, Keywords.RESTRICT);
|
|
||||||
setupAlternativeKeyword( __RESTRICT__, Keywords.RESTRICT);
|
setupAlternativeKeyword(scannerData, __CONST__, Keywords.CONST);
|
||||||
}
|
setupAlternativeKeyword(scannerData, __CONST, Keywords.CONST);
|
||||||
else
|
setupAlternativeKeyword(scannerData, __INLINE__, Keywords.INLINE);
|
||||||
setupAlternativeKeyword( __ASM__, Keywords.ASM );
|
setupAlternativeKeyword(scannerData, __SIGNED__, Keywords.SIGNED);
|
||||||
|
setupAlternativeKeyword(scannerData, __VOLATILE__, Keywords.VOLATILE);
|
||||||
|
setupAlternativeKeyword( scannerData, __RESTRICT, Keywords.RESTRICT);
|
||||||
|
setupAlternativeKeyword( scannerData, __RESTRICT__, Keywords.RESTRICT);
|
||||||
|
setupAlternativeKeyword( scannerData, __TYPEOF__, GCCKeywords.TYPEOF );
|
||||||
|
if( language == ParserLanguage.CPP )
|
||||||
|
setupAlternativeKeyword( scannerData, __ASM__, Keywords.ASM );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @param scannerData TODO
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
protected void setupAlternativeKeyword(String keyword, String mapping) {
|
protected void setupAlternativeKeyword(IScannerData scannerData, String keyword, String mapping) {
|
||||||
// alternate keyword forms
|
// alternate keyword forms
|
||||||
// TODO - make this more efficient - update TokenFactory to avoid a context push for these token to token cases
|
// TODO - make this more efficient - update TokenFactory to avoid a context push for these token to token cases
|
||||||
if( scannerData.getScanner().getDefinition( keyword ) == null )
|
if( scannerData.getScanner().getDefinition( keyword ) == null )
|
||||||
scannerData.getScanner().addDefinition( keyword, new ObjectMacroDescriptor( __CONST__, mapping )); //$NON-NLS-1$
|
scannerData.getScanner().addDefinition( keyword, new ObjectMacroDescriptor( __CONST__, mapping )); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setScannerData(IScannerData scannerData) {
|
|
||||||
this.scannerData = scannerData;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Object clone( ) {
|
|
||||||
try {
|
|
||||||
return super.clone();
|
|
||||||
} catch (CloneNotSupportedException e) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final Set directives;
|
private static final Set directives;
|
||||||
static
|
static
|
||||||
{
|
{
|
||||||
directives = new HashSet();
|
directives = new HashSet();
|
||||||
directives.add( "#include_next" ); //$NON-NLS-1$
|
directives.add( POUND_INCLUDE_NEXT );
|
||||||
directives.add( "#warning"); //$NON-NLS-1$
|
directives.add( POUND_WARNING);
|
||||||
directives.add( "#ident"); //$NON-NLS-1$
|
directives.add( POUND_IDENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@ -141,8 +144,8 @@ public class GCCScannerExtension implements IScannerExtension {
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.parser.extension.IScannerExtension#handlePreprocessorDirective(java.lang.String, java.lang.String)
|
* @see org.eclipse.cdt.core.parser.extension.IScannerExtension#handlePreprocessorDirective(java.lang.String, java.lang.String)
|
||||||
*/
|
*/
|
||||||
public void handlePreprocessorDirective(String directive, String restOfLine) {
|
public void handlePreprocessorDirective(IScannerData scannerData, String directive, String restOfLine) {
|
||||||
if( directive.equals("#include_next") ) //$NON-NLS-1$
|
if( directive.equals(POUND_INCLUDE_NEXT) )
|
||||||
{
|
{
|
||||||
TraceUtil.outputTrace(scannerData.getLogService(), "GCCScannerExtension handling #include_next directive", null, null, null, null); //$NON-NLS-1$
|
TraceUtil.outputTrace(scannerData.getLogService(), "GCCScannerExtension handling #include_next directive", null, null, null, null); //$NON-NLS-1$
|
||||||
// figure out the name of the current file and its path
|
// figure out the name of the current file and its path
|
||||||
|
@ -191,7 +194,7 @@ public class GCCScannerExtension implements IScannerExtension {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else if( directive.equals( "#warning") || directive.equals("#ident")) //$NON-NLS-1$ //$NON-NLS-2$
|
else if( directive.equals( POUND_WARNING) || directive.equals(POUND_IDENT))
|
||||||
return; // good enough -- the rest of the line has been consumed
|
return; // good enough -- the rest of the line has been consumed
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -220,4 +223,39 @@ public class GCCScannerExtension implements IScannerExtension {
|
||||||
Character.isUnicodeIdentifierPart( (char)c);
|
Character.isUnicodeIdentifierPart( (char)c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static final Map additionalCPPKeywords;
|
||||||
|
private static final Map additionalCKeywords;
|
||||||
|
static
|
||||||
|
{
|
||||||
|
additionalCKeywords = new HashMap();
|
||||||
|
additionalCKeywords.put( GCCKeywords.__ALIGNOF__, new Integer( IGCCToken.t___alignof__ ));
|
||||||
|
additionalCKeywords.put( GCCKeywords.TYPEOF, new Integer( IGCCToken.t_typeof ));
|
||||||
|
additionalCPPKeywords = new HashMap(additionalCKeywords);
|
||||||
|
additionalCPPKeywords.put( Keywords.RESTRICT, new Integer( IToken.t_restrict ));
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.extension.IScannerExtension#isExtensionKeyword()
|
||||||
|
*/
|
||||||
|
public boolean isExtensionKeyword(String tokenImage) {
|
||||||
|
if( language == ParserLanguage.CPP )
|
||||||
|
return ( additionalCPPKeywords.get( tokenImage ) != null );
|
||||||
|
else if( language == ParserLanguage.C )
|
||||||
|
return ( additionalCKeywords.get( tokenImage ) != null );
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.extension.IScannerExtension#createExtensionToken()
|
||||||
|
*/
|
||||||
|
public IToken createExtensionToken(String image, IScannerData scannerData) {
|
||||||
|
Integer get = null;
|
||||||
|
if( language == ParserLanguage.CPP )
|
||||||
|
get = (Integer) additionalCPPKeywords.get( image );
|
||||||
|
else if( language == ParserLanguage.C )
|
||||||
|
get = (Integer) additionalCKeywords.get( image );
|
||||||
|
if( get == null ) return null;
|
||||||
|
return TokenFactory.createToken(get.intValue(),scannerData);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -116,8 +116,6 @@ public class Scanner implements IScanner {
|
||||||
scannerData = new ScannerData( this, log, requestor, mode, filename, reader, language, new ScannerInfo( definitions, incs ), new ContextStack( this, log ), null );
|
scannerData = new ScannerData( this, log, requestor, mode, filename, reader, language, new ScannerInfo( definitions, incs ), new ContextStack( this, log ), null );
|
||||||
|
|
||||||
scannerExtension = extension;
|
scannerExtension = extension;
|
||||||
if( scannerExtension instanceof GCCScannerExtension )
|
|
||||||
((GCCScannerExtension)scannerExtension).setScannerData( scannerData );
|
|
||||||
|
|
||||||
scannerData.setDefinitions( definitions );
|
scannerData.setDefinitions( definitions );
|
||||||
scannerData.setIncludePathNames( includePaths );
|
scannerData.setIncludePathNames( includePaths );
|
||||||
|
@ -129,9 +127,6 @@ public class Scanner implements IScanner {
|
||||||
scannerData = new ScannerData( this, log, requestor, parserMode, filename, reader, language, info, new ContextStack( this, log ), workingCopies );
|
scannerData = new ScannerData( this, log, requestor, parserMode, filename, reader, language, info, new ContextStack( this, log ), workingCopies );
|
||||||
|
|
||||||
scannerExtension = extension;
|
scannerExtension = extension;
|
||||||
if( scannerExtension instanceof GCCScannerExtension )
|
|
||||||
((GCCScannerExtension)scannerExtension).setScannerData( scannerData );
|
|
||||||
|
|
||||||
scannerData.setASTFactory( ParserFactory.createASTFactory( this, scannerData.getParserMode(), language ) );
|
scannerData.setASTFactory( ParserFactory.createASTFactory( this, scannerData.getParserMode(), language ) );
|
||||||
|
|
||||||
TraceUtil.outputTrace(log, "Scanner constructed with the following configuration:"); //$NON-NLS-1$
|
TraceUtil.outputTrace(log, "Scanner constructed with the following configuration:"); //$NON-NLS-1$
|
||||||
|
@ -148,7 +143,7 @@ public class Scanner implements IScanner {
|
||||||
Object value = m.get( symbolName );
|
Object value = m.get( symbolName );
|
||||||
if( value instanceof String )
|
if( value instanceof String )
|
||||||
{
|
{
|
||||||
addDefinition( symbolName, scannerExtension.initializeMacroValue((String) value));
|
addDefinition( symbolName, scannerExtension.initializeMacroValue(scannerData, (String) value));
|
||||||
TraceUtil.outputTrace(log, "\t\tNAME = ", symbolName, " VALUE = ", value.toString() ); //$NON-NLS-1$ //$NON-NLS-2$
|
TraceUtil.outputTrace(log, "\t\tNAME = ", symbolName, " VALUE = ", value.toString() ); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
++numberOfSymbolsLogged;
|
++numberOfSymbolsLogged;
|
||||||
|
|
||||||
|
@ -182,7 +177,7 @@ public class Scanner implements IScanner {
|
||||||
*/
|
*/
|
||||||
protected void setupBuiltInMacros() {
|
protected void setupBuiltInMacros() {
|
||||||
|
|
||||||
scannerExtension.setupBuiltInMacros(scannerData.getLanguage());
|
scannerExtension.setupBuiltInMacros(scannerData, scannerData.getLanguage());
|
||||||
if( getDefinition(__STDC__) == null )
|
if( getDefinition(__STDC__) == null )
|
||||||
addDefinition( __STDC__, new ObjectMacroDescriptor( __STDC__, "1") ); //$NON-NLS-1$
|
addDefinition( __STDC__, new ObjectMacroDescriptor( __STDC__, "1") ); //$NON-NLS-1$
|
||||||
|
|
||||||
|
@ -469,8 +464,7 @@ public class Scanner implements IScanner {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected IToken newToken(int t, String i) {
|
protected IToken newToken(int t, String i) {
|
||||||
IToken theToken = TokenFactory.createToken( t, i, scannerData );
|
setCurrentToken(TokenFactory.createToken( t, i, scannerData ));
|
||||||
setCurrentToken(theToken);
|
|
||||||
return currentToken;
|
return currentToken;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1183,7 +1177,7 @@ public class Scanner implements IScanner {
|
||||||
Object directive = ppDirectives.get(token);
|
Object directive = ppDirectives.get(token);
|
||||||
if (directive == null) {
|
if (directive == null) {
|
||||||
if( scannerExtension.canHandlePreprocessorDirective( token ) )
|
if( scannerExtension.canHandlePreprocessorDirective( token ) )
|
||||||
scannerExtension.handlePreprocessorDirective( token, getRestOfPreprocessorLine() );
|
scannerExtension.handlePreprocessorDirective( scannerData, token, getRestOfPreprocessorLine() );
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if( passOnToClient )
|
if( passOnToClient )
|
||||||
|
@ -1540,9 +1534,22 @@ public class Scanner implements IScanner {
|
||||||
if (tokenTypeObject != null)
|
if (tokenTypeObject != null)
|
||||||
return newConstantToken(((Integer) tokenTypeObject).intValue());
|
return newConstantToken(((Integer) tokenTypeObject).intValue());
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
if( scannerExtension.isExtensionKeyword( ident ) )
|
||||||
|
return newExtensionToken( scannerExtension.createExtensionToken(ident, scannerData ));
|
||||||
return newToken(IToken.tIDENTIFIER, ident);
|
return newToken(IToken.tIDENTIFIER, ident);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param token
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
protected IToken newExtensionToken(IToken token) {
|
||||||
|
setCurrentToken( token );
|
||||||
|
return currentToken;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param c
|
* @param c
|
||||||
* @return
|
* @return
|
||||||
|
@ -2840,7 +2847,7 @@ public class Scanner implements IScanner {
|
||||||
scannerData.getParserMode(),
|
scannerData.getParserMode(),
|
||||||
scannerData.getLanguage(),
|
scannerData.getLanguage(),
|
||||||
NULL_LOG_SERVICE,
|
NULL_LOG_SERVICE,
|
||||||
(IScannerExtension)scannerExtension.clone() );
|
scannerExtension );
|
||||||
|
|
||||||
tokenizer.setThrowExceptionOnBadCharacterRead(false);
|
tokenizer.setThrowExceptionOnBadCharacterRead(false);
|
||||||
Vector parameterValues = new Vector();
|
Vector parameterValues = new Vector();
|
||||||
|
|
|
@ -130,7 +130,7 @@ public class ScannerUtility {
|
||||||
private static final IParserLogService NULL_LOG_SERVICE = new NullLogService();
|
private static final IParserLogService NULL_LOG_SERVICE = new NullLogService();
|
||||||
private static final InclusionParseException INCLUSION_PARSE_EXCEPTION = new InclusionParseException();
|
private static final InclusionParseException INCLUSION_PARSE_EXCEPTION = new InclusionParseException();
|
||||||
|
|
||||||
static InclusionDirective parseInclusionDirective( IScannerData scannerData, IScannerExtension scannerExtension, String includeLine, int baseOffset ) throws InclusionParseException
|
static InclusionDirective parseInclusionDirective( IScannerData scannerData, IScannerExtension extension, String includeLine, int baseOffset ) throws InclusionParseException
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -145,7 +145,7 @@ public class ScannerUtility {
|
||||||
scannerData.getDefinitions(), scannerData.getIncludePathNames(),
|
scannerData.getDefinitions(), scannerData.getIncludePathNames(),
|
||||||
NULL_REQUESTOR,
|
NULL_REQUESTOR,
|
||||||
scannerData.getParserMode(),
|
scannerData.getParserMode(),
|
||||||
scannerData.getLanguage(), NULL_LOG_SERVICE, (IScannerExtension)(scannerExtension.clone()) );
|
scannerData.getLanguage(), NULL_LOG_SERVICE, extension );
|
||||||
helperScanner.setForInclusion( true );
|
helperScanner.setForInclusion( true );
|
||||||
IToken t = null;
|
IToken t = null;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue