mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-23 17:05:26 +02:00
Fix for Bug 175493 - [Parser] Need API to reuse parser for custom C/C++ dialects
This commit is contained in:
parent
08bb9fd09f
commit
a924a2953c
50 changed files with 2628 additions and 1911 deletions
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2005 IBM Corporation and others.
|
||||
* Copyright (c) 2004, 2007 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -42,6 +42,16 @@ import org.eclipse.cdt.core.dom.ast.IType;
|
|||
import org.eclipse.cdt.core.dom.ast.c.CASTVisitor;
|
||||
import org.eclipse.cdt.core.dom.ast.c.ICASTTypeIdInitializerExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.CPPASTVisitor;
|
||||
import org.eclipse.cdt.core.dom.parser.IScannerExtensionConfiguration;
|
||||
import org.eclipse.cdt.core.dom.parser.ISourceCodeParser;
|
||||
import org.eclipse.cdt.core.dom.parser.c.ANSICParserExtensionConfiguration;
|
||||
import org.eclipse.cdt.core.dom.parser.c.GCCParserExtensionConfiguration;
|
||||
import org.eclipse.cdt.core.dom.parser.c.GCCScannerExtensionConfiguration;
|
||||
import org.eclipse.cdt.core.dom.parser.c.ICParserExtensionConfiguration;
|
||||
import org.eclipse.cdt.core.dom.parser.cpp.ANSICPPParserExtensionConfiguration;
|
||||
import org.eclipse.cdt.core.dom.parser.cpp.GPPParserExtensionConfiguration;
|
||||
import org.eclipse.cdt.core.dom.parser.cpp.GPPScannerExtensionConfiguration;
|
||||
import org.eclipse.cdt.core.dom.parser.cpp.ICPPParserExtensionConfiguration;
|
||||
import org.eclipse.cdt.core.parser.CodeReader;
|
||||
import org.eclipse.cdt.core.parser.IParserLogService;
|
||||
import org.eclipse.cdt.core.parser.IScanner;
|
||||
|
@ -52,23 +62,13 @@ import org.eclipse.cdt.core.parser.ScannerInfo;
|
|||
import org.eclipse.cdt.core.testplugin.CTestPlugin;
|
||||
import org.eclipse.cdt.core.testplugin.util.BaseTestCase;
|
||||
import org.eclipse.cdt.core.testplugin.util.TestSourceReader;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ISourceCodeParser;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.c.ANSICParserExtensionConfiguration;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.c.CVisitor;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.c.GCCParserExtensionConfiguration;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.c.GNUCSourceParser;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.c.ICParserExtensionConfiguration;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ANSICPPParserExtensionConfiguration;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPVisitor;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.GNUCPPSourceParser;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.GPPParserExtensionConfiguration;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPParserExtensionConfiguration;
|
||||
import org.eclipse.cdt.internal.core.parser.ParserException;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner2.DOMScanner;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner2.FileCodeReaderFactory;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner2.GCCScannerExtensionConfiguration;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner2.GPPScannerExtensionConfiguration;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner2.IScannerExtensionConfiguration;
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2005 IBM Corporation and others.
|
||||
* Copyright (c) 2005, 2007 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -14,6 +14,16 @@ import org.eclipse.cdt.core.dom.CDOM;
|
|||
import org.eclipse.cdt.core.dom.IASTServiceProvider.UnsupportedDialectException;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||
import org.eclipse.cdt.core.dom.parser.IScannerExtensionConfiguration;
|
||||
import org.eclipse.cdt.core.dom.parser.ISourceCodeParser;
|
||||
import org.eclipse.cdt.core.dom.parser.c.ANSICParserExtensionConfiguration;
|
||||
import org.eclipse.cdt.core.dom.parser.c.GCCParserExtensionConfiguration;
|
||||
import org.eclipse.cdt.core.dom.parser.c.GCCScannerExtensionConfiguration;
|
||||
import org.eclipse.cdt.core.dom.parser.c.ICParserExtensionConfiguration;
|
||||
import org.eclipse.cdt.core.dom.parser.cpp.ANSICPPParserExtensionConfiguration;
|
||||
import org.eclipse.cdt.core.dom.parser.cpp.GPPParserExtensionConfiguration;
|
||||
import org.eclipse.cdt.core.dom.parser.cpp.GPPScannerExtensionConfiguration;
|
||||
import org.eclipse.cdt.core.dom.parser.cpp.ICPPParserExtensionConfiguration;
|
||||
import org.eclipse.cdt.core.parser.CodeReader;
|
||||
import org.eclipse.cdt.core.parser.IParserLogService;
|
||||
import org.eclipse.cdt.core.parser.IScanner;
|
||||
|
@ -22,23 +32,13 @@ import org.eclipse.cdt.core.parser.ParserLanguage;
|
|||
import org.eclipse.cdt.core.parser.ParserMode;
|
||||
import org.eclipse.cdt.core.parser.ScannerInfo;
|
||||
import org.eclipse.cdt.core.parser.tests.FileBasePluginTest;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ISourceCodeParser;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.c.ANSICParserExtensionConfiguration;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.c.CVisitor;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.c.GCCParserExtensionConfiguration;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.c.GNUCSourceParser;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.c.ICParserExtensionConfiguration;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ANSICPPParserExtensionConfiguration;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPVisitor;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.GNUCPPSourceParser;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.GPPParserExtensionConfiguration;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPParserExtensionConfiguration;
|
||||
import org.eclipse.cdt.internal.core.parser.ParserException;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner2.DOMScanner;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner2.FileCodeReaderFactory;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner2.GCCScannerExtensionConfiguration;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner2.GPPScannerExtensionConfiguration;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner2.IScannerExtensionConfiguration;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2005 IBM Corporation and others.
|
||||
* Copyright (c) 2005, 2007 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -19,6 +19,16 @@ import org.eclipse.cdt.core.dom.ast.IBinding;
|
|||
import org.eclipse.cdt.core.dom.ast.IProblemBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.c.CASTVisitor;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.CPPASTVisitor;
|
||||
import org.eclipse.cdt.core.dom.parser.IScannerExtensionConfiguration;
|
||||
import org.eclipse.cdt.core.dom.parser.ISourceCodeParser;
|
||||
import org.eclipse.cdt.core.dom.parser.c.ANSICParserExtensionConfiguration;
|
||||
import org.eclipse.cdt.core.dom.parser.c.GCCParserExtensionConfiguration;
|
||||
import org.eclipse.cdt.core.dom.parser.c.GCCScannerExtensionConfiguration;
|
||||
import org.eclipse.cdt.core.dom.parser.c.ICParserExtensionConfiguration;
|
||||
import org.eclipse.cdt.core.dom.parser.cpp.ANSICPPParserExtensionConfiguration;
|
||||
import org.eclipse.cdt.core.dom.parser.cpp.GPPParserExtensionConfiguration;
|
||||
import org.eclipse.cdt.core.dom.parser.cpp.GPPScannerExtensionConfiguration;
|
||||
import org.eclipse.cdt.core.dom.parser.cpp.ICPPParserExtensionConfiguration;
|
||||
import org.eclipse.cdt.core.parser.CodeReader;
|
||||
import org.eclipse.cdt.core.parser.IParserLogService;
|
||||
import org.eclipse.cdt.core.parser.IScanner;
|
||||
|
@ -26,23 +36,13 @@ import org.eclipse.cdt.core.parser.NullLogService;
|
|||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||
import org.eclipse.cdt.core.parser.ParserMode;
|
||||
import org.eclipse.cdt.core.parser.ScannerInfo;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ISourceCodeParser;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.c.ANSICParserExtensionConfiguration;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.c.CVisitor;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.c.GCCParserExtensionConfiguration;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.c.GNUCSourceParser;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.c.ICParserExtensionConfiguration;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ANSICPPParserExtensionConfiguration;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPVisitor;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.GNUCPPSourceParser;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.GPPParserExtensionConfiguration;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPParserExtensionConfiguration;
|
||||
import org.eclipse.cdt.internal.core.parser.ParserException;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner2.DOMScanner;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner2.FileCodeReaderFactory;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner2.GCCScannerExtensionConfiguration;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner2.GPPScannerExtensionConfiguration;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner2.IScannerExtensionConfiguration;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
|
|
|
@ -63,6 +63,16 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPReferenceType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPUsingDeclaration;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPVariable;
|
||||
import org.eclipse.cdt.core.dom.parser.IScannerExtensionConfiguration;
|
||||
import org.eclipse.cdt.core.dom.parser.ISourceCodeParser;
|
||||
import org.eclipse.cdt.core.dom.parser.c.ANSICParserExtensionConfiguration;
|
||||
import org.eclipse.cdt.core.dom.parser.c.GCCParserExtensionConfiguration;
|
||||
import org.eclipse.cdt.core.dom.parser.c.GCCScannerExtensionConfiguration;
|
||||
import org.eclipse.cdt.core.dom.parser.c.ICParserExtensionConfiguration;
|
||||
import org.eclipse.cdt.core.dom.parser.cpp.ANSICPPParserExtensionConfiguration;
|
||||
import org.eclipse.cdt.core.dom.parser.cpp.GPPParserExtensionConfiguration;
|
||||
import org.eclipse.cdt.core.dom.parser.cpp.GPPScannerExtensionConfiguration;
|
||||
import org.eclipse.cdt.core.dom.parser.cpp.ICPPParserExtensionConfiguration;
|
||||
import org.eclipse.cdt.core.parser.CodeReader;
|
||||
import org.eclipse.cdt.core.parser.IScanner;
|
||||
import org.eclipse.cdt.core.parser.NullLogService;
|
||||
|
@ -70,23 +80,13 @@ import org.eclipse.cdt.core.parser.ParserLanguage;
|
|||
import org.eclipse.cdt.core.parser.ParserMode;
|
||||
import org.eclipse.cdt.core.parser.ScannerInfo;
|
||||
import org.eclipse.cdt.core.testplugin.util.BaseTestCase;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ISourceCodeParser;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.c.ANSICParserExtensionConfiguration;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.c.CVisitor;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.c.GCCParserExtensionConfiguration;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.c.GNUCSourceParser;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.c.ICParserExtensionConfiguration;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ANSICPPParserExtensionConfiguration;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPVisitor;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.GNUCPPSourceParser;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.GPPParserExtensionConfiguration;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPParserExtensionConfiguration;
|
||||
import org.eclipse.cdt.internal.core.parser.ParserException;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner2.DOMScanner;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner2.FileCodeReaderFactory;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner2.GCCScannerExtensionConfiguration;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner2.GPPScannerExtensionConfiguration;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner2.IScannerExtensionConfiguration;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2005 IBM Corporation and others.
|
||||
* Copyright (c) 2005, 2007 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -18,6 +18,16 @@ import junit.framework.TestCase;
|
|||
|
||||
import org.eclipse.cdt.core.dom.ast.IASTProblem;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||
import org.eclipse.cdt.core.dom.parser.IScannerExtensionConfiguration;
|
||||
import org.eclipse.cdt.core.dom.parser.ISourceCodeParser;
|
||||
import org.eclipse.cdt.core.dom.parser.c.ANSICParserExtensionConfiguration;
|
||||
import org.eclipse.cdt.core.dom.parser.c.GCCParserExtensionConfiguration;
|
||||
import org.eclipse.cdt.core.dom.parser.c.GCCScannerExtensionConfiguration;
|
||||
import org.eclipse.cdt.core.dom.parser.c.ICParserExtensionConfiguration;
|
||||
import org.eclipse.cdt.core.dom.parser.cpp.ANSICPPParserExtensionConfiguration;
|
||||
import org.eclipse.cdt.core.dom.parser.cpp.GPPParserExtensionConfiguration;
|
||||
import org.eclipse.cdt.core.dom.parser.cpp.GPPScannerExtensionConfiguration;
|
||||
import org.eclipse.cdt.core.dom.parser.cpp.ICPPParserExtensionConfiguration;
|
||||
import org.eclipse.cdt.core.parser.CodeReader;
|
||||
import org.eclipse.cdt.core.parser.IScanner;
|
||||
import org.eclipse.cdt.core.parser.IScannerInfo;
|
||||
|
@ -25,23 +35,13 @@ import org.eclipse.cdt.core.parser.NullLogService;
|
|||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||
import org.eclipse.cdt.core.parser.ParserMode;
|
||||
import org.eclipse.cdt.core.parser.ScannerInfo;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ISourceCodeParser;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.c.ANSICParserExtensionConfiguration;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.c.CVisitor;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.c.GCCParserExtensionConfiguration;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.c.GNUCSourceParser;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.c.ICParserExtensionConfiguration;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ANSICPPParserExtensionConfiguration;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPVisitor;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.GNUCPPSourceParser;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.GPPParserExtensionConfiguration;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPParserExtensionConfiguration;
|
||||
import org.eclipse.cdt.internal.core.parser.ParserException;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner2.DOMScanner;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner2.FileCodeReaderFactory;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner2.GCCScannerExtensionConfiguration;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner2.GPPScannerExtensionConfiguration;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner2.IScannerExtensionConfiguration;
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**********************************************************************
|
||||
* Copyright (c) 2004, 2005 IBM Corporation and others.
|
||||
* Copyright (c) 2004, 2007 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -17,6 +17,16 @@ import junit.framework.TestCase;
|
|||
|
||||
import org.eclipse.cdt.core.dom.ast.ASTCompletionNode;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.parser.IScannerExtensionConfiguration;
|
||||
import org.eclipse.cdt.core.dom.parser.ISourceCodeParser;
|
||||
import org.eclipse.cdt.core.dom.parser.c.ANSICParserExtensionConfiguration;
|
||||
import org.eclipse.cdt.core.dom.parser.c.GCCParserExtensionConfiguration;
|
||||
import org.eclipse.cdt.core.dom.parser.c.GCCScannerExtensionConfiguration;
|
||||
import org.eclipse.cdt.core.dom.parser.c.ICParserExtensionConfiguration;
|
||||
import org.eclipse.cdt.core.dom.parser.cpp.ANSICPPParserExtensionConfiguration;
|
||||
import org.eclipse.cdt.core.dom.parser.cpp.GPPParserExtensionConfiguration;
|
||||
import org.eclipse.cdt.core.dom.parser.cpp.GPPScannerExtensionConfiguration;
|
||||
import org.eclipse.cdt.core.dom.parser.cpp.ICPPParserExtensionConfiguration;
|
||||
import org.eclipse.cdt.core.parser.CodeReader;
|
||||
import org.eclipse.cdt.core.parser.IParserLogService;
|
||||
import org.eclipse.cdt.core.parser.IScanner;
|
||||
|
@ -24,21 +34,11 @@ import org.eclipse.cdt.core.parser.NullLogService;
|
|||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||
import org.eclipse.cdt.core.parser.ParserMode;
|
||||
import org.eclipse.cdt.core.parser.ScannerInfo;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ISourceCodeParser;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.c.ANSICParserExtensionConfiguration;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.c.GCCParserExtensionConfiguration;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.c.GNUCSourceParser;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.c.ICParserExtensionConfiguration;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ANSICPPParserExtensionConfiguration;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.GNUCPPSourceParser;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.GPPParserExtensionConfiguration;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPParserExtensionConfiguration;
|
||||
import org.eclipse.cdt.internal.core.parser.ParserException;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner2.DOMScanner;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner2.FileCodeReaderFactory;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner2.GCCScannerExtensionConfiguration;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner2.GPPScannerExtensionConfiguration;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner2.IScannerExtensionConfiguration;
|
||||
|
||||
public class CompletionTestBase extends TestCase {
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2001, 2006 IBM Corporation and others.
|
||||
* Copyright (c) 2001, 2007 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -17,6 +17,9 @@ import java.util.List;
|
|||
import junit.framework.ComparisonFailure;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.eclipse.cdt.core.dom.parser.IScannerExtensionConfiguration;
|
||||
import org.eclipse.cdt.core.dom.parser.c.GCCScannerExtensionConfiguration;
|
||||
import org.eclipse.cdt.core.dom.parser.cpp.GPPScannerExtensionConfiguration;
|
||||
import org.eclipse.cdt.core.parser.CodeReader;
|
||||
import org.eclipse.cdt.core.parser.EndOfFileException;
|
||||
import org.eclipse.cdt.core.parser.IParserLogService;
|
||||
|
@ -31,9 +34,6 @@ import org.eclipse.cdt.core.parser.ParserLanguage;
|
|||
import org.eclipse.cdt.core.parser.ParserMode;
|
||||
import org.eclipse.cdt.core.parser.ScannerInfo;
|
||||
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner2.GCCScannerExtensionConfiguration;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner2.GPPScannerExtensionConfiguration;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner2.IScannerExtensionConfiguration;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner2.ObjectStyleMacro;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner2.Scanner2;
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2005 IBM Corporation and others.
|
||||
* Copyright (c) 2005, 2007 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -17,6 +17,9 @@ import java.util.Map;
|
|||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.eclipse.cdt.core.dom.parser.IScannerExtensionConfiguration;
|
||||
import org.eclipse.cdt.core.dom.parser.c.GCCScannerExtensionConfiguration;
|
||||
import org.eclipse.cdt.core.dom.parser.cpp.GPPScannerExtensionConfiguration;
|
||||
import org.eclipse.cdt.core.parser.CodeReader;
|
||||
import org.eclipse.cdt.core.parser.IParser;
|
||||
import org.eclipse.cdt.core.parser.IParserLogService;
|
||||
|
@ -29,9 +32,6 @@ import org.eclipse.cdt.core.parser.ParserFactoryError;
|
|||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||
import org.eclipse.cdt.core.parser.ParserMode;
|
||||
import org.eclipse.cdt.core.parser.ScannerInfo;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner2.GCCScannerExtensionConfiguration;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner2.GPPScannerExtensionConfiguration;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner2.IScannerExtensionConfiguration;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner2.Scanner2;
|
||||
|
||||
// A test that just calculates the speed of the parser
|
||||
|
|
|
@ -16,6 +16,9 @@ Export-Package: org.eclipse.cdt.core,
|
|||
org.eclipse.cdt.core.dom.ast.gnu,
|
||||
org.eclipse.cdt.core.dom.ast.gnu.c,
|
||||
org.eclipse.cdt.core.dom.ast.gnu.cpp,
|
||||
org.eclipse.cdt.core.dom.parser,
|
||||
org.eclipse.cdt.core.dom.parser.c,
|
||||
org.eclipse.cdt.core.dom.parser.cpp,
|
||||
org.eclipse.cdt.core.envvar,
|
||||
org.eclipse.cdt.core.formatter,
|
||||
org.eclipse.cdt.core.index,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2005 IBM Corporation and others.
|
||||
* Copyright (c) 2005, 2007 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -7,6 +7,7 @@
|
|||
*
|
||||
* Contributors:
|
||||
* IBM - Initial API and implementation
|
||||
* Anton Leherbauer (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.core.dom.ast;
|
||||
|
||||
|
@ -15,6 +16,8 @@ package org.eclipse.cdt.core.dom.ast;
|
|||
* provided by a Built-in Symbol Provider that implements this interface.
|
||||
*
|
||||
* @author dsteffle
|
||||
*
|
||||
* @deprecated Use {@link org.eclipse.cdt.core.dom.parser.IBuiltinBindingsProvider} instead
|
||||
*/
|
||||
public interface IASTBuiltinSymbolProvider {
|
||||
|
||||
|
|
|
@ -9,50 +9,27 @@
|
|||
* QNX - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* IBM Corporation
|
||||
* Anton Leherbauer (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.core.dom.ast.gnu.c;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.dom.ICodeReaderFactory;
|
||||
import org.eclipse.cdt.core.dom.ast.ASTCompletionNode;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||
import org.eclipse.cdt.core.dom.ast.c.CASTVisitor;
|
||||
import org.eclipse.cdt.core.dom.ast.gnu.Messages;
|
||||
import org.eclipse.cdt.core.index.IIndex;
|
||||
import org.eclipse.cdt.core.model.AbstractLanguage;
|
||||
import org.eclipse.cdt.core.model.IContributedModelBuilder;
|
||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||
import org.eclipse.cdt.core.parser.CodeReader;
|
||||
import org.eclipse.cdt.core.parser.DefaultLogService;
|
||||
import org.eclipse.cdt.core.parser.IParserLogService;
|
||||
import org.eclipse.cdt.core.parser.IScanner;
|
||||
import org.eclipse.cdt.core.parser.IScannerInfo;
|
||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||
import org.eclipse.cdt.core.parser.ParserMode;
|
||||
import org.eclipse.cdt.core.parser.ParserUtil;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ISourceCodeParser;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.c.GCCParserExtensionConfiguration;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.c.GNUCSourceParser;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner2.DOMScanner;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner2.GCCScannerExtensionConfiguration;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner2.IScannerExtensionConfiguration;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.IPDOMLinkageFactory;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.c.PDOMCLinkageFactory;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.cdt.core.dom.parser.IScannerExtensionConfiguration;
|
||||
import org.eclipse.cdt.core.dom.parser.c.AbstractCLanguage;
|
||||
import org.eclipse.cdt.core.dom.parser.c.GCCParserExtensionConfiguration;
|
||||
import org.eclipse.cdt.core.dom.parser.c.GCCScannerExtensionConfiguration;
|
||||
import org.eclipse.cdt.core.dom.parser.c.ICParserExtensionConfiguration;
|
||||
|
||||
/**
|
||||
* @author Doug Schaefer
|
||||
*
|
||||
*/
|
||||
public class GCCLanguage extends AbstractLanguage {
|
||||
public class GCCLanguage extends AbstractCLanguage {
|
||||
|
||||
protected static final GCCScannerExtensionConfiguration C_GNU_SCANNER_EXTENSION = new GCCScannerExtensionConfiguration();
|
||||
protected static final GCCParserExtensionConfiguration C_GNU_PARSER_EXTENSION = new GCCParserExtensionConfiguration();
|
||||
// Must match the id in the extension
|
||||
public static final String ID = CCorePlugin.PLUGIN_ID + ".gcc"; //$NON-NLS-1$
|
||||
|
||||
|
@ -67,83 +44,21 @@ public class GCCLanguage extends AbstractLanguage {
|
|||
}
|
||||
|
||||
public String getName() {
|
||||
return new String(Messages.getString("GCCLanguage.name")); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
public Object getAdapter(Class adapter) {
|
||||
if (adapter == IPDOMLinkageFactory.class)
|
||||
return new PDOMCLinkageFactory();
|
||||
else
|
||||
return super.getAdapter(adapter);
|
||||
}
|
||||
|
||||
public IASTTranslationUnit getASTTranslationUnit(CodeReader reader,
|
||||
IScannerInfo scanInfo, ICodeReaderFactory codeReaderFactory, IIndex index, IParserLogService log) throws CoreException {
|
||||
IScannerExtensionConfiguration scannerExtensionConfiguration= C_GNU_SCANNER_EXTENSION;
|
||||
IScanner scanner = new DOMScanner(reader, scanInfo, ParserMode.COMPLETE_PARSE,
|
||||
ParserLanguage.C, new DefaultLogService(), scannerExtensionConfiguration, codeReaderFactory);
|
||||
//assume GCC
|
||||
ISourceCodeParser parser = new GNUCSourceParser( scanner, ParserMode.COMPLETE_PARSE, log,
|
||||
new GCCParserExtensionConfiguration(), index);
|
||||
|
||||
// Parse
|
||||
IASTTranslationUnit ast = parser.parse();
|
||||
return ast;
|
||||
}
|
||||
|
||||
public ASTCompletionNode getCompletionNode(CodeReader reader, IScannerInfo scanInfo, ICodeReaderFactory fileCreator, IIndex index, IParserLogService log, int offset) throws CoreException {
|
||||
IScannerExtensionConfiguration scannerExtensionConfiguration
|
||||
= C_GNU_SCANNER_EXTENSION;
|
||||
IScanner scanner = new DOMScanner(reader, scanInfo, ParserMode.COMPLETE_PARSE,
|
||||
ParserLanguage.C, new DefaultLogService(), scannerExtensionConfiguration, fileCreator );
|
||||
scanner.setContentAssistMode(offset);
|
||||
|
||||
ISourceCodeParser parser = new GNUCSourceParser(
|
||||
scanner,
|
||||
ParserMode.COMPLETION_PARSE,
|
||||
ParserUtil.getParserLogService(),
|
||||
new GCCParserExtensionConfiguration(),
|
||||
index);
|
||||
|
||||
// Run the parse and return the completion node
|
||||
parser.parse();
|
||||
ASTCompletionNode node = parser.getCompletionNode();
|
||||
if (node != null) {
|
||||
node.count = scanner.getCount();
|
||||
}
|
||||
return node;
|
||||
return Messages.getString("GCCLanguage.name"); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
private static class NameCollector extends CASTVisitor {
|
||||
{
|
||||
shouldVisitNames = true;
|
||||
}
|
||||
private List nameList = new ArrayList();
|
||||
public int visit( IASTName name ){
|
||||
nameList.add( name );
|
||||
return PROCESS_CONTINUE;
|
||||
}
|
||||
public IASTName[] getNames() {
|
||||
return (IASTName[])nameList.toArray(new IASTName[nameList.size()]);
|
||||
}
|
||||
/*
|
||||
* @see org.eclipse.cdt.core.parser.AbstractCLanguage#getParserExtensionConfiguration()
|
||||
*/
|
||||
protected ICParserExtensionConfiguration getParserExtensionConfiguration() {
|
||||
return C_GNU_PARSER_EXTENSION;
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.cdt.core.parser.AbstractCLanguage#getScannerExtensionConfiguration()
|
||||
*/
|
||||
protected IScannerExtensionConfiguration getScannerExtensionConfiguration() {
|
||||
return C_GNU_SCANNER_EXTENSION;
|
||||
}
|
||||
|
||||
public IASTName[] getSelectedNames(IASTTranslationUnit ast, int start, int length) {
|
||||
IASTNode selectedNode = ast.selectNodeForLocation(ast.getFilePath(), start, length);
|
||||
|
||||
if (selectedNode == null)
|
||||
return new IASTName[0];
|
||||
|
||||
if (selectedNode instanceof IASTName)
|
||||
return new IASTName[] { (IASTName)selectedNode };
|
||||
|
||||
NameCollector collector = new NameCollector();
|
||||
selectedNode.accept(collector);
|
||||
return collector.getNames();
|
||||
}
|
||||
|
||||
public IContributedModelBuilder createModelBuilder(ITranslationUnit tu) {
|
||||
// Use the default CDT model builder
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,50 +9,26 @@
|
|||
* QNX - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* IBM Corporation
|
||||
* Anton Leherbauer (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.core.dom.ast.gnu.cpp;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.dom.ICodeReaderFactory;
|
||||
import org.eclipse.cdt.core.dom.ast.ASTCompletionNode;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.CPPASTVisitor;
|
||||
import org.eclipse.cdt.core.dom.ast.gnu.Messages;
|
||||
import org.eclipse.cdt.core.index.IIndex;
|
||||
import org.eclipse.cdt.core.model.AbstractLanguage;
|
||||
import org.eclipse.cdt.core.model.IContributedModelBuilder;
|
||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||
import org.eclipse.cdt.core.parser.CodeReader;
|
||||
import org.eclipse.cdt.core.parser.DefaultLogService;
|
||||
import org.eclipse.cdt.core.parser.IParserLogService;
|
||||
import org.eclipse.cdt.core.parser.IScanner;
|
||||
import org.eclipse.cdt.core.parser.IScannerInfo;
|
||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||
import org.eclipse.cdt.core.parser.ParserMode;
|
||||
import org.eclipse.cdt.core.parser.ParserUtil;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ISourceCodeParser;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.GNUCPPSourceParser;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.GPPParserExtensionConfiguration;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner2.DOMScanner;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner2.GPPScannerExtensionConfiguration;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner2.IScannerExtensionConfiguration;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.IPDOMLinkageFactory;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.cpp.PDOMCPPLinkageFactory;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.cdt.core.dom.parser.IScannerExtensionConfiguration;
|
||||
import org.eclipse.cdt.core.dom.parser.cpp.AbstractCPPLanguage;
|
||||
import org.eclipse.cdt.core.dom.parser.cpp.AbstractCPPParserExtensionConfiguration;
|
||||
import org.eclipse.cdt.core.dom.parser.cpp.GPPParserExtensionConfiguration;
|
||||
import org.eclipse.cdt.core.dom.parser.cpp.GPPScannerExtensionConfiguration;
|
||||
|
||||
/**
|
||||
* @author Doug Schaefer
|
||||
*
|
||||
*/
|
||||
public class GPPLanguage extends AbstractLanguage {
|
||||
public class GPPLanguage extends AbstractCPPLanguage {
|
||||
|
||||
protected static final GPPScannerExtensionConfiguration CPP_GNU_SCANNER_EXTENSION = new GPPScannerExtensionConfiguration();
|
||||
protected static final GPPParserExtensionConfiguration CPP_GNU_PARSER_EXTENSION = new GPPParserExtensionConfiguration();
|
||||
public static final String ID = CCorePlugin.PLUGIN_ID + ".g++"; //$NON-NLS-1$
|
||||
|
||||
private static final GPPLanguage myDefault = new GPPLanguage();
|
||||
|
@ -66,84 +42,21 @@ public class GPPLanguage extends AbstractLanguage {
|
|||
}
|
||||
|
||||
public String getName() {
|
||||
return new String(Messages.getString("GPPLanguage.name")); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
public Object getAdapter(Class adapter) {
|
||||
if (adapter == IPDOMLinkageFactory.class)
|
||||
return new PDOMCPPLinkageFactory();
|
||||
else
|
||||
return super.getAdapter(adapter);
|
||||
}
|
||||
|
||||
|
||||
public IASTTranslationUnit getASTTranslationUnit(CodeReader reader, IScannerInfo scanInfo,
|
||||
ICodeReaderFactory codeReaderFactory, IIndex index, IParserLogService log) throws CoreException {
|
||||
IScannerExtensionConfiguration scannerExtensionConfiguration= CPP_GNU_SCANNER_EXTENSION;
|
||||
IScanner scanner = new DOMScanner(reader, scanInfo, ParserMode.COMPLETE_PARSE,
|
||||
ParserLanguage.CPP, new DefaultLogService(), scannerExtensionConfiguration, codeReaderFactory);
|
||||
//assume GCC
|
||||
ISourceCodeParser parser = new GNUCPPSourceParser( scanner, ParserMode.COMPLETE_PARSE, log,
|
||||
new GPPParserExtensionConfiguration(), index );
|
||||
|
||||
// Parse
|
||||
IASTTranslationUnit ast= parser.parse();
|
||||
return ast;
|
||||
return Messages.getString("GPPLanguage.name"); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
public ASTCompletionNode getCompletionNode(CodeReader reader, IScannerInfo scanInfo, ICodeReaderFactory fileCreator, IIndex index, IParserLogService log, int offset) throws CoreException {
|
||||
IScannerExtensionConfiguration scannerExtensionConfiguration
|
||||
= CPP_GNU_SCANNER_EXTENSION;
|
||||
IScanner scanner = new DOMScanner(reader, scanInfo, ParserMode.COMPLETE_PARSE,
|
||||
ParserLanguage.CPP, new DefaultLogService(), scannerExtensionConfiguration, fileCreator );
|
||||
scanner.setContentAssistMode(offset);
|
||||
|
||||
ISourceCodeParser parser = new GNUCPPSourceParser(
|
||||
scanner,
|
||||
ParserMode.COMPLETION_PARSE,
|
||||
ParserUtil.getParserLogService(),
|
||||
new GPPParserExtensionConfiguration(),
|
||||
index);
|
||||
|
||||
// Run the parse and return the completion node
|
||||
parser.parse();
|
||||
ASTCompletionNode node = parser.getCompletionNode();
|
||||
if (node != null) {
|
||||
node.count = scanner.getCount();
|
||||
}
|
||||
return node;
|
||||
/*
|
||||
* @see org.eclipse.cdt.core.dom.ast.gnu.cpp.AbstractCPPLanguage#getScannerExtensionConfiguration()
|
||||
*/
|
||||
protected IScannerExtensionConfiguration getScannerExtensionConfiguration() {
|
||||
return CPP_GNU_SCANNER_EXTENSION;
|
||||
}
|
||||
|
||||
private static class NameCollector extends CPPASTVisitor {
|
||||
{
|
||||
shouldVisitNames = true;
|
||||
}
|
||||
private List nameList = new ArrayList();
|
||||
public int visit( IASTName name ){
|
||||
nameList.add( name );
|
||||
return PROCESS_CONTINUE;
|
||||
}
|
||||
public IASTName[] getNames() {
|
||||
return (IASTName[])nameList.toArray(new IASTName[nameList.size()]);
|
||||
}
|
||||
}
|
||||
|
||||
public IASTName[] getSelectedNames(IASTTranslationUnit ast, int start, int length) {
|
||||
IASTNode selectedNode = ast.selectNodeForLocation(ast.getFilePath(), start, length);
|
||||
|
||||
if (selectedNode == null)
|
||||
return new IASTName[0];
|
||||
|
||||
if (selectedNode instanceof IASTName)
|
||||
return new IASTName[] { (IASTName)selectedNode };
|
||||
|
||||
NameCollector collector = new NameCollector();
|
||||
selectedNode.accept(collector);
|
||||
return collector.getNames();
|
||||
}
|
||||
|
||||
public IContributedModelBuilder createModelBuilder(ITranslationUnit tu) {
|
||||
// Use the default CDT model builder
|
||||
return null;
|
||||
|
||||
/*
|
||||
* @see org.eclipse.cdt.core.dom.ast.gnu.cpp.AbstractCPPLanguage#getParserExtensionConfiguration()
|
||||
*/
|
||||
protected AbstractCPPParserExtensionConfiguration getParserExtensionConfiguration() {
|
||||
return CPP_GNU_PARSER_EXTENSION;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,110 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007 Wind River Systems, Inc. and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Anton Leherbauer (Wind River Systems) - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.core.dom.parser;
|
||||
|
||||
import org.eclipse.cdt.core.parser.util.CharArrayIntMap;
|
||||
import org.eclipse.cdt.core.parser.util.CharArrayObjectMap;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner2.FunctionStyleMacro;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner2.ObjectStyleMacro;
|
||||
|
||||
/**
|
||||
* Abstract scanner extension configuration to help model C/C++ dialects.
|
||||
*
|
||||
* <p>
|
||||
* <strong>EXPERIMENTAL</strong>. This class or interface has been added as
|
||||
* part of a work in progress. There is no guarantee that this API will work or
|
||||
* that it will remain the same. Please do not use this API without consulting
|
||||
* with the CDT team.
|
||||
* </p>
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
public abstract class AbstractScannerExtensionConfiguration implements IScannerExtensionConfiguration {
|
||||
|
||||
/*
|
||||
* @see org.eclipse.cdt.internal.core.parser.scanner2.IScannerExtensionConfiguration#getAdditionalKeywords()
|
||||
*/
|
||||
public CharArrayIntMap getAdditionalKeywords() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.cdt.internal.core.parser.scanner2.IScannerExtensionConfiguration#getAdditionalMacros()
|
||||
*/
|
||||
public CharArrayObjectMap getAdditionalMacros() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.cdt.internal.core.parser.scanner2.IScannerExtensionConfiguration#getAdditionalPreprocessorKeywords()
|
||||
*/
|
||||
public CharArrayIntMap getAdditionalPreprocessorKeywords() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.cdt.internal.core.parser.scanner2.IScannerExtensionConfiguration#initializeMacroValuesTo1()
|
||||
*/
|
||||
public boolean initializeMacroValuesTo1() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.cdt.internal.core.parser.scanner2.IScannerExtensionConfiguration#support$InIdentifiers()
|
||||
*/
|
||||
public boolean support$InIdentifiers() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.cdt.internal.core.parser.scanner2.IScannerExtensionConfiguration#supportAdditionalNumericLiteralSuffixes()
|
||||
*/
|
||||
public char[] supportAdditionalNumericLiteralSuffixes() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.cdt.internal.core.parser.scanner2.IScannerExtensionConfiguration#supportMinAndMaxOperators()
|
||||
*/
|
||||
public boolean supportMinAndMaxOperators() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to add an object style macro to the given map.
|
||||
*
|
||||
* @param macros the macro map
|
||||
* @param name the macro name
|
||||
* @param value the macro value
|
||||
*/
|
||||
protected void addObjectStyleMacro(CharArrayObjectMap macros, String name, String value) {
|
||||
char[] nameChars= name.toCharArray();
|
||||
macros.put(nameChars, new ObjectStyleMacro(nameChars, value.toCharArray()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to add a function style macro to the given map.
|
||||
*
|
||||
* @param macros the macro map
|
||||
* @param name the macro name
|
||||
* @param value the macro value
|
||||
* @param arguments the macro arguments
|
||||
*/
|
||||
protected void addFunctionStyleMacro(CharArrayObjectMap macros, String name, String value, String[] arguments) {
|
||||
char[] nameChars= name.toCharArray();
|
||||
char[][] argumentsArray= new char[arguments.length][];
|
||||
for (int i = 0; i < arguments.length; i++) {
|
||||
argumentsArray[i]= arguments[i].toCharArray();
|
||||
}
|
||||
macros.put(nameChars, new FunctionStyleMacro(nameChars, value.toCharArray(), argumentsArray));
|
||||
}
|
||||
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2005 IBM Corporation and others.
|
||||
* Copyright (c) 2004, 2007 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -7,15 +7,21 @@
|
|||
*
|
||||
* Contributors:
|
||||
* IBM - Initial API and implementation
|
||||
* Anton Leherbauer (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.parser.scanner2;
|
||||
package org.eclipse.cdt.core.dom.parser;
|
||||
|
||||
import org.eclipse.cdt.core.parser.IPreprocessorDirective;
|
||||
import org.eclipse.cdt.core.parser.Keywords;
|
||||
import org.eclipse.cdt.core.parser.util.CharArrayIntMap;
|
||||
import org.eclipse.cdt.core.parser.util.CharArrayObjectMap;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner2.FunctionStyleMacro;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner2.ObjectStyleMacro;
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
*/
|
||||
public abstract class GNUScannerExtensionConfiguration implements IScannerExtensionConfiguration {
|
||||
public abstract class GNUScannerExtensionConfiguration extends AbstractScannerExtensionConfiguration {
|
||||
|
||||
protected static final char[] emptyCharArray = "".toCharArray(); //$NON-NLS-1$
|
||||
|
||||
|
@ -105,4 +111,18 @@ public abstract class GNUScannerExtensionConfiguration implements IScannerExtens
|
|||
return realDefinitions;
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.cdt.internal.core.parser.scanner2.IScannerExtensionConfiguration#getAdditionalPreprocessorKeywords()
|
||||
*/
|
||||
public CharArrayIntMap getAdditionalPreprocessorKeywords() {
|
||||
CharArrayIntMap additionalPPKeywords= new CharArrayIntMap(8, IPreprocessorDirective.ppInvalid);
|
||||
additionalPPKeywords.put(Keywords.cINCLUDE_NEXT, IPreprocessorDirective.ppInclude_next);
|
||||
additionalPPKeywords.put(Keywords.cIMPORT, IPreprocessorDirective.ppImport);
|
||||
additionalPPKeywords.put(Keywords.cWARNING, IPreprocessorDirective.ppWarning);
|
||||
additionalPPKeywords.put(Keywords.cIDENT, IPreprocessorDirective.ppIgnore);
|
||||
additionalPPKeywords.put(Keywords.cSCCS, IPreprocessorDirective.ppIgnore);
|
||||
additionalPPKeywords.put(Keywords.cASSERT, IPreprocessorDirective.ppIgnore);
|
||||
additionalPPKeywords.put(Keywords.cUNASSERT, IPreprocessorDirective.ppIgnore);
|
||||
return additionalPPKeywords;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007 Wind River Systems, Inc. and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Anton Leherbauer (Wind River Systems) - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.core.dom.parser;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||
|
||||
/**
|
||||
* Provides built-in symbols to the parser.
|
||||
*
|
||||
* <p>
|
||||
* <strong>EXPERIMENTAL</strong>. This class or interface has been added as
|
||||
* part of a work in progress. There is no guarantee that this API will work or
|
||||
* that it will remain the same. Please do not use this API without consulting
|
||||
* with the CDT team.
|
||||
* </p>
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
public interface IBuiltinBindingsProvider {
|
||||
|
||||
/**
|
||||
* Get additional built-in bindings for the given scope.
|
||||
*
|
||||
* @param scope the scope the bindings are added to
|
||||
* @return an array of {@link IBinding}s, may not return <code>null</code>
|
||||
*/
|
||||
public IBinding[] getBuiltinBindings(IScope scope);
|
||||
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007 Wind River Systems, Inc. and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Anton Leherbauer (Wind River Systems) - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.core.dom.parser;
|
||||
|
||||
import org.eclipse.cdt.core.parser.IToken;
|
||||
|
||||
/**
|
||||
* Token types for parser extensions.
|
||||
* <p>
|
||||
* This interface is not intended to be implemented.
|
||||
* </p>
|
||||
* <p>
|
||||
* <strong>EXPERIMENTAL</strong>. This class or interface has been added as
|
||||
* part of a work in progress. There is no guarantee that this API will work or
|
||||
* that it will remain the same. Please do not use this API without consulting
|
||||
* with the CDT team.
|
||||
* </p>
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
public interface IExtensionToken {
|
||||
|
||||
int t__otherDeclSpecModifierFirst= IToken.tLAST + 100;
|
||||
int t__otherDeclSpecModifierLast= IToken.tLAST + 110;
|
||||
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2005 IBM Corporation and others.
|
||||
* Copyright (c) 2004, 2007 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -7,8 +7,9 @@
|
|||
*
|
||||
* Contributors:
|
||||
* IBM - Initial API and implementation
|
||||
* Anton Leherbauer (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.parser.scanner2;
|
||||
package org.eclipse.cdt.core.dom.parser;
|
||||
|
||||
import org.eclipse.cdt.core.parser.util.CharArrayIntMap;
|
||||
import org.eclipse.cdt.core.parser.util.CharArrayObjectMap;
|
||||
|
@ -26,4 +27,12 @@ public interface IScannerExtensionConfiguration {
|
|||
|
||||
public char [] supportAdditionalNumericLiteralSuffixes();
|
||||
public CharArrayObjectMap getAdditionalMacros();
|
||||
|
||||
/**
|
||||
* @return a mapping of preprocessor directive keyword to one of the constants defined in
|
||||
* {@link org.eclipse.cdt.core.parser.IPreprocessorDirective IPreprocessorDirective}.
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
public CharArrayIntMap getAdditionalPreprocessorKeywords();
|
||||
}
|
|
@ -0,0 +1,59 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2005, 2007 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM Rational Software - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.core.dom.parser;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.ASTCompletionNode;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||
|
||||
/**
|
||||
* Interface for an AST source code parser.
|
||||
* <p>
|
||||
* This interface is not intended to be implemented directly.
|
||||
* </p>
|
||||
* <p>
|
||||
* <strong>EXPERIMENTAL</strong>. This class or interface has been added as
|
||||
* part of a work in progress. There is no guarantee that this API will work or
|
||||
* that it will remain the same. Please do not use this API without consulting
|
||||
* with the CDT team.
|
||||
* </p>
|
||||
*
|
||||
* @author jcamelon
|
||||
*/
|
||||
public interface ISourceCodeParser {
|
||||
|
||||
/**
|
||||
* Compute an abstract syntax tree (AST).
|
||||
* @return the AST, should not return <code>null</code>
|
||||
*
|
||||
* @throws ParseError if parsing has been cancelled or for other reasons
|
||||
*/
|
||||
public IASTTranslationUnit parse();
|
||||
|
||||
/**
|
||||
* Cancel the parsing.
|
||||
*/
|
||||
public void cancel();
|
||||
|
||||
/**
|
||||
* Check whether there were errors.
|
||||
* @return <code>true</code> if there were errors
|
||||
*/
|
||||
public boolean encounteredError();
|
||||
|
||||
/**
|
||||
* Compute an {@link ASTCompletionNode} for code completion.
|
||||
* @return a completion node or <code>null</code> if none could be computed
|
||||
*
|
||||
* @throws ParseError if parsing has been cancelled or for other reasons
|
||||
*/
|
||||
public ASTCompletionNode getCompletionNode();
|
||||
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2005 IBM Corporation and others.
|
||||
* Copyright (c) 2002, 2007 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -7,23 +7,15 @@
|
|||
*
|
||||
* Contributors:
|
||||
* IBM Rational Software - Initial API and implementation
|
||||
* Ed Swartz (Nokia)
|
||||
* Anton Leherbauer (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser;
|
||||
package org.eclipse.cdt.core.dom.parser.c;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.ASTCompletionNode;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
*/
|
||||
public interface ISourceCodeParser {
|
||||
|
||||
public void cancel();
|
||||
|
||||
public IASTTranslationUnit parse();
|
||||
|
||||
public boolean encounteredError();
|
||||
|
||||
public ASTCompletionNode getCompletionNode();
|
||||
|
||||
public class ANSICParserExtensionConfiguration extends AbstractCParserExtensionConfiguration {
|
||||
|
||||
}
|
|
@ -0,0 +1,172 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007 Wind River Systems, Inc. and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Anton Leherbauer (Wind River Systems) - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.core.dom.parser.c;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ICodeReaderFactory;
|
||||
import org.eclipse.cdt.core.dom.ast.ASTCompletionNode;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||
import org.eclipse.cdt.core.dom.ast.c.CASTVisitor;
|
||||
import org.eclipse.cdt.core.dom.parser.AbstractScannerExtensionConfiguration;
|
||||
import org.eclipse.cdt.core.dom.parser.IScannerExtensionConfiguration;
|
||||
import org.eclipse.cdt.core.dom.parser.ISourceCodeParser;
|
||||
import org.eclipse.cdt.core.index.IIndex;
|
||||
import org.eclipse.cdt.core.model.AbstractLanguage;
|
||||
import org.eclipse.cdt.core.model.IContributedModelBuilder;
|
||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||
import org.eclipse.cdt.core.parser.CodeReader;
|
||||
import org.eclipse.cdt.core.parser.IParserLogService;
|
||||
import org.eclipse.cdt.core.parser.IScanner;
|
||||
import org.eclipse.cdt.core.parser.IScannerInfo;
|
||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||
import org.eclipse.cdt.core.parser.ParserMode;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.c.GNUCSourceParser;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner2.DOMScanner;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.IPDOMLinkageFactory;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.c.PDOMCLinkageFactory;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
/**
|
||||
* Abstract C language. Derived classes need only implement
|
||||
* {@link getScannerExtensionConfiguration()} and
|
||||
* {@link getParserExtensionConfiguration()}.
|
||||
*
|
||||
* <p>
|
||||
* <strong>EXPERIMENTAL</strong>. This class or interface has been added as
|
||||
* part of a work in progress. There is no guarantee that this API will work or
|
||||
* that it will remain the same. Please do not use this API without consulting
|
||||
* with the CDT team.
|
||||
* </p>
|
||||
*
|
||||
* @see AbstractScannerExtensionConfiguration
|
||||
* @see AbstractCParserExtensionConfiguration
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
public abstract class AbstractCLanguage extends AbstractLanguage {
|
||||
|
||||
protected static class NameCollector extends CASTVisitor {
|
||||
{
|
||||
shouldVisitNames= true;
|
||||
}
|
||||
|
||||
private List nameList= new ArrayList();
|
||||
|
||||
public int visit(IASTName name) {
|
||||
nameList.add(name);
|
||||
return PROCESS_CONTINUE;
|
||||
}
|
||||
|
||||
public IASTName[] getNames() {
|
||||
return (IASTName[]) nameList.toArray(new IASTName[nameList.size()]);
|
||||
}
|
||||
}
|
||||
|
||||
public Object getAdapter(Class adapter) {
|
||||
if (adapter == IPDOMLinkageFactory.class)
|
||||
return new PDOMCLinkageFactory();
|
||||
else
|
||||
return super.getAdapter(adapter);
|
||||
}
|
||||
|
||||
public IASTTranslationUnit getASTTranslationUnit(CodeReader reader, IScannerInfo scanInfo,
|
||||
ICodeReaderFactory codeReaderFactory, IIndex index, IParserLogService log) throws CoreException {
|
||||
|
||||
IScanner scanner= createScanner(reader, scanInfo, codeReaderFactory, log);
|
||||
ISourceCodeParser parser= createParser(scanner, log, index, false);
|
||||
|
||||
// Parse
|
||||
IASTTranslationUnit ast= parser.parse();
|
||||
return ast;
|
||||
}
|
||||
|
||||
public ASTCompletionNode getCompletionNode(CodeReader reader, IScannerInfo scanInfo,
|
||||
ICodeReaderFactory fileCreator, IIndex index, IParserLogService log, int offset) throws CoreException {
|
||||
|
||||
IScanner scanner= createScanner(reader, scanInfo, fileCreator, log);
|
||||
scanner.setContentAssistMode(offset);
|
||||
|
||||
ISourceCodeParser parser= createParser(scanner, log, index, true);
|
||||
|
||||
// Run the parse and return the completion node
|
||||
parser.parse();
|
||||
ASTCompletionNode node= parser.getCompletionNode();
|
||||
if (node != null) {
|
||||
node.count= scanner.getCount();
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
||||
|
||||
public IASTName[] getSelectedNames(IASTTranslationUnit ast, int start, int length) {
|
||||
IASTNode selectedNode= ast.selectNodeForLocation(ast.getFilePath(), start, length);
|
||||
|
||||
if (selectedNode == null)
|
||||
return new IASTName[0];
|
||||
|
||||
if (selectedNode instanceof IASTName)
|
||||
return new IASTName[] { (IASTName) selectedNode };
|
||||
|
||||
NameCollector collector= new NameCollector();
|
||||
selectedNode.accept(collector);
|
||||
return collector.getNames();
|
||||
}
|
||||
|
||||
public IContributedModelBuilder createModelBuilder(ITranslationUnit tu) {
|
||||
// Use the default CDT model builder
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the scanner to be used with the parser.
|
||||
*
|
||||
* @param reader the code reader for the main file
|
||||
* @param scanInfo the scanner information (macros, include pathes)
|
||||
* @param fileCreator the code reader factory for inclusions
|
||||
* @param log the log for debugging
|
||||
* @return an instance of IScanner
|
||||
*/
|
||||
protected IScanner createScanner(CodeReader reader, IScannerInfo scanInfo, ICodeReaderFactory fileCreator, IParserLogService log) {
|
||||
return new DOMScanner(reader, scanInfo, ParserMode.COMPLETE_PARSE, ParserLanguage.C,
|
||||
log, getScannerExtensionConfiguration(), fileCreator);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the parser.
|
||||
*
|
||||
* @param scanner the IScanner to get tokens from
|
||||
* @param log the parser log service
|
||||
* @param index the index to help resolve bindings
|
||||
* @param forCompletion whether the parser is used for code completion
|
||||
* @return an instance of ISourceCodeParser
|
||||
*/
|
||||
protected ISourceCodeParser createParser(IScanner scanner, IParserLogService log, IIndex index, boolean forCompletion) {
|
||||
ParserMode mode= forCompletion ? ParserMode.COMPLETION_PARSE : ParserMode.COMPLETE_PARSE;
|
||||
return new GNUCSourceParser(scanner, mode, log, getParserExtensionConfiguration(), index);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the scanner extension configuration for this language, may not
|
||||
* return <code>null</code>
|
||||
*/
|
||||
protected abstract IScannerExtensionConfiguration getScannerExtensionConfiguration();
|
||||
|
||||
/**
|
||||
* @return the parser extension configuration for this language, may not
|
||||
* return <code>null</code>
|
||||
*/
|
||||
protected abstract ICParserExtensionConfiguration getParserExtensionConfiguration();
|
||||
|
||||
}
|
|
@ -0,0 +1,98 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007 Wind River Systems, Inc. and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Anton Leherbauer (Wind River Systems) - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.core.dom.parser.c;
|
||||
|
||||
import org.eclipse.cdt.core.dom.parser.IBuiltinBindingsProvider;
|
||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.GCCBuiltinSymbolProvider;
|
||||
|
||||
|
||||
/**
|
||||
* Abstract C parser extension configuration to help model C dialects.
|
||||
*
|
||||
* <p>
|
||||
* <strong>EXPERIMENTAL</strong>. This class or interface has been added as
|
||||
* part of a work in progress. There is no guarantee that this API will work or
|
||||
* that it will remain the same. Please do not use this API without consulting
|
||||
* with the CDT team.
|
||||
* </p>
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
public abstract class AbstractCParserExtensionConfiguration implements ICParserExtensionConfiguration {
|
||||
|
||||
/*
|
||||
* @see org.eclipse.cdt.core.dom.parser.c.ICParserExtensionConfiguration#supportAlignOfUnaryExpression()
|
||||
*/
|
||||
public boolean supportAlignOfUnaryExpression() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.cdt.core.dom.parser.c.ICParserExtensionConfiguration#supportAttributeSpecifiers()
|
||||
*/
|
||||
public boolean supportAttributeSpecifiers() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.cdt.core.dom.parser.c.ICParserExtensionConfiguration#supportDeclspecSpecifiers()
|
||||
*/
|
||||
public boolean supportDeclspecSpecifiers() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.cdt.core.dom.parser.c.ICParserExtensionConfiguration#supportGCCOtherBuiltinSymbols()
|
||||
*/
|
||||
public boolean supportGCCOtherBuiltinSymbols() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.cdt.core.dom.parser.c.ICParserExtensionConfiguration#supportGCCStyleDesignators()
|
||||
*/
|
||||
public boolean supportGCCStyleDesignators() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.cdt.core.dom.parser.c.ICParserExtensionConfiguration#supportKnRC()
|
||||
*/
|
||||
public boolean supportKnRC() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.cdt.core.dom.parser.c.ICParserExtensionConfiguration#supportStatementsInExpressions()
|
||||
*/
|
||||
public boolean supportStatementsInExpressions() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.cdt.core.dom.parser.c.ICParserExtensionConfiguration#supportTypeofUnaryExpressions()
|
||||
*/
|
||||
public boolean supportTypeofUnaryExpressions() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.cdt.core.dom.parser.c.ICParserExtensionConfiguration#getBuiltinSymbolProvider()
|
||||
*/
|
||||
public IBuiltinBindingsProvider getBuiltinBindingsProvider() {
|
||||
if (supportGCCOtherBuiltinSymbols()) {
|
||||
return new GCCBuiltinSymbolProvider(ParserLanguage.C);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,82 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM Rational Software - Initial API and implementation
|
||||
* Ed Swartz (Nokia)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.core.dom.parser.c;
|
||||
|
||||
import org.eclipse.cdt.core.dom.parser.IBuiltinBindingsProvider;
|
||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.GCCBuiltinSymbolProvider;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
*/
|
||||
public class GCCParserExtensionConfiguration extends AbstractCParserExtensionConfiguration {
|
||||
|
||||
/*
|
||||
* @see org.eclipse.cdt.core.dom.parser.c.AbstractCParserExtensionConfiguration#supportStatementsInExpressions()
|
||||
*/
|
||||
public boolean supportStatementsInExpressions() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.cdt.core.dom.parser.c.AbstractCParserExtensionConfiguration#supportGCCStyleDesignators()
|
||||
*/
|
||||
public boolean supportGCCStyleDesignators() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.cdt.core.dom.parser.c.AbstractCParserExtensionConfiguration#supportTypeofUnaryExpressions()
|
||||
*/
|
||||
public boolean supportTypeofUnaryExpressions() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.cdt.core.dom.parser.c.AbstractCParserExtensionConfiguration#supportAlignOfUnaryExpression()
|
||||
*/
|
||||
public boolean supportAlignOfUnaryExpression() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.cdt.core.dom.parser.c.AbstractCParserExtensionConfiguration#supportKnRC()
|
||||
*/
|
||||
public boolean supportKnRC() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.cdt.core.dom.parser.c.AbstractCParserExtensionConfiguration#supportAttributeSpecifiers()
|
||||
*/
|
||||
public boolean supportAttributeSpecifiers() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.cdt.core.dom.parser.c.AbstractCParserExtensionConfiguration#supportDeclspecSpecifiers()
|
||||
*/
|
||||
public boolean supportDeclspecSpecifiers() {
|
||||
// XXX Yes, this is a hack -- should use the target platform
|
||||
if (Platform.getOS().equals(Platform.OS_WIN32))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.cdt.core.dom.parser.c.AbstractCParserExtensionConfiguration#getBuiltinSymbolProvider()
|
||||
*/
|
||||
public IBuiltinBindingsProvider getBuiltinBindingsProvider() {
|
||||
return new GCCBuiltinSymbolProvider(ParserLanguage.C);
|
||||
}
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2005 IBM Corporation and others.
|
||||
* Copyright (c) 2004, 2007 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -9,18 +9,21 @@
|
|||
* IBM - Initial API and implementation
|
||||
* Ed Swartz (Nokia)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.parser.scanner2;
|
||||
package org.eclipse.cdt.core.dom.parser.c;
|
||||
|
||||
import org.eclipse.cdt.core.dom.parser.GNUScannerExtensionConfiguration;
|
||||
import org.eclipse.cdt.core.parser.GCCKeywords;
|
||||
import org.eclipse.cdt.core.parser.IGCCToken;
|
||||
import org.eclipse.cdt.core.parser.util.CharArrayIntMap;
|
||||
import org.eclipse.cdt.core.parser.util.CharArrayObjectMap;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner2.BaseScanner.ExpressionEvaluator;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner2.DynamicFunctionStyleMacro;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner2.ExpressionEvaluator;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner2.FunctionStyleMacro;
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
*/
|
||||
public class GCCScannerExtensionConfiguration extends GNUScannerExtensionConfiguration implements IScannerExtensionConfiguration {
|
||||
public class GCCScannerExtensionConfiguration extends GNUScannerExtensionConfiguration {
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.scanner2.IScannerConfiguration#supportMinAndMaxOperators()
|
|
@ -0,0 +1,99 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2002, 2007 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM Rational Software - Initial API and implementation
|
||||
* Ed Swartz (Nokia)
|
||||
* Anton Leherbauer (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.core.dom.parser.c;
|
||||
|
||||
import org.eclipse.cdt.core.dom.parser.IBuiltinBindingsProvider;
|
||||
|
||||
|
||||
/**
|
||||
* C parser extension configuration interface.
|
||||
*
|
||||
* <p>
|
||||
* This interface is not intended to be implemented directly.
|
||||
* Clients should subclass {@link AbstractCParserExtensionConfiguration} instead.
|
||||
* </p>
|
||||
* <p>
|
||||
* <strong>EXPERIMENTAL</strong>. This class or interface has been added as
|
||||
* part of a work in progress. There is no guarantee that this API will work or
|
||||
* that it will remain the same. Please do not use this API without consulting
|
||||
* with the CDT team.
|
||||
* </p>
|
||||
*
|
||||
* @see http://gcc.gnu.org/onlinedocs/gcc/C-Extensions.html
|
||||
*
|
||||
* @author jcamelon
|
||||
* @since 4.0
|
||||
*/
|
||||
public interface ICParserExtensionConfiguration {
|
||||
|
||||
/**
|
||||
* Support for GNU extension "Statements and Declarations in Expressions".
|
||||
* @see http://gcc.gnu.org/onlinedocs/gcc/Statement-Exprs.html
|
||||
* @return <code>true</code> if support for the extension should be enabled
|
||||
*/
|
||||
public boolean supportStatementsInExpressions();
|
||||
|
||||
/**
|
||||
* Support for GNU extension "Designated Initializers".
|
||||
* @see http://gcc.gnu.org/onlinedocs/gcc/Designated-Inits.html
|
||||
* @return <code>true</code> if support for the extension should be enabled
|
||||
*/
|
||||
public boolean supportGCCStyleDesignators();
|
||||
|
||||
/**
|
||||
* Support for GNU extension "Referring to a Type with typeof".
|
||||
* @see http://gcc.gnu.org/onlinedocs/gcc/Typeof.html
|
||||
* @return <code>true</code> if support for the extension should be enabled
|
||||
*/
|
||||
public boolean supportTypeofUnaryExpressions();
|
||||
|
||||
/**
|
||||
* Support for GNU extension "Inquiring on Alignment of Types or Variables".
|
||||
* @see http://gcc.gnu.org/onlinedocs/gcc/Alignment.html
|
||||
* @return <code>true</code> if support for the extension should be enabled
|
||||
*/
|
||||
public boolean supportAlignOfUnaryExpression();
|
||||
|
||||
/**
|
||||
* Support for Kernighan and Richie (K&R) C.
|
||||
* @return <code>true</code> if support for K&R C should be enabled
|
||||
*/
|
||||
public boolean supportKnRC();
|
||||
|
||||
/**
|
||||
* See http://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html
|
||||
* for more information on GCC's Other Built-in Symbols.
|
||||
* @return <code>true</code> if support for the extension should be enabled
|
||||
* @deprecated use {@link #getBuiltinBindingsProvider()} instead.
|
||||
*/
|
||||
public boolean supportGCCOtherBuiltinSymbols();
|
||||
|
||||
/**
|
||||
* See http://gcc.gnu.org/onlinedocs/gcc/Attribute-Syntax.html
|
||||
* for more information on GCC's Attribute Specifiers.
|
||||
* @return <code>true</code> if support for the extension should be enabled
|
||||
*/
|
||||
public boolean supportAttributeSpecifiers();
|
||||
|
||||
/**
|
||||
* Win32 compiler extensions also supported by GCC on Win32
|
||||
* @return <code>true</code> if support for the extension should be enabled
|
||||
*/
|
||||
public boolean supportDeclspecSpecifiers();
|
||||
|
||||
/**
|
||||
* Provide additional built-in bindings.
|
||||
* @return an instance of {@link IBuiltinBindingsProvider} or <code>null</code>
|
||||
*/
|
||||
public IBuiltinBindingsProvider getBuiltinBindingsProvider();
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2002, 2007 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM Rational Software - Initial API and implementation
|
||||
* Ed Swartz (Nokia)
|
||||
* Anton Leherbauer (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.core.dom.parser.cpp;
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
*/
|
||||
public class ANSICPPParserExtensionConfiguration extends AbstractCPPParserExtensionConfiguration {
|
||||
|
||||
}
|
|
@ -0,0 +1,169 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007 Wind River Systems, Inc. and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Anton Leherbauer (Wind River Systems) - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.core.dom.parser.cpp;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ICodeReaderFactory;
|
||||
import org.eclipse.cdt.core.dom.ast.ASTCompletionNode;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.CPPASTVisitor;
|
||||
import org.eclipse.cdt.core.dom.parser.IScannerExtensionConfiguration;
|
||||
import org.eclipse.cdt.core.dom.parser.ISourceCodeParser;
|
||||
import org.eclipse.cdt.core.index.IIndex;
|
||||
import org.eclipse.cdt.core.model.AbstractLanguage;
|
||||
import org.eclipse.cdt.core.model.IContributedModelBuilder;
|
||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||
import org.eclipse.cdt.core.parser.CodeReader;
|
||||
import org.eclipse.cdt.core.parser.IParserLogService;
|
||||
import org.eclipse.cdt.core.parser.IScanner;
|
||||
import org.eclipse.cdt.core.parser.IScannerInfo;
|
||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||
import org.eclipse.cdt.core.parser.ParserMode;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.GNUCPPSourceParser;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner2.DOMScanner;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.IPDOMLinkageFactory;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.cpp.PDOMCPPLinkageFactory;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
/**
|
||||
* Abstract C++ language. Derived classes need only implement
|
||||
* {@link getScannerExtensionConfiguration()} and
|
||||
* {@link getParserExtensionConfiguration()}.
|
||||
*
|
||||
* <p>
|
||||
* <strong>EXPERIMENTAL</strong>. This class or interface has been added as
|
||||
* part of a work in progress. There is no guarantee that this API will work or
|
||||
* that it will remain the same. Please do not use this API without consulting
|
||||
* with the CDT team.
|
||||
* </p>
|
||||
*
|
||||
* @see IScannerExtensionConfiguration
|
||||
* @see ICPPParserExtensionConfiguration
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
public abstract class AbstractCPPLanguage extends AbstractLanguage {
|
||||
|
||||
protected static class NameCollector extends CPPASTVisitor {
|
||||
{
|
||||
shouldVisitNames= true;
|
||||
}
|
||||
|
||||
private List nameList= new ArrayList();
|
||||
|
||||
public int visit(IASTName name) {
|
||||
nameList.add(name);
|
||||
return PROCESS_CONTINUE;
|
||||
}
|
||||
|
||||
public IASTName[] getNames() {
|
||||
return (IASTName[]) nameList.toArray(new IASTName[nameList.size()]);
|
||||
}
|
||||
}
|
||||
|
||||
public Object getAdapter(Class adapter) {
|
||||
if (adapter == IPDOMLinkageFactory.class)
|
||||
return new PDOMCPPLinkageFactory();
|
||||
else
|
||||
return super.getAdapter(adapter);
|
||||
}
|
||||
|
||||
public IASTTranslationUnit getASTTranslationUnit(CodeReader reader, IScannerInfo scanInfo,
|
||||
ICodeReaderFactory codeReaderFactory, IIndex index, IParserLogService log) throws CoreException {
|
||||
|
||||
IScanner scanner= createScanner(reader, scanInfo, codeReaderFactory, log);
|
||||
ISourceCodeParser parser= createParser(scanner, log, index, false);
|
||||
|
||||
// Parse
|
||||
IASTTranslationUnit ast= parser.parse();
|
||||
return ast;
|
||||
}
|
||||
|
||||
public ASTCompletionNode getCompletionNode(CodeReader reader, IScannerInfo scanInfo,
|
||||
ICodeReaderFactory fileCreator, IIndex index, IParserLogService log, int offset) throws CoreException {
|
||||
IScanner scanner= createScanner(reader, scanInfo, fileCreator, log);
|
||||
scanner.setContentAssistMode(offset);
|
||||
|
||||
ISourceCodeParser parser= createParser(scanner, log, index, true);
|
||||
|
||||
// Run the parse and return the completion node
|
||||
parser.parse();
|
||||
ASTCompletionNode node= parser.getCompletionNode();
|
||||
if (node != null) {
|
||||
node.count= scanner.getCount();
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
||||
public IASTName[] getSelectedNames(IASTTranslationUnit ast, int start, int length) {
|
||||
IASTNode selectedNode= ast.selectNodeForLocation(ast.getFilePath(), start, length);
|
||||
|
||||
if (selectedNode == null)
|
||||
return new IASTName[0];
|
||||
|
||||
if (selectedNode instanceof IASTName)
|
||||
return new IASTName[] { (IASTName) selectedNode };
|
||||
|
||||
NameCollector collector= new NameCollector();
|
||||
selectedNode.accept(collector);
|
||||
return collector.getNames();
|
||||
}
|
||||
|
||||
public IContributedModelBuilder createModelBuilder(ITranslationUnit tu) {
|
||||
// Use the default CDT model builder
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the scanner to be used with the parser.
|
||||
*
|
||||
* @param reader the code reader for the main file
|
||||
* @param scanInfo the scanner information (macros, include pathes)
|
||||
* @param fileCreator the code reader factory for inclusions
|
||||
* @param log the log for debugging
|
||||
* @return an instance of IScanner
|
||||
*/
|
||||
protected IScanner createScanner(CodeReader reader, IScannerInfo scanInfo, ICodeReaderFactory fileCreator, IParserLogService log) {
|
||||
return new DOMScanner(reader, scanInfo, ParserMode.COMPLETE_PARSE, ParserLanguage.C,
|
||||
log, getScannerExtensionConfiguration(), fileCreator);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the parser.
|
||||
*
|
||||
* @param scanner the IScanner to get tokens from
|
||||
* @param log the parser log service
|
||||
* @param index the index to help resolve bindings
|
||||
* @param forCompletion whether the parser is used for code completion
|
||||
* @return an instance of ISourceCodeParser
|
||||
*/
|
||||
protected ISourceCodeParser createParser(IScanner scanner, IParserLogService log, IIndex index, boolean forCompletion) {
|
||||
ParserMode mode= forCompletion ? ParserMode.COMPLETION_PARSE : ParserMode.COMPLETE_PARSE;
|
||||
return new GNUCPPSourceParser(scanner, mode, log, getParserExtensionConfiguration(), index);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the scanner extension configuration for this language, may not
|
||||
* return <code>null</code>
|
||||
*/
|
||||
protected abstract IScannerExtensionConfiguration getScannerExtensionConfiguration();
|
||||
|
||||
/**
|
||||
* @return the parser extension configuration for this language, may not
|
||||
* return <code>null</code>
|
||||
*/
|
||||
protected abstract AbstractCPPParserExtensionConfiguration getParserExtensionConfiguration();
|
||||
|
||||
}
|
|
@ -0,0 +1,134 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007 Wind River Systems, Inc. and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Anton Leherbauer (Wind River Systems) - initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.core.dom.parser.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.parser.IBuiltinBindingsProvider;
|
||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.GCCBuiltinSymbolProvider;
|
||||
|
||||
|
||||
/**
|
||||
* Abstract C++ parser extension configuration to help model C++ dialects.
|
||||
*
|
||||
* <p>
|
||||
* <strong>EXPERIMENTAL</strong>. This class or interface has been added as
|
||||
* part of a work in progress. There is no guarantee that this API will work or
|
||||
* that it will remain the same. Please do not use this API without consulting
|
||||
* with the CDT team.
|
||||
* </p>
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
public abstract class AbstractCPPParserExtensionConfiguration implements ICPPParserExtensionConfiguration {
|
||||
|
||||
/*
|
||||
* @see org.eclipse.cdt.core.dom.parser.cpp.ICPPParserExtensionConfiguration#allowRestrictPointerOperators()
|
||||
*/
|
||||
public boolean allowRestrictPointerOperators() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.cdt.core.dom.parser.cpp.ICPPParserExtensionConfiguration#supportAlignOfUnaryExpression()
|
||||
*/
|
||||
public boolean supportAlignOfUnaryExpression() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.cdt.core.dom.parser.cpp.ICPPParserExtensionConfiguration#supportAttributeSpecifiers()
|
||||
*/
|
||||
public boolean supportAttributeSpecifiers() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.cdt.core.dom.parser.cpp.ICPPParserExtensionConfiguration#supportComplexNumbers()
|
||||
*/
|
||||
public boolean supportComplexNumbers() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.cdt.core.dom.parser.cpp.ICPPParserExtensionConfiguration#supportDeclspecSpecifiers()
|
||||
*/
|
||||
public boolean supportDeclspecSpecifiers() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.cdt.core.dom.parser.cpp.ICPPParserExtensionConfiguration#supportExtendedTemplateSyntax()
|
||||
*/
|
||||
public boolean supportExtendedTemplateSyntax() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.cdt.core.dom.parser.cpp.ICPPParserExtensionConfiguration#supportGCCOtherBuiltinSymbols()
|
||||
*/
|
||||
public boolean supportGCCOtherBuiltinSymbols() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.cdt.core.dom.parser.cpp.ICPPParserExtensionConfiguration#supportKnRC()
|
||||
*/
|
||||
public boolean supportKnRC() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.cdt.core.dom.parser.cpp.ICPPParserExtensionConfiguration#supportLongLongs()
|
||||
*/
|
||||
public boolean supportLongLongs() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.cdt.core.dom.parser.cpp.ICPPParserExtensionConfiguration#supportMinAndMaxOperators()
|
||||
*/
|
||||
public boolean supportMinAndMaxOperators() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.cdt.core.dom.parser.cpp.ICPPParserExtensionConfiguration#supportRestrictKeyword()
|
||||
*/
|
||||
public boolean supportRestrictKeyword() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.cdt.core.dom.parser.cpp.ICPPParserExtensionConfiguration#supportStatementsInExpressions()
|
||||
*/
|
||||
public boolean supportStatementsInExpressions() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.cdt.core.dom.parser.cpp.ICPPParserExtensionConfiguration#supportTypeofUnaryExpressions()
|
||||
*/
|
||||
public boolean supportTypeofUnaryExpressions() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.cdt.core.dom.parser.cpp.ICPPParserExtensionConfiguration#getBuiltinBindingsProvider()
|
||||
*/
|
||||
public IBuiltinBindingsProvider getBuiltinBindingsProvider() {
|
||||
if (supportGCCOtherBuiltinSymbols()) {
|
||||
return new GCCBuiltinSymbolProvider(ParserLanguage.CPP);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,115 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2002, 2007 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM Rational Software - Initial API and implementation
|
||||
* Ed Swartz (Nokia)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.core.dom.parser.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.parser.IBuiltinBindingsProvider;
|
||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.GCCBuiltinSymbolProvider;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
*/
|
||||
public class GPPParserExtensionConfiguration extends AbstractCPPParserExtensionConfiguration {
|
||||
|
||||
/*
|
||||
* @see org.eclipse.cdt.core.dom.parser.cpp.AbstractCPPParserExtensionConfiguration#allowRestrictPointerOperators()
|
||||
*/
|
||||
public boolean allowRestrictPointerOperators() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.cdt.core.dom.parser.cpp.AbstractCPPParserExtensionConfiguration#supportTypeofUnaryExpressions()
|
||||
*/
|
||||
public boolean supportTypeofUnaryExpressions() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.cdt.core.dom.parser.cpp.AbstractCPPParserExtensionConfiguration#supportAlignOfUnaryExpression()
|
||||
*/
|
||||
public boolean supportAlignOfUnaryExpression() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.cdt.core.dom.parser.cpp.AbstractCPPParserExtensionConfiguration#supportExtendedTemplateSyntax()
|
||||
*/
|
||||
public boolean supportExtendedTemplateSyntax() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.cdt.core.dom.parser.cpp.AbstractCPPParserExtensionConfiguration#supportMinAndMaxOperators()
|
||||
*/
|
||||
public boolean supportMinAndMaxOperators() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.cdt.core.dom.parser.cpp.AbstractCPPParserExtensionConfiguration#supportStatementsInExpressions()
|
||||
*/
|
||||
public boolean supportStatementsInExpressions() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.cdt.core.dom.parser.cpp.AbstractCPPParserExtensionConfiguration#supportComplexNumbers()
|
||||
*/
|
||||
public boolean supportComplexNumbers() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.cdt.core.dom.parser.cpp.AbstractCPPParserExtensionConfiguration#supportRestrictKeyword()
|
||||
*/
|
||||
public boolean supportRestrictKeyword() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.cdt.core.dom.parser.cpp.AbstractCPPParserExtensionConfiguration#supportLongLongs()
|
||||
*/
|
||||
public boolean supportLongLongs() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.cdt.core.dom.parser.cpp.AbstractCPPParserExtensionConfiguration#supportKnRC()
|
||||
*/
|
||||
public boolean supportKnRC() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.cdt.core.dom.parser.cpp.AbstractCPPParserExtensionConfiguration#supportAttributeSpecifiers()
|
||||
*/
|
||||
public boolean supportAttributeSpecifiers() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.cdt.core.dom.parser.cpp.AbstractCPPParserExtensionConfiguration#supportDeclspecSpecifiers()
|
||||
*/
|
||||
public boolean supportDeclspecSpecifiers() {
|
||||
// XXX: a hack, should use the target's platform
|
||||
return Platform.getOS().equals(Platform.OS_WIN32);
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.cdt.core.dom.parser.cpp.AbstractCPPParserExtensionConfiguration#getBuiltinBindingsProvider()
|
||||
*/
|
||||
public IBuiltinBindingsProvider getBuiltinBindingsProvider() {
|
||||
return new GCCBuiltinSymbolProvider(ParserLanguage.CPP);
|
||||
}
|
||||
}
|
|
@ -9,8 +9,10 @@
|
|||
* IBM - Initial API and implementation
|
||||
* Ed Swartz (Nokia)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.parser.scanner2;
|
||||
package org.eclipse.cdt.core.dom.parser.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.parser.GNUScannerExtensionConfiguration;
|
||||
import org.eclipse.cdt.core.dom.parser.IScannerExtensionConfiguration;
|
||||
import org.eclipse.cdt.core.parser.GCCKeywords;
|
||||
import org.eclipse.cdt.core.parser.IGCCToken;
|
||||
import org.eclipse.cdt.core.parser.IToken;
|
|
@ -0,0 +1,135 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2002, 2007 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM Rational Software - Initial API and implementation
|
||||
* Ed Swartz (Nokia)
|
||||
* Anton Leherbauer (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.core.dom.parser.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||
import org.eclipse.cdt.core.dom.parser.IBuiltinBindingsProvider;
|
||||
|
||||
|
||||
/**
|
||||
* C++ parser extension configuration interface.
|
||||
*
|
||||
* <p>
|
||||
* This interface is not intended to be implemented directly.
|
||||
* Clients should subclass {@link AbstractCPPParserExtensionConfiguration} instead.
|
||||
* </p>
|
||||
* <p>
|
||||
* <strong>EXPERIMENTAL</strong>. This class or interface has been added as
|
||||
* part of a work in progress. There is no guarantee that this API will work or
|
||||
* that it will remain the same. Please do not use this API without consulting
|
||||
* with the CDT team.
|
||||
* </p>
|
||||
*
|
||||
* @see http://gcc.gnu.org/onlinedocs/gcc/C-Extensions.html
|
||||
* @see http://gcc.gnu.org/onlinedocs/gcc/C_002b_002b-Extensions.html
|
||||
*
|
||||
* @author jcamelon
|
||||
* @since 4.0
|
||||
*/
|
||||
public interface ICPPParserExtensionConfiguration {
|
||||
|
||||
/**
|
||||
* Support for GNU extension "Restricting Pointer Aliasing".
|
||||
* @see http://gcc.gnu.org/onlinedocs/gcc/Restricted-Pointers.html
|
||||
* @return <code>true</code> if support for the extension should be enabled
|
||||
*/
|
||||
public boolean allowRestrictPointerOperators();
|
||||
|
||||
/**
|
||||
* Support for GNU extension "Extended Syntax for Template Instantiation".
|
||||
* @see http://gcc.gnu.org/onlinedocs/gcc/Template-Instantiation.html
|
||||
* @return <code>true</code> if support for the extension should be enabled
|
||||
*/
|
||||
public boolean supportExtendedTemplateSyntax();
|
||||
|
||||
/**
|
||||
* Support for (deprecated) GNU minimum and maximum operators (`<?' and `>?').
|
||||
* @see http://gcc.gnu.org/onlinedocs/gcc/Deprecated-Features.html
|
||||
* @return <code>true</code> if support for the extension should be enabled
|
||||
*/
|
||||
public boolean supportMinAndMaxOperators();
|
||||
|
||||
/**
|
||||
* Support for GNU extension "Data types for complex numbers".
|
||||
* @see http://gcc.gnu.org/onlinedocs/gcc/Complex.html#Complex
|
||||
* @return <code>true</code> if support for the extension should be enabled
|
||||
*/
|
||||
public boolean supportComplexNumbers();
|
||||
|
||||
/**
|
||||
* Support for the GNU <code>__restrict__</code> keyword.
|
||||
* @return <code>true</code> if support for the extension should be enabled
|
||||
*/
|
||||
public boolean supportRestrictKeyword();
|
||||
|
||||
/**
|
||||
* Support for GNU long long types.
|
||||
* @see http://gcc.gnu.org/onlinedocs/gcc/Long-Long.html
|
||||
* @return <code>true</code> if support for the extension should be enabled
|
||||
*/
|
||||
public boolean supportLongLongs();
|
||||
|
||||
/**
|
||||
* Support for GNU extension "Statements and Declarations in Expressions".
|
||||
* @see http://gcc.gnu.org/onlinedocs/gcc/Statement-Exprs.html
|
||||
* @return <code>true</code> if support for the extension should be enabled
|
||||
*/
|
||||
public boolean supportStatementsInExpressions();
|
||||
|
||||
/**
|
||||
* Support for GNU extension "Referring to a Type with typeof".
|
||||
* @see http://gcc.gnu.org/onlinedocs/gcc/Typeof.html
|
||||
* @return <code>true</code> if support for the extension should be enabled
|
||||
*/
|
||||
public boolean supportTypeofUnaryExpressions();
|
||||
|
||||
/**
|
||||
* Support for GNU extension "Inquiring on Alignment of Types or Variables".
|
||||
* @see http://gcc.gnu.org/onlinedocs/gcc/Alignment.html
|
||||
* @return <code>true</code> if support for the extension should be enabled
|
||||
*/
|
||||
public boolean supportAlignOfUnaryExpression();
|
||||
|
||||
/**
|
||||
* Support for Kernighan and Richie (K&R) C.
|
||||
* @return <code>true</code> if support for K&R C should be enabled
|
||||
*/
|
||||
public boolean supportKnRC();
|
||||
|
||||
/**
|
||||
* See http://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html
|
||||
* for more information on GCC's Other Built-in Symbols.
|
||||
* @return <code>true</code> if support for the extension should be enabled
|
||||
* @deprecated use {@link #getBuiltinSymbolProvider(IScope)} instead.
|
||||
*/
|
||||
public boolean supportGCCOtherBuiltinSymbols();
|
||||
|
||||
/**
|
||||
* See http://gcc.gnu.org/onlinedocs/gcc/Attribute-Syntax.html
|
||||
* for more information on GCC's Attribute Specifiers.
|
||||
* @return <code>true</code> if support for the extension should be enabled
|
||||
*/
|
||||
public boolean supportAttributeSpecifiers();
|
||||
|
||||
/**
|
||||
* Win32 compiler extensions also supported by GCC on Win32
|
||||
* @return <code>true</code> if support for the extension should be enabled
|
||||
*/
|
||||
public boolean supportDeclspecSpecifiers();
|
||||
|
||||
/**
|
||||
* Provide additional built-in bindings.
|
||||
* @return an instance of {@link IBuiltinBindingsProvider} or <code>null</code>
|
||||
*/
|
||||
public IBuiltinBindingsProvider getBuiltinBindingsProvider();
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2002, 2005 IBM Corporation and others.
|
||||
* Copyright (c) 2002, 2007 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -14,6 +14,7 @@ import java.io.IOException;
|
|||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.eclipse.cdt.core.dom.parser.IScannerExtensionConfiguration;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTFactory;
|
||||
import org.eclipse.cdt.core.parser.extension.ExtensionDialect;
|
||||
import org.eclipse.cdt.core.parser.extension.IParserExtension;
|
||||
|
@ -26,7 +27,6 @@ import org.eclipse.cdt.internal.core.parser.ast.complete.CompleteParseASTFactory
|
|||
import org.eclipse.cdt.internal.core.parser.ast.quick.QuickParseASTFactory;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner2.GCCOldScannerExtensionConfiguration;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner2.GPPOldScannerExtensionConfiguration;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner2.IScannerExtensionConfiguration;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner2.Scanner2;
|
||||
import org.eclipse.cdt.internal.core.parser.token.KeywordSets;
|
||||
|
||||
|
|
|
@ -60,6 +60,8 @@ import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier.IASTEnumerator;
|
|||
import org.eclipse.cdt.core.dom.ast.gnu.IGNUASTCompoundStatementExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.gnu.IGNUASTTypeIdExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.gnu.IGNUASTUnaryExpression;
|
||||
import org.eclipse.cdt.core.dom.parser.IBuiltinBindingsProvider;
|
||||
import org.eclipse.cdt.core.dom.parser.ISourceCodeParser;
|
||||
import org.eclipse.cdt.core.parser.AbstractParserLogService;
|
||||
import org.eclipse.cdt.core.parser.EndOfFileException;
|
||||
import org.eclipse.cdt.core.parser.IGCCToken;
|
||||
|
@ -89,18 +91,19 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
|||
|
||||
protected final boolean supportKnRC;
|
||||
|
||||
protected final boolean supportGCCOtherBuiltinSymbols;
|
||||
|
||||
protected final boolean supportAttributeSpecifiers;
|
||||
|
||||
protected final boolean supportDeclspecSpecifiers;
|
||||
|
||||
protected final IBuiltinBindingsProvider builtinBindingsProvider;
|
||||
|
||||
protected AbstractGNUSourceCodeParser(IScanner scanner,
|
||||
IParserLogService logService, ParserMode parserMode,
|
||||
boolean supportStatementsInExpressions,
|
||||
boolean supportTypeOfUnaries, boolean supportAlignOfUnaries,
|
||||
boolean supportKnRC, boolean supportGCCOtherBuiltinSymbols,
|
||||
boolean supportAttributeSpecifiers, boolean supportDeclspecSpecifiers) {
|
||||
boolean supportKnRC, boolean supportAttributeSpecifiers,
|
||||
boolean supportDeclspecSpecifiers,
|
||||
IBuiltinBindingsProvider builtinBindingsProvider) {
|
||||
this.scanner = scanner;
|
||||
this.log = wrapLogService(logService);
|
||||
this.mode = parserMode;
|
||||
|
@ -108,9 +111,9 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
|||
this.supportTypeOfUnaries = supportTypeOfUnaries;
|
||||
this.supportAlignOfUnaries = supportAlignOfUnaries;
|
||||
this.supportKnRC = supportKnRC;
|
||||
this.supportGCCOtherBuiltinSymbols = supportGCCOtherBuiltinSymbols;
|
||||
this.supportAttributeSpecifiers = supportAttributeSpecifiers;
|
||||
this.supportDeclspecSpecifiers = supportDeclspecSpecifiers;
|
||||
this.builtinBindingsProvider= builtinBindingsProvider;
|
||||
}
|
||||
|
||||
protected boolean parsePassed = true;
|
||||
|
@ -2303,7 +2306,36 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Hook method to support (skip) additional declspec modifiers.
|
||||
* @throws BacktrackException
|
||||
* @throws EndOfFileException
|
||||
*/
|
||||
protected void handleOtherDeclSpecModifier() throws BacktrackException, EndOfFileException {
|
||||
// default action: consume keyword plus optional parenthesised "something"
|
||||
consume();
|
||||
|
||||
IToken token = LA(1);
|
||||
|
||||
if (token.getType() == IToken.tLPAREN) {
|
||||
consume();
|
||||
int openParen= 1;
|
||||
while(true) {
|
||||
token = LA(1);
|
||||
consume();
|
||||
if (token.getType() == IToken.tLPAREN) {
|
||||
++openParen;
|
||||
} else if (token.getType() == IToken.tRPAREN) {
|
||||
--openParen;
|
||||
if (openParen == 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* In case a cast expression is followed by +/- or & we should avoid it:
|
||||
* (a)+1 vs. (int)+1;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2005, 2006 IBM Corporation and others.
|
||||
* Copyright (c) 2005, 2007 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -8,12 +8,12 @@
|
|||
* Contributors:
|
||||
* IBM - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Anton Leherbauer (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ILinkage;
|
||||
import org.eclipse.cdt.core.dom.ast.ASTNodeProperty;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTBuiltinSymbolProvider;
|
||||
import org.eclipse.cdt.core.dom.ast.IBasicType;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IFunctionType;
|
||||
|
@ -22,6 +22,7 @@ import org.eclipse.cdt.core.dom.ast.IScope;
|
|||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBasicType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameter;
|
||||
import org.eclipse.cdt.core.dom.parser.IBuiltinBindingsProvider;
|
||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||
import org.eclipse.cdt.internal.core.dom.Linkage;
|
||||
|
@ -42,12 +43,12 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.GPPPointerType;
|
|||
import org.eclipse.core.runtime.PlatformObject;
|
||||
|
||||
/**
|
||||
* This is the IASTBuiltinSymbolProvider used to implement the "Other" built-in GCC symbols defined:
|
||||
* This is the IBuiltinBindingsProvider used to implement the "Other" built-in GCC symbols defined:
|
||||
* http://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html#Other-Builtins
|
||||
*
|
||||
* @author dsteffle
|
||||
*/
|
||||
public class GCCBuiltinSymbolProvider implements IASTBuiltinSymbolProvider {
|
||||
public class GCCBuiltinSymbolProvider implements IBuiltinBindingsProvider {
|
||||
/**
|
||||
* <code>BUILTIN_GCC_SYMBOL</code> is a built-in GCC symbol.
|
||||
*/
|
||||
|
@ -290,12 +291,11 @@ public class GCCBuiltinSymbolProvider implements IASTBuiltinSymbolProvider {
|
|||
private IBinding[] bindings=new IBinding[NUM_OTHER_GCC_BUILTINS];
|
||||
private IScope scope=null;
|
||||
private ParserLanguage lang=null;
|
||||
public GCCBuiltinSymbolProvider(IScope scope, ParserLanguage lang) {
|
||||
this.scope = scope;
|
||||
public GCCBuiltinSymbolProvider(ParserLanguage lang) {
|
||||
this.lang = lang;
|
||||
}
|
||||
|
||||
public void initialize() {
|
||||
private void initialize() {
|
||||
__builtin_va_list();
|
||||
__builtin_expect();
|
||||
__builtin_prefetch();
|
||||
|
@ -913,7 +913,7 @@ public class GCCBuiltinSymbolProvider implements IASTBuiltinSymbolProvider {
|
|||
bindings = (IBinding[])ArrayUtil.append(IBinding.class, bindings, temp);
|
||||
}
|
||||
|
||||
public void __builtin_exit() {
|
||||
private void __builtin_exit() {
|
||||
// void __builtin_abort(void)
|
||||
IBinding temp = null;
|
||||
if (lang == ParserLanguage.C) {
|
||||
|
@ -2148,7 +2148,7 @@ public class GCCBuiltinSymbolProvider implements IASTBuiltinSymbolProvider {
|
|||
bindings = (IBinding[])ArrayUtil.append(IBinding.class, bindings, temp);
|
||||
}
|
||||
|
||||
public void __builtin_less_greater() {
|
||||
private void __builtin_less_greater() {
|
||||
IBinding temp = null;
|
||||
// int __builtin_isgreater(real-floating, real-floating)
|
||||
if (lang == ParserLanguage.C) {
|
||||
|
@ -2294,7 +2294,8 @@ public class GCCBuiltinSymbolProvider implements IASTBuiltinSymbolProvider {
|
|||
bindings = (IBinding[])ArrayUtil.append(IBinding.class, bindings, temp);
|
||||
}
|
||||
|
||||
public IBinding[] getBuiltinBindings() {
|
||||
public IBinding[] getBuiltinBindings(IScope scope) {
|
||||
this.scope= scope;
|
||||
initialize();
|
||||
return (IBinding[])ArrayUtil.trim(IBinding.class, bindings);
|
||||
}
|
||||
|
|
|
@ -1,75 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2002, 2005 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM Rational Software - Initial API and implementation
|
||||
* Ed Swartz (Nokia)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.c;
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
*/
|
||||
public class ANSICParserExtensionConfiguration implements
|
||||
ICParserExtensionConfiguration {
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser2.c.ICParserExtensionConfiguration#supportStatementsInExpressions()
|
||||
*/
|
||||
public boolean supportStatementsInExpressions() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser2.c.ICParserExtensionConfiguration#supportGCCStyleDesignators()
|
||||
*/
|
||||
public boolean supportGCCStyleDesignators() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser2.c.ICParserExtensionConfiguration#supportTypeofUnaryExpressions()
|
||||
*/
|
||||
public boolean supportTypeofUnaryExpressions() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser2.c.ICParserExtensionConfiguration#supportAlignOfUnaryExpression()
|
||||
*/
|
||||
public boolean supportAlignOfUnaryExpression() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser2.c.ICParserExtensionConfiguration#supportKnRC()
|
||||
*/
|
||||
public boolean supportKnRC() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser2.c.ICParserExtensionConfiguration#supportGCCBuiltinSymbols()
|
||||
*/
|
||||
public boolean supportGCCOtherBuiltinSymbols() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser2.c.ICParserExtensionConfiguration#supportAttributeSpecifiers()
|
||||
*/
|
||||
public boolean supportAttributeSpecifiers() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.dom.parser.c.ICParserExtensionConfiguration#supportDeclspecSpecifiers()
|
||||
*/
|
||||
public boolean supportDeclspecSpecifiers() {
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -40,10 +40,7 @@ import org.eclipse.cdt.core.dom.ast.IMacroBinding;
|
|||
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||
import org.eclipse.cdt.core.dom.ast.c.CASTVisitor;
|
||||
import org.eclipse.cdt.core.dom.ast.c.ICASTDesignator;
|
||||
import org.eclipse.cdt.core.dom.ast.gnu.c.GCCLanguage;
|
||||
import org.eclipse.cdt.core.index.IIndex;
|
||||
import org.eclipse.cdt.core.model.ILanguage;
|
||||
import org.eclipse.cdt.core.model.LanguageManager;
|
||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTEnumerator;
|
||||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||
|
|
|
@ -1,80 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2005 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM Rational Software - Initial API and implementation
|
||||
* Ed Swartz (Nokia)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.c;
|
||||
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
*/
|
||||
public class GCCParserExtensionConfiguration implements
|
||||
ICParserExtensionConfiguration {
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser2.c.ICParserExtensionConfiguration#supportStatementsInExpressions()
|
||||
*/
|
||||
public boolean supportStatementsInExpressions() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser2.c.ICParserExtensionConfiguration#supportGCCStyleDesignators()
|
||||
*/
|
||||
public boolean supportGCCStyleDesignators() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser2.c.ICParserExtensionConfiguration#supportTypeofUnaryExpressions()
|
||||
*/
|
||||
public boolean supportTypeofUnaryExpressions() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser2.c.ICParserExtensionConfiguration#supportAlignOfUnaryExpression()
|
||||
*/
|
||||
public boolean supportAlignOfUnaryExpression() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.dom.parser.c.ICParserExtensionConfiguration#supportKRCSyntax()
|
||||
*/
|
||||
public boolean supportKnRC() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser2.c.ICParserExtensionConfiguration#supportGCCOtherBuiltinSymbols()
|
||||
*/
|
||||
public boolean supportGCCOtherBuiltinSymbols() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser2.c.ICParserExtensionConfiguration#supportAttributeSpecifiers()
|
||||
*/
|
||||
public boolean supportAttributeSpecifiers() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.dom.parser.c.ICParserExtensionConfiguration#supportDeclspecSpecifiers()
|
||||
*/
|
||||
public boolean supportDeclspecSpecifiers() {
|
||||
// XXX Yes, this is a hack -- should use the target platform
|
||||
if (Platform.getOS().equals(Platform.OS_WIN32))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -94,6 +94,8 @@ import org.eclipse.cdt.core.dom.ast.gnu.IGNUASTCompoundStatementExpression;
|
|||
import org.eclipse.cdt.core.dom.ast.gnu.c.ICASTKnRFunctionDeclarator;
|
||||
import org.eclipse.cdt.core.dom.ast.gnu.c.IGCCASTArrayRangeDesignator;
|
||||
import org.eclipse.cdt.core.dom.ast.gnu.c.IGCCASTSimpleDeclSpecifier;
|
||||
import org.eclipse.cdt.core.dom.parser.IExtensionToken;
|
||||
import org.eclipse.cdt.core.dom.parser.c.ICParserExtensionConfiguration;
|
||||
import org.eclipse.cdt.core.index.IIndex;
|
||||
import org.eclipse.cdt.core.parser.EndOfFileException;
|
||||
import org.eclipse.cdt.core.parser.IGCCToken;
|
||||
|
@ -101,7 +103,6 @@ import org.eclipse.cdt.core.parser.IParserLogService;
|
|||
import org.eclipse.cdt.core.parser.IScanner;
|
||||
import org.eclipse.cdt.core.parser.IToken;
|
||||
import org.eclipse.cdt.core.parser.ParseError;
|
||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||
import org.eclipse.cdt.core.parser.ParserMode;
|
||||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
||||
|
@ -109,7 +110,6 @@ import org.eclipse.cdt.internal.core.dom.parser.ASTInternal;
|
|||
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.AbstractGNUSourceCodeParser;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.BacktrackException;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.GCCBuiltinSymbolProvider;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguousExpression;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguousStatement;
|
||||
|
||||
|
@ -143,13 +143,14 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
|||
public GNUCSourceParser(IScanner scanner, ParserMode parserMode,
|
||||
IParserLogService logService, ICParserExtensionConfiguration config,
|
||||
IIndex index) {
|
||||
super(scanner, logService, parserMode, config
|
||||
.supportStatementsInExpressions(), config
|
||||
.supportTypeofUnaryExpressions(), config
|
||||
.supportAlignOfUnaryExpression(), config
|
||||
.supportKnRC(), config.supportGCCOtherBuiltinSymbols(),
|
||||
config.supportAttributeSpecifiers(),
|
||||
config.supportDeclspecSpecifiers());
|
||||
super(scanner, logService, parserMode,
|
||||
config.supportStatementsInExpressions(),
|
||||
config.supportTypeofUnaryExpressions(),
|
||||
config.supportAlignOfUnaryExpression(),
|
||||
config.supportKnRC(),
|
||||
config.supportAttributeSpecifiers(),
|
||||
config.supportDeclspecSpecifiers(),
|
||||
config.getBuiltinBindingsProvider());
|
||||
supportGCCStyleDesignators = config.supportGCCStyleDesignators();
|
||||
this.index= index;
|
||||
}
|
||||
|
@ -593,10 +594,10 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
|||
translationUnit.setIndex(index);
|
||||
|
||||
// add built-in names to the scope
|
||||
if (supportGCCOtherBuiltinSymbols) {
|
||||
if (builtinBindingsProvider != null) {
|
||||
IScope tuScope = translationUnit.getScope();
|
||||
|
||||
IBinding[] bindings = new GCCBuiltinSymbolProvider(translationUnit.getScope(), ParserLanguage.C).getBuiltinBindings();
|
||||
IBinding[] bindings = builtinBindingsProvider.getBuiltinBindings(tuScope);
|
||||
for(int i=0; i<bindings.length; i++) {
|
||||
ASTInternal.addBinding(tuScope, bindings[i]);
|
||||
}
|
||||
|
@ -1598,7 +1599,11 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
|||
throwBacktrack(LA(1).getOffset(), LA(1).getLength());
|
||||
break;
|
||||
default:
|
||||
if (supportTypeOfUnaries && LT(1) == IGCCToken.t_typeof) {
|
||||
if (LT(1) >= IExtensionToken.t__otherDeclSpecModifierFirst && LT(1) <= IExtensionToken.t__otherDeclSpecModifierLast) {
|
||||
handleOtherDeclSpecModifier();
|
||||
break;
|
||||
}
|
||||
if (supportTypeOfUnaries && LT(1) == IGCCToken.t_typeof) {
|
||||
typeofExpression = unaryTypeofExpression();
|
||||
if (typeofExpression != null) {
|
||||
flags.setEncounteredTypename(true);
|
||||
|
@ -1694,7 +1699,7 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
|||
return declSpec;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
protected ICASTSimpleDeclSpecifier createSimpleTypeSpecifier() {
|
||||
|
|
|
@ -1,45 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2002, 2005 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM Rational Software - Initial API and implementation
|
||||
* Ed Swartz (Nokia)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.c;
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
*/
|
||||
public interface ICParserExtensionConfiguration {
|
||||
|
||||
public boolean supportStatementsInExpressions();
|
||||
public boolean supportGCCStyleDesignators();
|
||||
public boolean supportTypeofUnaryExpressions();
|
||||
public boolean supportAlignOfUnaryExpression();
|
||||
public boolean supportKnRC();
|
||||
|
||||
/**
|
||||
* See http://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html#Other-Builtins
|
||||
* for more information on GCC's Other Built-in Symbols.
|
||||
* @return
|
||||
*/
|
||||
public boolean supportGCCOtherBuiltinSymbols();
|
||||
|
||||
/**
|
||||
* See http://gcc.gnu.org/onlinedocs/gcc-3.4.4/gcc/Attribute-Syntax.html#Attribute-Syntax
|
||||
* for more information on GCC's Attribute Specifiers.
|
||||
* @return
|
||||
*/
|
||||
public boolean supportAttributeSpecifiers();
|
||||
|
||||
/**
|
||||
* Win32 compiler extensions also supported by GCC on Win32
|
||||
* @return
|
||||
*/
|
||||
public boolean supportDeclspecSpecifiers();
|
||||
|
||||
}
|
|
@ -1,110 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2002, 2005 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM Rational Software - Initial API and implementation
|
||||
* Ed Swartz (Nokia)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
*/
|
||||
public class ANSICPPParserExtensionConfiguration implements
|
||||
ICPPParserExtensionConfiguration {
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser2.cpp.ICPPParserExtensionConfiguration#allowRestrictPointerOperators()
|
||||
*/
|
||||
public boolean allowRestrictPointerOperators() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser2.cpp.ICPPParserExtensionConfiguration#supportTypeofUnaryExpressions()
|
||||
*/
|
||||
public boolean supportTypeofUnaryExpressions() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser2.cpp.ICPPParserExtensionConfiguration#supportAlignOfUnaryExpression()
|
||||
*/
|
||||
public boolean supportAlignOfUnaryExpression() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser2.cpp.ICPPParserExtensionConfiguration#supportExtendedTemplateSyntax()
|
||||
*/
|
||||
public boolean supportExtendedTemplateSyntax() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser2.cpp.ICPPParserExtensionConfiguration#supportMinAndMaxOperators()
|
||||
*/
|
||||
public boolean supportMinAndMaxOperators() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser2.cpp.ICPPParserExtensionConfiguration#supportStatementsInExpressions()
|
||||
*/
|
||||
public boolean supportStatementsInExpressions() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser2.cpp.ICPPParserExtensionConfiguration#supportComplexNumbers()
|
||||
*/
|
||||
public boolean supportComplexNumbers() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser2.cpp.ICPPParserExtensionConfiguration#supportRestrictKeyword()
|
||||
*/
|
||||
public boolean supportRestrictKeyword() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser2.cpp.ICPPParserExtensionConfiguration#supportLongLongs()
|
||||
*/
|
||||
public boolean supportLongLongs() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser2.cpp.ICPPParserExtensionConfiguration#supportGCCOtherBuiltinSymbols()
|
||||
*/
|
||||
public boolean supportGCCOtherBuiltinSymbols() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser2.cpp.ICPPParserExtensionConfiguration#supportKnRC()
|
||||
*/
|
||||
public boolean supportKnRC() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser2.cpp.ICPPParserExtensionConfiguration#supportAttributeSpecifiers()
|
||||
*/
|
||||
public boolean supportAttributeSpecifiers() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPParserExtensionConfiguration#supportDeclspecSpecifiers()
|
||||
*/
|
||||
public boolean supportDeclspecSpecifiers() {
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -54,10 +54,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTranslationUnit;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBasicType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
|
||||
import org.eclipse.cdt.core.dom.ast.gnu.cpp.GPPLanguage;
|
||||
import org.eclipse.cdt.core.index.IIndex;
|
||||
import org.eclipse.cdt.core.model.ILanguage;
|
||||
import org.eclipse.cdt.core.model.LanguageManager;
|
||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTEnumerator;
|
||||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||
|
|
|
@ -134,6 +134,8 @@ import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTExplicitTemplateInstantiation
|
|||
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTPointer;
|
||||
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTPointerToMember;
|
||||
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTSimpleDeclSpecifier;
|
||||
import org.eclipse.cdt.core.dom.parser.IExtensionToken;
|
||||
import org.eclipse.cdt.core.dom.parser.cpp.ICPPParserExtensionConfiguration;
|
||||
import org.eclipse.cdt.core.index.IIndex;
|
||||
import org.eclipse.cdt.core.parser.EndOfFileException;
|
||||
import org.eclipse.cdt.core.parser.IGCCToken;
|
||||
|
@ -142,14 +144,12 @@ import org.eclipse.cdt.core.parser.IScanner;
|
|||
import org.eclipse.cdt.core.parser.IToken;
|
||||
import org.eclipse.cdt.core.parser.ITokenDuple;
|
||||
import org.eclipse.cdt.core.parser.ParseError;
|
||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||
import org.eclipse.cdt.core.parser.ParserMode;
|
||||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ASTInternal;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.AbstractGNUSourceCodeParser;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.BacktrackException;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.GCCBuiltinSymbolProvider;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguousDeclaration;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguousExpression;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguousStatement;
|
||||
|
@ -1993,11 +1993,14 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
|||
public GNUCPPSourceParser(IScanner scanner, ParserMode mode,
|
||||
IParserLogService log, ICPPParserExtensionConfiguration config,
|
||||
IIndex index) {
|
||||
super(scanner, log, mode, config.supportStatementsInExpressions(),
|
||||
config.supportTypeofUnaryExpressions(), config
|
||||
.supportAlignOfUnaryExpression(), config.supportKnRC(),
|
||||
config.supportGCCOtherBuiltinSymbols(), config.supportAttributeSpecifiers(),
|
||||
config.supportDeclspecSpecifiers());
|
||||
super(scanner, log, mode,
|
||||
config.supportStatementsInExpressions(),
|
||||
config.supportTypeofUnaryExpressions(),
|
||||
config.supportAlignOfUnaryExpression(),
|
||||
config.supportKnRC(),
|
||||
config.supportAttributeSpecifiers(),
|
||||
config.supportDeclspecSpecifiers(),
|
||||
config.getBuiltinBindingsProvider());
|
||||
allowCPPRestrict = config.allowRestrictPointerOperators();
|
||||
supportExtendedTemplateSyntax = config.supportExtendedTemplateSyntax();
|
||||
supportMinAndMaxOperators = config.supportMinAndMaxOperators();
|
||||
|
@ -3504,7 +3507,11 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
|||
break;
|
||||
|
||||
default:
|
||||
if (supportTypeOfUnaries && LT(1) == IGCCToken.t_typeof) {
|
||||
if (LT(1) >= IExtensionToken.t__otherDeclSpecModifierFirst && LT(1) <= IExtensionToken.t__otherDeclSpecModifierLast) {
|
||||
handleOtherDeclSpecModifier();
|
||||
break;
|
||||
}
|
||||
if (supportTypeOfUnaries && LT(1) == IGCCToken.t_typeof) {
|
||||
typeofExpression = unaryTypeofExpression();
|
||||
if (typeofExpression != null) {
|
||||
flags.setEncounteredTypename(true);
|
||||
|
@ -4674,16 +4681,15 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
|||
translationUnit.setIndex(index);
|
||||
|
||||
// add built-in names to the scope
|
||||
if (supportGCCOtherBuiltinSymbols) {
|
||||
IScope tuScope = translationUnit.getScope();
|
||||
|
||||
IBinding[] bindings = new GCCBuiltinSymbolProvider(
|
||||
translationUnit.getScope(), ParserLanguage.CPP)
|
||||
.getBuiltinBindings();
|
||||
for (int i = 0; i < bindings.length; i++) {
|
||||
ASTInternal.addBinding(tuScope, bindings[i]);
|
||||
}
|
||||
}
|
||||
// add built-in names to the scope
|
||||
if (builtinBindingsProvider != null) {
|
||||
IScope tuScope = translationUnit.getScope();
|
||||
|
||||
IBinding[] bindings = builtinBindingsProvider.getBuiltinBindings(tuScope);
|
||||
for(int i=0; i<bindings.length; i++) {
|
||||
ASTInternal.addBinding(tuScope, bindings[i]);
|
||||
}
|
||||
}
|
||||
} catch (Exception e2) {
|
||||
logException("translationUnit::createCompilationUnit()", e2); //$NON-NLS-1$
|
||||
return;
|
||||
|
|
|
@ -1,113 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2002, 2005 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM Rational Software - Initial API and implementation
|
||||
* Ed Swartz (Nokia)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
*/
|
||||
public class GPPParserExtensionConfiguration implements
|
||||
ICPPParserExtensionConfiguration {
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser2.cpp.ICPPParserExtensionConfiguration#allowRestrictPointerOperators()
|
||||
*/
|
||||
public boolean allowRestrictPointerOperators() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser2.cpp.ICPPParserExtensionConfiguration#supportTypeofUnaryExpressions()
|
||||
*/
|
||||
public boolean supportTypeofUnaryExpressions() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser2.cpp.ICPPParserExtensionConfiguration#supportAlignOfUnaryExpression()
|
||||
*/
|
||||
public boolean supportAlignOfUnaryExpression() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser2.cpp.ICPPParserExtensionConfiguration#supportExtendedTemplateSyntax()
|
||||
*/
|
||||
public boolean supportExtendedTemplateSyntax() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser2.cpp.ICPPParserExtensionConfiguration#supportMinAndMaxOperators()
|
||||
*/
|
||||
public boolean supportMinAndMaxOperators() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser2.cpp.ICPPParserExtensionConfiguration#supportStatementsInExpressions()
|
||||
*/
|
||||
public boolean supportStatementsInExpressions() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser2.cpp.ICPPParserExtensionConfiguration#supportComplexNumbers()
|
||||
*/
|
||||
public boolean supportComplexNumbers() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser2.cpp.ICPPParserExtensionConfiguration#supportRestrictKeyword()
|
||||
*/
|
||||
public boolean supportRestrictKeyword() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser2.cpp.ICPPParserExtensionConfiguration#supportLongLongs()
|
||||
*/
|
||||
public boolean supportLongLongs() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser2.cpp.ICPPParserExtensionConfiguration#supportKnRC()
|
||||
*/
|
||||
public boolean supportKnRC() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser2.cpp.ICPPParserExtensionConfiguration#supportGCCOtherBuiltinSymbols()
|
||||
*/
|
||||
public boolean supportGCCOtherBuiltinSymbols() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser2.cpp.ICPPParserExtensionConfiguration#supportAttributeSpecifiers()
|
||||
*/
|
||||
public boolean supportAttributeSpecifiers() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPParserExtensionConfiguration#supportDeclspecSpecifiers()
|
||||
*/
|
||||
public boolean supportDeclspecSpecifiers() {
|
||||
// XXX: a hack, should use the target's platform
|
||||
return Platform.getOS().equals(Platform.OS_WIN32);
|
||||
}
|
||||
}
|
|
@ -1,38 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2002, 2005 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM Rational Software - Initial API and implementation
|
||||
* Ed Swartz (Nokia)
|
||||
*******************************************************************************/
|
||||
|
||||
/*
|
||||
* Created on Oct 22, 2004
|
||||
*
|
||||
*/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
*/
|
||||
public interface ICPPParserExtensionConfiguration {
|
||||
|
||||
public boolean allowRestrictPointerOperators();
|
||||
public boolean supportTypeofUnaryExpressions();
|
||||
public boolean supportAlignOfUnaryExpression();
|
||||
public boolean supportExtendedTemplateSyntax();
|
||||
public boolean supportMinAndMaxOperators();
|
||||
public boolean supportStatementsInExpressions();
|
||||
public boolean supportComplexNumbers();
|
||||
public boolean supportRestrictKeyword();
|
||||
public boolean supportLongLongs();
|
||||
public boolean supportKnRC();
|
||||
public boolean supportGCCOtherBuiltinSymbols();
|
||||
public boolean supportAttributeSpecifiers();
|
||||
public boolean supportDeclspecSpecifiers();
|
||||
|
||||
}
|
File diff suppressed because it is too large
Load diff
|
@ -17,6 +17,7 @@ import java.util.List;
|
|||
|
||||
import org.eclipse.cdt.core.dom.ICodeReaderFactory;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTProblem;
|
||||
import org.eclipse.cdt.core.dom.parser.IScannerExtensionConfiguration;
|
||||
import org.eclipse.cdt.core.parser.CodeReader;
|
||||
import org.eclipse.cdt.core.parser.IMacro;
|
||||
import org.eclipse.cdt.core.parser.IParserLogService;
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2002, 2005 IBM Corporation and others.
|
||||
* Copyright (c) 2002, 2007 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -11,6 +11,7 @@
|
|||
|
||||
package org.eclipse.cdt.internal.core.parser.scanner2;
|
||||
|
||||
import org.eclipse.cdt.core.dom.parser.c.GCCScannerExtensionConfiguration;
|
||||
import org.eclipse.cdt.core.parser.util.CharArrayObjectMap;
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2002, 2005 IBM Corporation and others.
|
||||
* Copyright (c) 2002, 2007 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -11,6 +11,7 @@
|
|||
|
||||
package org.eclipse.cdt.internal.core.parser.scanner2;
|
||||
|
||||
import org.eclipse.cdt.core.dom.parser.cpp.GPPScannerExtensionConfiguration;
|
||||
import org.eclipse.cdt.core.parser.util.CharArrayObjectMap;
|
||||
|
||||
/**
|
||||
|
|
|
@ -14,6 +14,7 @@ package org.eclipse.cdt.internal.core.parser.scanner2;
|
|||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.core.dom.parser.IScannerExtensionConfiguration;
|
||||
import org.eclipse.cdt.core.parser.CodeReader;
|
||||
import org.eclipse.cdt.core.parser.IParserLogService;
|
||||
import org.eclipse.cdt.core.parser.IProblem;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2005 IBM Corporation and others.
|
||||
* Copyright (c) 2004, 2007 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -16,6 +16,16 @@ import org.eclipse.cdt.core.dom.ICodeReaderFactory;
|
|||
import org.eclipse.cdt.core.dom.IParserConfiguration;
|
||||
import org.eclipse.cdt.core.dom.ast.ASTCompletionNode;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||
import org.eclipse.cdt.core.dom.parser.IScannerExtensionConfiguration;
|
||||
import org.eclipse.cdt.core.dom.parser.ISourceCodeParser;
|
||||
import org.eclipse.cdt.core.dom.parser.c.ANSICParserExtensionConfiguration;
|
||||
import org.eclipse.cdt.core.dom.parser.c.GCCParserExtensionConfiguration;
|
||||
import org.eclipse.cdt.core.dom.parser.c.GCCScannerExtensionConfiguration;
|
||||
import org.eclipse.cdt.core.dom.parser.c.ICParserExtensionConfiguration;
|
||||
import org.eclipse.cdt.core.dom.parser.cpp.ANSICPPParserExtensionConfiguration;
|
||||
import org.eclipse.cdt.core.dom.parser.cpp.GPPParserExtensionConfiguration;
|
||||
import org.eclipse.cdt.core.dom.parser.cpp.GPPScannerExtensionConfiguration;
|
||||
import org.eclipse.cdt.core.dom.parser.cpp.ICPPParserExtensionConfiguration;
|
||||
import org.eclipse.cdt.core.parser.CodeReader;
|
||||
import org.eclipse.cdt.core.parser.IScanner;
|
||||
import org.eclipse.cdt.core.parser.IScannerInfo;
|
||||
|
@ -25,19 +35,9 @@ import org.eclipse.cdt.core.parser.ParserLanguage;
|
|||
import org.eclipse.cdt.core.parser.ParserMode;
|
||||
import org.eclipse.cdt.core.parser.ParserUtil;
|
||||
import org.eclipse.cdt.core.parser.ScannerInfo;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ISourceCodeParser;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.c.ANSICParserExtensionConfiguration;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.c.GCCParserExtensionConfiguration;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.c.GNUCSourceParser;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.c.ICParserExtensionConfiguration;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ANSICPPParserExtensionConfiguration;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.GNUCPPSourceParser;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.GPPParserExtensionConfiguration;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPParserExtensionConfiguration;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner2.DOMScanner;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner2.GCCScannerExtensionConfiguration;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner2.GPPScannerExtensionConfiguration;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner2.IScannerExtensionConfiguration;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
|
|
Loading…
Add table
Reference in a new issue