mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-09-08 11:03:28 +02:00
Support for @ in identifiers, bug 237028.
This commit is contained in:
parent
e50931293e
commit
e6baa5b577
27 changed files with 476 additions and 302 deletions
|
@ -165,9 +165,9 @@ public class AST2BaseTest extends BaseTestCase {
|
||||||
IScannerInfo scannerInfo, boolean parseComments) {
|
IScannerInfo scannerInfo, boolean parseComments) {
|
||||||
IScannerExtensionConfiguration configuration = null;
|
IScannerExtensionConfiguration configuration = null;
|
||||||
if( lang == ParserLanguage.C )
|
if( lang == ParserLanguage.C )
|
||||||
configuration = new GCCScannerExtensionConfiguration();
|
configuration= GCCScannerExtensionConfiguration.getInstance();
|
||||||
else
|
else
|
||||||
configuration = new GPPScannerExtensionConfiguration();
|
configuration= GPPScannerExtensionConfiguration.getInstance();
|
||||||
IScanner scanner;
|
IScanner scanner;
|
||||||
scanner= new CPreprocessor(codeReader, scannerInfo, lang, NULL_LOG, configuration,
|
scanner= new CPreprocessor(codeReader, scannerInfo, lang, NULL_LOG, configuration,
|
||||||
FileCodeReaderFactory.getInstance());
|
FileCodeReaderFactory.getInstance());
|
||||||
|
|
|
@ -85,7 +85,7 @@ public class ExpansionExplorerTests extends BaseTestCase {
|
||||||
private MacroExpander createExpander(final String macrodefs) throws OffsetLimitReachedException {
|
private MacroExpander createExpander(final String macrodefs) throws OffsetLimitReachedException {
|
||||||
CPreprocessor cpp= new CPreprocessor(new CodeReader(macrodefs.toCharArray()),
|
CPreprocessor cpp= new CPreprocessor(new CodeReader(macrodefs.toCharArray()),
|
||||||
new ScannerInfo(), ParserLanguage.C, new NullLogService(),
|
new ScannerInfo(), ParserLanguage.C, new NullLogService(),
|
||||||
new GCCScannerExtensionConfiguration(), NullCodeReaderFactory.getInstance());
|
GCCScannerExtensionConfiguration.getInstance(), NullCodeReaderFactory.getInstance());
|
||||||
int type;
|
int type;
|
||||||
do {
|
do {
|
||||||
type= cpp.nextTokenRaw().getType();
|
type= cpp.nextTokenRaw().getType();
|
||||||
|
|
|
@ -53,7 +53,7 @@ public class LexerTests extends BaseTestCase {
|
||||||
private void init(String input, boolean dollar, boolean minmax) throws Exception {
|
private void init(String input, boolean dollar, boolean minmax) throws Exception {
|
||||||
fLog.clear();
|
fLog.clear();
|
||||||
final LexerOptions lexerOptions = new LexerOptions();
|
final LexerOptions lexerOptions = new LexerOptions();
|
||||||
lexerOptions.fSupportDollarInitializers= dollar;
|
lexerOptions.fSupportDollarInIdentifiers= dollar;
|
||||||
lexerOptions.fSupportMinAndMax= minmax;
|
lexerOptions.fSupportMinAndMax= minmax;
|
||||||
fLexer= new Lexer(input.toCharArray(), lexerOptions, fLog, null);
|
fLexer= new Lexer(input.toCharArray(), lexerOptions, fLog, null);
|
||||||
fLexer.nextToken();
|
fLexer.nextToken();
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2005, 2007 IBM Corporation and others.
|
* Copyright (c) 2005, 2008 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -80,10 +80,10 @@ public class PreprocessorSpeedTest {
|
||||||
ICodeReaderFactory readerFactory= FileCodeReaderFactory.getInstance();
|
ICodeReaderFactory readerFactory= FileCodeReaderFactory.getInstance();
|
||||||
IScannerExtensionConfiguration scannerConfig;
|
IScannerExtensionConfiguration scannerConfig;
|
||||||
if (lang == ParserLanguage.C) {
|
if (lang == ParserLanguage.C) {
|
||||||
scannerConfig= new GCCScannerExtensionConfiguration();
|
scannerConfig= GCCScannerExtensionConfiguration.getInstance();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
scannerConfig= new GPPScannerExtensionConfiguration();
|
scannerConfig= GPPScannerExtensionConfiguration.getInstance();
|
||||||
}
|
}
|
||||||
ParserMode mode = ParserMode.COMPLETE_PARSE;
|
ParserMode mode = ParserMode.COMPLETE_PARSE;
|
||||||
CPreprocessor cpp= new CPreprocessor(reader, info, lang, new NullLogService(), scannerConfig, readerFactory);
|
CPreprocessor cpp= new CPreprocessor(reader, info, lang, new NullLogService(), scannerConfig, readerFactory);
|
||||||
|
|
|
@ -67,10 +67,10 @@ public abstract class PreprocessorTestsBase extends BaseTestCase {
|
||||||
IScannerExtensionConfiguration scannerConfig;
|
IScannerExtensionConfiguration scannerConfig;
|
||||||
|
|
||||||
if (lang == ParserLanguage.C) {
|
if (lang == ParserLanguage.C) {
|
||||||
scannerConfig= new GCCScannerExtensionConfiguration();
|
scannerConfig= GCCScannerExtensionConfiguration.getInstance();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
scannerConfig= new GPPScannerExtensionConfiguration();
|
scannerConfig= GPPScannerExtensionConfiguration.getInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
fScanner= new CPreprocessor(input, scannerInfo, lang, NULL_LOG, scannerConfig, readerFactory);
|
fScanner= new CPreprocessor(input, scannerInfo, lang, NULL_LOG, scannerConfig, readerFactory);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2005, 2007 QNX Software Systems and others.
|
* Copyright (c) 2005, 2008 QNX Software Systems and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -12,7 +12,6 @@
|
||||||
* Anton Leherbauer (Wind River Systems)
|
* Anton Leherbauer (Wind River Systems)
|
||||||
* Mike Kucera - IBM
|
* Mike Kucera - IBM
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.core.dom.ast.gnu.c;
|
package org.eclipse.cdt.core.dom.ast.gnu.c;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
|
@ -22,6 +21,7 @@ import org.eclipse.cdt.core.dom.parser.IScannerExtensionConfiguration;
|
||||||
import org.eclipse.cdt.core.dom.parser.ISourceCodeParser;
|
import org.eclipse.cdt.core.dom.parser.ISourceCodeParser;
|
||||||
import org.eclipse.cdt.core.dom.parser.c.GCCParserExtensionConfiguration;
|
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.GCCScannerExtensionConfiguration;
|
||||||
|
import org.eclipse.cdt.core.dom.parser.c.ICParserExtensionConfiguration;
|
||||||
import org.eclipse.cdt.core.index.IIndex;
|
import org.eclipse.cdt.core.index.IIndex;
|
||||||
import org.eclipse.cdt.core.parser.IParserLogService;
|
import org.eclipse.cdt.core.parser.IParserLogService;
|
||||||
import org.eclipse.cdt.core.parser.IScanner;
|
import org.eclipse.cdt.core.parser.IScanner;
|
||||||
|
@ -37,8 +37,8 @@ import org.eclipse.cdt.internal.core.pdom.dom.c.PDOMCLinkageFactory;
|
||||||
*/
|
*/
|
||||||
public class GCCLanguage extends AbstractCLikeLanguage {
|
public class GCCLanguage extends AbstractCLikeLanguage {
|
||||||
|
|
||||||
protected static final GCCScannerExtensionConfiguration C_GNU_SCANNER_EXTENSION = new GCCScannerExtensionConfiguration();
|
protected static final GCCScannerExtensionConfiguration C_GNU_SCANNER_EXTENSION= GCCScannerExtensionConfiguration.getInstance();
|
||||||
protected static final GCCParserExtensionConfiguration C_GNU_PARSER_EXTENSION = new GCCParserExtensionConfiguration();
|
protected static final GCCParserExtensionConfiguration C_GNU_PARSER_EXTENSION= GCCParserExtensionConfiguration.getInstance();
|
||||||
// Must match the id in the extension
|
// Must match the id in the extension
|
||||||
public static final String ID = CCorePlugin.PLUGIN_ID + ".gcc"; //$NON-NLS-1$
|
public static final String ID = CCorePlugin.PLUGIN_ID + ".gcc"; //$NON-NLS-1$
|
||||||
|
|
||||||
|
@ -73,13 +73,19 @@ public class GCCLanguage extends AbstractCLikeLanguage {
|
||||||
return C_GNU_SCANNER_EXTENSION;
|
return C_GNU_SCANNER_EXTENSION;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the extension configuration used for creating the parser.
|
||||||
|
* @since 5.1
|
||||||
|
*/
|
||||||
|
protected ICParserExtensionConfiguration getParserExtensionConfiguration() {
|
||||||
|
return C_GNU_PARSER_EXTENSION;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ISourceCodeParser createParser(IScanner scanner, ParserMode parserMode, IParserLogService logService, IIndex index) {
|
protected ISourceCodeParser createParser(IScanner scanner, ParserMode parserMode, IParserLogService logService, IIndex index) {
|
||||||
return new GNUCSourceParser(scanner, parserMode, logService, C_GNU_PARSER_EXTENSION, index);
|
return new GNUCSourceParser(scanner, parserMode, logService, getParserExtensionConfiguration(), index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ParserLanguage getParserLanguage() {
|
protected ParserLanguage getParserLanguage() {
|
||||||
return ParserLanguage.C;
|
return ParserLanguage.C;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2005, 2007 QNX Software Systems and others.
|
* Copyright (c) 2005, 2008 QNX Software Systems and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -21,6 +21,7 @@ import org.eclipse.cdt.core.dom.parser.IScannerExtensionConfiguration;
|
||||||
import org.eclipse.cdt.core.dom.parser.ISourceCodeParser;
|
import org.eclipse.cdt.core.dom.parser.ISourceCodeParser;
|
||||||
import org.eclipse.cdt.core.dom.parser.cpp.GPPParserExtensionConfiguration;
|
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.GPPScannerExtensionConfiguration;
|
||||||
|
import org.eclipse.cdt.core.dom.parser.cpp.ICPPParserExtensionConfiguration;
|
||||||
import org.eclipse.cdt.core.index.IIndex;
|
import org.eclipse.cdt.core.index.IIndex;
|
||||||
import org.eclipse.cdt.core.parser.IParserLogService;
|
import org.eclipse.cdt.core.parser.IParserLogService;
|
||||||
import org.eclipse.cdt.core.parser.IScanner;
|
import org.eclipse.cdt.core.parser.IScanner;
|
||||||
|
@ -36,8 +37,8 @@ import org.eclipse.cdt.internal.core.pdom.dom.cpp.PDOMCPPLinkageFactory;
|
||||||
*/
|
*/
|
||||||
public class GPPLanguage extends AbstractCLikeLanguage {
|
public class GPPLanguage extends AbstractCLikeLanguage {
|
||||||
|
|
||||||
protected static final GPPScannerExtensionConfiguration CPP_GNU_SCANNER_EXTENSION = new GPPScannerExtensionConfiguration();
|
protected static final GPPScannerExtensionConfiguration CPP_GNU_SCANNER_EXTENSION= GPPScannerExtensionConfiguration.getInstance();
|
||||||
protected static final GPPParserExtensionConfiguration CPP_GNU_PARSER_EXTENSION = new GPPParserExtensionConfiguration();
|
protected static final GPPParserExtensionConfiguration CPP_GNU_PARSER_EXTENSION= GPPParserExtensionConfiguration.getInstance();
|
||||||
public static final String ID = CCorePlugin.PLUGIN_ID + ".g++"; //$NON-NLS-1$
|
public static final String ID = CCorePlugin.PLUGIN_ID + ".g++"; //$NON-NLS-1$
|
||||||
|
|
||||||
private static final GPPLanguage DEFAULT_INSTANCE = new GPPLanguage();
|
private static final GPPLanguage DEFAULT_INSTANCE = new GPPLanguage();
|
||||||
|
@ -70,9 +71,17 @@ public class GPPLanguage extends AbstractCLikeLanguage {
|
||||||
return CPP_GNU_SCANNER_EXTENSION;
|
return CPP_GNU_SCANNER_EXTENSION;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the extension configuration used for creating the parser.
|
||||||
|
* @since 5.1
|
||||||
|
*/
|
||||||
|
protected ICPPParserExtensionConfiguration getParserExtensionConfiguration() {
|
||||||
|
return CPP_GNU_PARSER_EXTENSION;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ISourceCodeParser createParser(IScanner scanner, ParserMode parserMode, IParserLogService logService, IIndex index) {
|
protected ISourceCodeParser createParser(IScanner scanner, ParserMode parserMode, IParserLogService logService, IIndex index) {
|
||||||
return new GNUCPPSourceParser(scanner, parserMode, logService, CPP_GNU_PARSER_EXTENSION, index);
|
return new GNUCPPSourceParser(scanner, parserMode, logService, getParserExtensionConfiguration(), index);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -11,22 +11,23 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.core.dom.parser;
|
package org.eclipse.cdt.core.dom.parser;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.parser.IMacro;
|
import org.eclipse.cdt.core.parser.IMacro;
|
||||||
|
import org.eclipse.cdt.core.parser.IToken;
|
||||||
import org.eclipse.cdt.core.parser.util.CharArrayIntMap;
|
import org.eclipse.cdt.core.parser.util.CharArrayIntMap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Abstract scanner extension configuration to help model C/C++ dialects.
|
* 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
|
* @since 4.0
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractScannerExtensionConfiguration implements IScannerExtensionConfiguration {
|
public abstract class AbstractScannerExtensionConfiguration implements IScannerExtensionConfiguration {
|
||||||
|
private static final IMacro[] EMPTY_MACRO_ARRAY = new IMacro[0];
|
||||||
|
private ArrayList<IMacro> fAddMacroList;
|
||||||
|
private IMacro[] fAddMacros;
|
||||||
|
private CharArrayIntMap fAddKeywords;
|
||||||
|
private CharArrayIntMap fAddPreprocessorKeywords;
|
||||||
|
|
||||||
protected static class MacroDefinition implements IMacro {
|
protected static class MacroDefinition implements IMacro {
|
||||||
private char[] fSignature;
|
private char[] fSignature;
|
||||||
private char[] fExpansion;
|
private char[] fExpansion;
|
||||||
|
@ -44,14 +45,9 @@ public abstract class AbstractScannerExtensionConfiguration implements IScannerE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public AbstractScannerExtensionConfiguration() {
|
||||||
* @deprecated see {@link IScannerExtensionConfiguration#initializeMacroValuesTo1()}
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public boolean initializeMacroValuesTo1() {
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @see org.eclipse.cdt.core.dom.parser.IScannerExtensionConfiguration#support$InIdentifiers()
|
* @see org.eclipse.cdt.core.dom.parser.IScannerExtensionConfiguration#support$InIdentifiers()
|
||||||
*/
|
*/
|
||||||
|
@ -59,6 +55,14 @@ public abstract class AbstractScannerExtensionConfiguration implements IScannerE
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
* @since 5.1
|
||||||
|
*/
|
||||||
|
public boolean supportAtSignInIdentifiers() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @see org.eclipse.cdt.core.dom.parser.IScannerExtensionConfiguration#supportAdditionalNumericLiteralSuffixes()
|
* @see org.eclipse.cdt.core.dom.parser.IScannerExtensionConfiguration#supportAdditionalNumericLiteralSuffixes()
|
||||||
*/
|
*/
|
||||||
|
@ -73,41 +77,82 @@ public abstract class AbstractScannerExtensionConfiguration implements IScannerE
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
public CharArrayIntMap getAdditionalPreprocessorKeywords() {
|
||||||
* @see org.eclipse.cdt.core.dom.parser.IScannerExtensionConfiguration#getAdditionalKeywords()
|
return fAddPreprocessorKeywords;
|
||||||
*/
|
}
|
||||||
public CharArrayIntMap getAdditionalKeywords() {
|
|
||||||
return null;
|
public CharArrayIntMap getAdditionalKeywords() {
|
||||||
|
return fAddKeywords;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public IMacro[] getAdditionalMacros() {
|
public IMacro[] getAdditionalMacros() {
|
||||||
return null;
|
if (fAddMacros == null) {
|
||||||
}
|
if (fAddMacroList == null) {
|
||||||
|
fAddMacros= EMPTY_MACRO_ARRAY;
|
||||||
/*
|
} else {
|
||||||
* @see org.eclipse.cdt.core.dom.parser.IScannerExtensionConfiguration#getAdditionalPreprocessorKeywords()
|
fAddMacros= fAddMacroList.toArray(new IMacro[fAddMacroList.size()]);
|
||||||
*/
|
}
|
||||||
public CharArrayIntMap getAdditionalPreprocessorKeywords() {
|
}
|
||||||
return null;
|
return fAddMacros;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper method to add an object style macro to the given map.
|
* Adds a macro to the list of additional macros.
|
||||||
|
* The macro can either be of object- or of function-style.
|
||||||
|
* <pre>
|
||||||
|
* Example:
|
||||||
|
* addMacro("max(a,b)", "(((a)>(b) ? (a) : (b))");
|
||||||
|
* </pre>
|
||||||
* @param signature the signature of the macro, see {@link IMacro#getSignature()}.
|
* @param signature the signature of the macro, see {@link IMacro#getSignature()}.
|
||||||
* @param value the macro value
|
* @param value the macro value
|
||||||
|
* @since 5.1
|
||||||
*/
|
*/
|
||||||
|
protected void addMacro(String signature, String value) {
|
||||||
|
if (fAddMacroList == null) {
|
||||||
|
fAddMacroList= new ArrayList<IMacro>();
|
||||||
|
}
|
||||||
|
fAddMacroList.add(new MacroDefinition(signature.toCharArray(), value.toCharArray()));
|
||||||
|
fAddMacros= null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a preprocessor keyword to the map of additional preprocessor keywords.
|
||||||
|
* @param name the name of the keyword
|
||||||
|
* @param tokenKind the kind of token the keyword is mapped to. See {@link IToken}.
|
||||||
|
* @since 5.1
|
||||||
|
*/
|
||||||
|
protected void addPreprocessorKeyword(char[] name, int tokenKind) {
|
||||||
|
if (fAddPreprocessorKeywords == null) {
|
||||||
|
fAddPreprocessorKeywords= new CharArrayIntMap(10, -1);
|
||||||
|
}
|
||||||
|
fAddPreprocessorKeywords.put(name, tokenKind);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a keyword to the map of additional keywords.
|
||||||
|
* @param name the name of the keyword
|
||||||
|
* @param tokenKind the kind of token the keyword is mapped to. See {@link IToken}.
|
||||||
|
* @since 5.1
|
||||||
|
*/
|
||||||
|
protected void addKeyword(char[] name, int tokenKind) {
|
||||||
|
if (fAddKeywords == null) {
|
||||||
|
fAddKeywords= new CharArrayIntMap(10, -1);
|
||||||
|
}
|
||||||
|
fAddKeywords.put(name, tokenKind);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated use {@link #addMacro(String, String)}
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
protected static IMacro createMacro(String signature, String value) {
|
protected static IMacro createMacro(String signature, String value) {
|
||||||
return new MacroDefinition(signature.toCharArray(), value.toCharArray());
|
return new MacroDefinition(signature.toCharArray(), value.toCharArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper method to add a function style macro to the given map.
|
* @deprecated use {@link #addMacro(String, String)}
|
||||||
*
|
|
||||||
* @param name the macro name
|
|
||||||
* @param value the macro value
|
|
||||||
* @param arguments the macro arguments
|
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
protected static IMacro createFunctionStyleMacro(String name, String value, String[] arguments) {
|
protected static IMacro createFunctionStyleMacro(String name, String value, String[] arguments) {
|
||||||
StringBuffer buf= new StringBuffer();
|
StringBuffer buf= new StringBuffer();
|
||||||
buf.append(name);
|
buf.append(name);
|
||||||
|
@ -123,4 +168,13 @@ public abstract class AbstractScannerExtensionConfiguration implements IScannerE
|
||||||
buf.getChars(0, signature.length, signature, 0);
|
buf.getChars(0, signature.length, signature, 0);
|
||||||
return new MacroDefinition(signature, value.toCharArray());
|
return new MacroDefinition(signature, value.toCharArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated see {@link IScannerExtensionConfiguration#initializeMacroValuesTo1()}
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public boolean initializeMacroValuesTo1() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,47 +21,52 @@ import org.eclipse.cdt.core.parser.Keywords;
|
||||||
import org.eclipse.cdt.core.parser.util.CharArrayIntMap;
|
import org.eclipse.cdt.core.parser.util.CharArrayIntMap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* Base class for all gnu scanner configurations. Provides gnu-specific macros and keywords.
|
||||||
|
* @since 5.0
|
||||||
*/
|
*/
|
||||||
public abstract class GNUScannerExtensionConfiguration extends AbstractScannerExtensionConfiguration {
|
public abstract class GNUScannerExtensionConfiguration extends AbstractScannerExtensionConfiguration {
|
||||||
|
private static GNUScannerExtensionConfiguration sInstance;
|
||||||
private static IMacro[] sAdditionalMacros= new IMacro[] {
|
|
||||||
createMacro("__complex__", "_Complex"), //$NON-NLS-1$ //$NON-NLS-2$
|
|
||||||
createMacro("__extension__", ""), //$NON-NLS-1$ //$NON-NLS-2$
|
|
||||||
createMacro("__imag__", "(int)"), //$NON-NLS-1$ //$NON-NLS-2$
|
|
||||||
createMacro("__null", "(void *)0"), //$NON-NLS-1$ //$NON-NLS-2$
|
|
||||||
createMacro("__real__", "(int)"), //$NON-NLS-1$ //$NON-NLS-2$
|
|
||||||
createMacro("__stdcall", ""), //$NON-NLS-1$ //$NON-NLS-2$
|
|
||||||
|
|
||||||
createMacro("__builtin_va_arg(ap,type)", "*(type *)ap"), //$NON-NLS-1$//$NON-NLS-2$
|
|
||||||
createMacro("__builtin_constant_p(exp)", "0") //$NON-NLS-1$//$NON-NLS-2$
|
|
||||||
};
|
|
||||||
|
|
||||||
public static IMacro[] getAdditionalGNUMacros() {
|
|
||||||
return sAdditionalMacros;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void addAdditionalGNUKeywords(CharArrayIntMap target) {
|
@SuppressWarnings("nls")
|
||||||
target.put(GCCKeywords.cp__ALIGNOF__, IGCCToken.t___alignof__ );
|
public GNUScannerExtensionConfiguration() {
|
||||||
target.put(GCCKeywords.cp__ALIGNOF__, IGCCToken.t___alignof__ );
|
addMacro("__complex__", "_Complex");
|
||||||
target.put(GCCKeywords.cp__ASM, IToken.t_asm);
|
addMacro("__extension__", "");
|
||||||
target.put(GCCKeywords.cp__ASM__, IToken.t_asm);
|
addMacro("__imag__", "(int)");
|
||||||
target.put(GCCKeywords.cp__ATTRIBUTE, IGCCToken.t__attribute__ );
|
addMacro("__null", "(void *)0");
|
||||||
target.put(GCCKeywords.cp__ATTRIBUTE__, IGCCToken.t__attribute__ );
|
addMacro("__real__", "(int)");
|
||||||
target.put(GCCKeywords.cp__CONST, IToken.t_const);
|
addMacro("__stdcall", "");
|
||||||
target.put(GCCKeywords.cp__CONST__, IToken.t_const);
|
|
||||||
target.put(GCCKeywords.cp__DECLSPEC, IGCCToken.t__declspec );
|
addMacro("__builtin_va_arg(ap,type)", "*(type *)ap");
|
||||||
target.put(GCCKeywords.cp__INLINE, IToken.t_inline);
|
addMacro("__builtin_constant_p(exp)", "0");
|
||||||
target.put(GCCKeywords.cp__INLINE__, IToken.t_inline);
|
|
||||||
target.put(GCCKeywords.cp__RESTRICT, IToken.t_restrict);
|
addPreprocessorKeyword(Keywords.cINCLUDE_NEXT, IPreprocessorDirective.ppInclude_next);
|
||||||
target.put(GCCKeywords.cp__RESTRICT__, IToken.t_restrict);
|
addPreprocessorKeyword(Keywords.cIMPORT, IPreprocessorDirective.ppImport);
|
||||||
target.put(GCCKeywords.cp__VOLATILE, IToken.t_volatile);
|
addPreprocessorKeyword(Keywords.cWARNING, IPreprocessorDirective.ppWarning);
|
||||||
target.put(GCCKeywords.cp__VOLATILE__, IToken.t_volatile);
|
addPreprocessorKeyword(Keywords.cIDENT, IPreprocessorDirective.ppIgnore);
|
||||||
target.put(GCCKeywords.cp__SIGNED, IToken.t_signed);
|
addPreprocessorKeyword(Keywords.cSCCS, IPreprocessorDirective.ppIgnore);
|
||||||
target.put(GCCKeywords.cp__SIGNED__, IToken.t_signed);
|
addPreprocessorKeyword(Keywords.cASSERT, IPreprocessorDirective.ppIgnore);
|
||||||
target.put(GCCKeywords.cp__TYPEOF, IGCCToken.t_typeof);
|
addPreprocessorKeyword(Keywords.cUNASSERT, IPreprocessorDirective.ppIgnore);
|
||||||
target.put(GCCKeywords.cp__TYPEOF__, IGCCToken.t_typeof);
|
|
||||||
target.put(GCCKeywords.cpTYPEOF, IGCCToken.t_typeof );
|
addKeyword(GCCKeywords.cp__ALIGNOF__, IGCCToken.t___alignof__ );
|
||||||
|
addKeyword(GCCKeywords.cp__ALIGNOF__, IGCCToken.t___alignof__ );
|
||||||
|
addKeyword(GCCKeywords.cp__ASM, IToken.t_asm);
|
||||||
|
addKeyword(GCCKeywords.cp__ASM__, IToken.t_asm);
|
||||||
|
addKeyword(GCCKeywords.cp__ATTRIBUTE, IGCCToken.t__attribute__ );
|
||||||
|
addKeyword(GCCKeywords.cp__ATTRIBUTE__, IGCCToken.t__attribute__ );
|
||||||
|
addKeyword(GCCKeywords.cp__CONST, IToken.t_const);
|
||||||
|
addKeyword(GCCKeywords.cp__CONST__, IToken.t_const);
|
||||||
|
addKeyword(GCCKeywords.cp__DECLSPEC, IGCCToken.t__declspec );
|
||||||
|
addKeyword(GCCKeywords.cp__INLINE, IToken.t_inline);
|
||||||
|
addKeyword(GCCKeywords.cp__INLINE__, IToken.t_inline);
|
||||||
|
addKeyword(GCCKeywords.cp__RESTRICT, IToken.t_restrict);
|
||||||
|
addKeyword(GCCKeywords.cp__RESTRICT__, IToken.t_restrict);
|
||||||
|
addKeyword(GCCKeywords.cp__VOLATILE, IToken.t_volatile);
|
||||||
|
addKeyword(GCCKeywords.cp__VOLATILE__, IToken.t_volatile);
|
||||||
|
addKeyword(GCCKeywords.cp__SIGNED, IToken.t_signed);
|
||||||
|
addKeyword(GCCKeywords.cp__SIGNED__, IToken.t_signed);
|
||||||
|
addKeyword(GCCKeywords.cp__TYPEOF, IGCCToken.t_typeof);
|
||||||
|
addKeyword(GCCKeywords.cp__TYPEOF__, IGCCToken.t_typeof);
|
||||||
|
addKeyword(GCCKeywords.cpTYPEOF, IGCCToken.t_typeof );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -73,25 +78,28 @@ public abstract class GNUScannerExtensionConfiguration extends AbstractScannerEx
|
||||||
public char[] supportAdditionalNumericLiteralSuffixes() {
|
public char[] supportAdditionalNumericLiteralSuffixes() {
|
||||||
return "ij".toCharArray(); //$NON-NLS-1$
|
return "ij".toCharArray(); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
/**
|
||||||
public IMacro[] getAdditionalMacros() {
|
* @deprecated simply derive from this class and use {@link #addMacro(String, String)} to
|
||||||
return sAdditionalMacros;
|
* add additional macros.
|
||||||
}
|
*/
|
||||||
|
@Deprecated
|
||||||
/*
|
public static IMacro[] getAdditionalGNUMacros() {
|
||||||
* @see org.eclipse.cdt.internal.core.parser.scanner2.IScannerExtensionConfiguration#getAdditionalPreprocessorKeywords()
|
if (sInstance == null) {
|
||||||
*/
|
sInstance= new GNUScannerExtensionConfiguration() {};
|
||||||
@Override
|
}
|
||||||
public CharArrayIntMap getAdditionalPreprocessorKeywords() {
|
return sInstance.getAdditionalMacros();
|
||||||
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);
|
* @deprecated simply derive from this class and use {@link #addKeyword(char[], int)} to
|
||||||
additionalPPKeywords.put(Keywords.cIDENT, IPreprocessorDirective.ppIgnore);
|
* add additional keywords.
|
||||||
additionalPPKeywords.put(Keywords.cSCCS, IPreprocessorDirective.ppIgnore);
|
*/
|
||||||
additionalPPKeywords.put(Keywords.cASSERT, IPreprocessorDirective.ppIgnore);
|
@Deprecated
|
||||||
additionalPPKeywords.put(Keywords.cUNASSERT, IPreprocessorDirective.ppIgnore);
|
public static void addAdditionalGNUKeywords(CharArrayIntMap target) {
|
||||||
return additionalPPKeywords;
|
if (sInstance == null) {
|
||||||
}
|
sInstance= new GNUScannerExtensionConfiguration() {};
|
||||||
|
}
|
||||||
|
target.putAll(sInstance.getAdditionalKeywords());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,19 +18,9 @@ import org.eclipse.cdt.core.parser.util.CharArrayIntMap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Scanner extension configuration interface.
|
* Scanner extension configuration interface.
|
||||||
*
|
*
|
||||||
* <p>
|
* @noimplement This interface is not intended to be implemented by clients. Clients can subclass
|
||||||
* This interface is not intended to be implemented directly. Clients should
|
* {@link AbstractScannerExtensionConfiguration}, instead.
|
||||||
* subclass {@link AbstractScannerExtensionConfiguration} 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>
|
|
||||||
*
|
|
||||||
* @author jcamelon
|
|
||||||
*/
|
*/
|
||||||
public interface IScannerExtensionConfiguration {
|
public interface IScannerExtensionConfiguration {
|
||||||
|
|
||||||
|
@ -50,6 +40,14 @@ public interface IScannerExtensionConfiguration {
|
||||||
*/
|
*/
|
||||||
public boolean support$InIdentifiers();
|
public boolean support$InIdentifiers();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Support for extension "At Signs in Identifier Names". If enabled, the '@' sign is treated as part of
|
||||||
|
* identifiers.
|
||||||
|
* @return <code>true</code>, if @ should be supported in identifiers
|
||||||
|
* @since 5.1
|
||||||
|
*/
|
||||||
|
public boolean supportAtSignInIdentifiers();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Support for (deprecated) GNU minimum and maximum operators (<code><?</code>
|
* Support for (deprecated) GNU minimum and maximum operators (<code><?</code>
|
||||||
* and <code>>?</code>).
|
* and <code>>?</code>).
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2007 Wind River Systems, Inc. and others.
|
* Copyright (c) 2007, 2008 Wind River Systems, Inc. and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -7,6 +7,7 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Anton Leherbauer (Wind River Systems) - initial API and implementation
|
* Anton Leherbauer (Wind River Systems) - initial API and implementation
|
||||||
|
* Markus Schorn (Wind River Systems)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.core.dom.parser.c;
|
package org.eclipse.cdt.core.dom.parser.c;
|
||||||
|
|
||||||
|
@ -17,14 +18,6 @@ import org.eclipse.cdt.internal.core.dom.parser.GCCBuiltinSymbolProvider;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Abstract C parser extension configuration to help model C dialects.
|
* 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
|
* @since 4.0
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractCParserExtensionConfiguration implements ICParserExtensionConfiguration {
|
public abstract class AbstractCParserExtensionConfiguration implements ICParserExtensionConfiguration {
|
||||||
|
@ -95,4 +88,11 @@ public abstract class AbstractCParserExtensionConfiguration implements ICParserE
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
* @since 5.1
|
||||||
|
*/
|
||||||
|
public boolean supportParameterInfoBlock() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,8 +6,9 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM Rational Software - Initial API and implementation
|
* IBM Rational Software - Initial API and implementation
|
||||||
* Ed Swartz (Nokia)
|
* Ed Swartz (Nokia)
|
||||||
|
* Markus Schorn (Wind River Systems)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.core.dom.parser.c;
|
package org.eclipse.cdt.core.dom.parser.c;
|
||||||
|
|
||||||
|
@ -16,9 +17,16 @@ import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.GCCBuiltinSymbolProvider;
|
import org.eclipse.cdt.internal.core.dom.parser.GCCBuiltinSymbolProvider;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* Configures the parser for c-source code as accepted by gcc.
|
||||||
*/
|
*/
|
||||||
public class GCCParserExtensionConfiguration extends AbstractCParserExtensionConfiguration {
|
public class GCCParserExtensionConfiguration extends AbstractCParserExtensionConfiguration {
|
||||||
|
private static GCCParserExtensionConfiguration sInstance= new GCCParserExtensionConfiguration();
|
||||||
|
/**
|
||||||
|
* @since 5.1
|
||||||
|
*/
|
||||||
|
public static GCCParserExtensionConfiguration getInstance() {
|
||||||
|
return sInstance;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @see org.eclipse.cdt.core.dom.parser.c.AbstractCParserExtensionConfiguration#supportStatementsInExpressions()
|
* @see org.eclipse.cdt.core.dom.parser.c.AbstractCParserExtensionConfiguration#supportStatementsInExpressions()
|
||||||
|
|
|
@ -13,24 +13,22 @@
|
||||||
package org.eclipse.cdt.core.dom.parser.c;
|
package org.eclipse.cdt.core.dom.parser.c;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.parser.GNUScannerExtensionConfiguration;
|
import org.eclipse.cdt.core.dom.parser.GNUScannerExtensionConfiguration;
|
||||||
import org.eclipse.cdt.core.parser.IMacro;
|
|
||||||
import org.eclipse.cdt.core.parser.util.CharArrayIntMap;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* Configures the preprocessor for parsing c-sources as accepted by gcc.
|
||||||
*/
|
*/
|
||||||
public class GCCScannerExtensionConfiguration extends GNUScannerExtensionConfiguration {
|
public class GCCScannerExtensionConfiguration extends GNUScannerExtensionConfiguration {
|
||||||
|
|
||||||
private static IMacro[] sAdditionalMacros;
|
private static GCCScannerExtensionConfiguration sInstance= new GCCScannerExtensionConfiguration();
|
||||||
private static CharArrayIntMap sAdditionalKeywords;
|
/**
|
||||||
static {
|
* @since 5.1
|
||||||
final IMacro[] macros = GNUScannerExtensionConfiguration.getAdditionalGNUMacros();
|
*/
|
||||||
sAdditionalMacros= new IMacro[macros.length+1];
|
public static GCCScannerExtensionConfiguration getInstance() {
|
||||||
System.arraycopy(macros, 0, sAdditionalMacros, 0, macros.length);
|
return sInstance;
|
||||||
sAdditionalMacros[macros.length]= createMacro("_Pragma(arg)", ""); //$NON-NLS-1$//$NON-NLS-2$
|
}
|
||||||
|
|
||||||
sAdditionalKeywords= new CharArrayIntMap(10, -1);
|
public GCCScannerExtensionConfiguration() {
|
||||||
GNUScannerExtensionConfiguration.addAdditionalGNUKeywords(sAdditionalKeywords);
|
addMacro("_Pragma(arg)", ""); //$NON-NLS-1$//$NON-NLS-2$
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@ -40,22 +38,4 @@ public class GCCScannerExtensionConfiguration extends GNUScannerExtensionConfigu
|
||||||
public boolean supportMinAndMaxOperators() {
|
public boolean supportMinAndMaxOperators() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.internal.core.parser.scanner2.IScannerConfiguration#getAdditionalMacros()
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public IMacro[] getAdditionalMacros() {
|
|
||||||
return sAdditionalMacros;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.internal.core.parser.scanner2.IScannerConfiguration#getAdditionalKeywords()
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public CharArrayIntMap getAdditionalKeywords() {
|
|
||||||
return sAdditionalKeywords;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,9 +6,10 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM Rational Software - Initial API and implementation
|
* IBM Rational Software - Initial API and implementation
|
||||||
* Ed Swartz (Nokia)
|
* Ed Swartz (Nokia)
|
||||||
* Anton Leherbauer (Wind River Systems)
|
* Anton Leherbauer (Wind River Systems)
|
||||||
|
* Markus Schorn (Wind River Systems)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.core.dom.parser.c;
|
package org.eclipse.cdt.core.dom.parser.c;
|
||||||
|
|
||||||
|
@ -17,20 +18,10 @@ import org.eclipse.cdt.core.dom.parser.IBuiltinBindingsProvider;
|
||||||
/**
|
/**
|
||||||
* C parser extension configuration interface.
|
* C parser extension configuration interface.
|
||||||
*
|
*
|
||||||
* <p>
|
* @noimplement This interface is not intended to be implemented by clients.
|
||||||
* This interface is not intended to be implemented directly. Clients should
|
* Clients can subclass {@link AbstractCParserExtensionConfiguration} instead.
|
||||||
* 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"
|
* @see "http://gcc.gnu.org/onlinedocs/gcc/C-Extensions.html"
|
||||||
*
|
|
||||||
* @author jcamelon
|
|
||||||
* @since 4.0
|
* @since 4.0
|
||||||
*/
|
*/
|
||||||
public interface ICParserExtensionConfiguration {
|
public interface ICParserExtensionConfiguration {
|
||||||
|
@ -78,17 +69,6 @@ public interface ICParserExtensionConfiguration {
|
||||||
*/
|
*/
|
||||||
public boolean supportKnRC();
|
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.
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public boolean supportGCCOtherBuiltinSymbols();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* See http://gcc.gnu.org/onlinedocs/gcc/Attribute-Syntax.html for more
|
* See http://gcc.gnu.org/onlinedocs/gcc/Attribute-Syntax.html for more
|
||||||
* information on GCC's Attribute Specifiers.
|
* information on GCC's Attribute Specifiers.
|
||||||
|
@ -113,4 +93,23 @@ public interface ICParserExtensionConfiguration {
|
||||||
* <code>null</code>
|
* <code>null</code>
|
||||||
*/
|
*/
|
||||||
public IBuiltinBindingsProvider getBuiltinBindingsProvider();
|
public IBuiltinBindingsProvider getBuiltinBindingsProvider();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Skips information in brackets provided at the beginning of a parameter declaration:
|
||||||
|
* <br>
|
||||||
|
* void accelerate([proc=marsh] const Speed &data);
|
||||||
|
* @since 5.1
|
||||||
|
*/
|
||||||
|
public boolean supportParameterInfoBlock();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public boolean supportGCCOtherBuiltinSymbols();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2007 Wind River Systems, Inc. and others.
|
* Copyright (c) 2007, 2008 Wind River Systems, Inc. and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -7,6 +7,7 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Anton Leherbauer (Wind River Systems) - initial API and implementation
|
* Anton Leherbauer (Wind River Systems) - initial API and implementation
|
||||||
|
* Markus Schorn (Wind River Systems)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.core.dom.parser.cpp;
|
package org.eclipse.cdt.core.dom.parser.cpp;
|
||||||
|
@ -19,13 +20,6 @@ import org.eclipse.cdt.internal.core.dom.parser.GCCBuiltinSymbolProvider;
|
||||||
/**
|
/**
|
||||||
* Abstract C++ parser extension configuration to help model C++ dialects.
|
* 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
|
* @since 4.0
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractCPPParserExtensionConfiguration implements ICPPParserExtensionConfiguration {
|
public abstract class AbstractCPPParserExtensionConfiguration implements ICPPParserExtensionConfiguration {
|
||||||
|
@ -121,6 +115,14 @@ public abstract class AbstractCPPParserExtensionConfiguration implements ICPPPar
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
* @since 5.1
|
||||||
|
*/
|
||||||
|
public boolean supportParameterInfoBlock() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @see org.eclipse.cdt.core.dom.parser.cpp.ICPPParserExtensionConfiguration#getBuiltinBindingsProvider()
|
* @see org.eclipse.cdt.core.dom.parser.cpp.ICPPParserExtensionConfiguration#getBuiltinBindingsProvider()
|
||||||
*/
|
*/
|
||||||
|
@ -130,5 +132,4 @@ public abstract class AbstractCPPParserExtensionConfiguration implements ICPPPar
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,8 +6,9 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM Rational Software - Initial API and implementation
|
* IBM Rational Software - Initial API and implementation
|
||||||
* Ed Swartz (Nokia)
|
* Ed Swartz (Nokia)
|
||||||
|
* Markus Schorn (Wind River Systems)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.core.dom.parser.cpp;
|
package org.eclipse.cdt.core.dom.parser.cpp;
|
||||||
|
|
||||||
|
@ -16,9 +17,16 @@ import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.GCCBuiltinSymbolProvider;
|
import org.eclipse.cdt.internal.core.dom.parser.GCCBuiltinSymbolProvider;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* Configures the parser for c++-sources as accepted by g++.
|
||||||
*/
|
*/
|
||||||
public class GPPParserExtensionConfiguration extends AbstractCPPParserExtensionConfiguration {
|
public class GPPParserExtensionConfiguration extends AbstractCPPParserExtensionConfiguration {
|
||||||
|
private static GPPParserExtensionConfiguration sInstance= new GPPParserExtensionConfiguration();
|
||||||
|
/**
|
||||||
|
* @since 5.1
|
||||||
|
*/
|
||||||
|
public static GPPParserExtensionConfiguration getInstance() {
|
||||||
|
return sInstance;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @see org.eclipse.cdt.core.dom.parser.cpp.AbstractCPPParserExtensionConfiguration#allowRestrictPointerOperators()
|
* @see org.eclipse.cdt.core.dom.parser.cpp.AbstractCPPParserExtensionConfiguration#allowRestrictPointerOperators()
|
||||||
|
|
|
@ -16,20 +16,24 @@ package org.eclipse.cdt.core.dom.parser.cpp;
|
||||||
import org.eclipse.cdt.core.dom.parser.GNUScannerExtensionConfiguration;
|
import org.eclipse.cdt.core.dom.parser.GNUScannerExtensionConfiguration;
|
||||||
import org.eclipse.cdt.core.parser.IToken;
|
import org.eclipse.cdt.core.parser.IToken;
|
||||||
import org.eclipse.cdt.core.parser.Keywords;
|
import org.eclipse.cdt.core.parser.Keywords;
|
||||||
import org.eclipse.cdt.core.parser.util.CharArrayIntMap;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* Configures the preprocessor for c++-sources as accepted by g++.
|
||||||
*/
|
*/
|
||||||
public class GPPScannerExtensionConfiguration extends GNUScannerExtensionConfiguration {
|
public class GPPScannerExtensionConfiguration extends GNUScannerExtensionConfiguration {
|
||||||
|
|
||||||
private static CharArrayIntMap sAdditionalKeywords;
|
private static GPPScannerExtensionConfiguration sInstance= new GPPScannerExtensionConfiguration();
|
||||||
static {
|
/**
|
||||||
sAdditionalKeywords= new CharArrayIntMap(10, -1);
|
* @since 5.1
|
||||||
GNUScannerExtensionConfiguration.addAdditionalGNUKeywords(sAdditionalKeywords);
|
*/
|
||||||
sAdditionalKeywords.put( Keywords.cRESTRICT, IToken.t_restrict );
|
public static GPPScannerExtensionConfiguration getInstance() {
|
||||||
sAdditionalKeywords.put( Keywords.c_COMPLEX, IToken.t__Complex );
|
return sInstance;
|
||||||
sAdditionalKeywords.put( Keywords.c_IMAGINARY, IToken.t__Imaginary );
|
}
|
||||||
|
|
||||||
|
public GPPScannerExtensionConfiguration() {
|
||||||
|
addKeyword(Keywords.cRESTRICT, IToken.t_restrict);
|
||||||
|
addKeyword(Keywords.c_COMPLEX, IToken.t__Complex);
|
||||||
|
addKeyword(Keywords.c_IMAGINARY, IToken.t__Imaginary);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@ -39,12 +43,4 @@ public class GPPScannerExtensionConfiguration extends GNUScannerExtensionConfigu
|
||||||
public boolean supportMinAndMaxOperators() {
|
public boolean supportMinAndMaxOperators() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.internal.core.parser.scanner2.IScannerConfiguration#getAdditionalKeywords()
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public CharArrayIntMap getAdditionalKeywords() {
|
|
||||||
return sAdditionalKeywords;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,9 +6,10 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM Rational Software - Initial API and implementation
|
* IBM Rational Software - Initial API and implementation
|
||||||
* Ed Swartz (Nokia)
|
* Ed Swartz (Nokia)
|
||||||
* Anton Leherbauer (Wind River Systems)
|
* Anton Leherbauer (Wind River Systems)
|
||||||
|
* Markus Schorn (Wind River Systems)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.core.dom.parser.cpp;
|
package org.eclipse.cdt.core.dom.parser.cpp;
|
||||||
|
|
||||||
|
@ -18,21 +19,11 @@ import org.eclipse.cdt.core.dom.parser.IScannerExtensionConfiguration;
|
||||||
/**
|
/**
|
||||||
* C++ parser extension configuration interface.
|
* C++ parser extension configuration interface.
|
||||||
*
|
*
|
||||||
* <p>
|
* @noimplement This interface is not intended to be implemented by clients.
|
||||||
* This interface is not intended to be implemented directly. Clients should
|
* Clients can subclass {@link AbstractCPPParserExtensionConfiguration} instead.
|
||||||
* 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-Extensions.html"
|
||||||
* @see "http://gcc.gnu.org/onlinedocs/gcc/C_002b_002b-Extensions.html"
|
* @see "http://gcc.gnu.org/onlinedocs/gcc/C_002b_002b-Extensions.html"
|
||||||
*
|
|
||||||
* @author jcamelon
|
|
||||||
* @since 4.0
|
* @since 4.0
|
||||||
*/
|
*/
|
||||||
public interface ICPPParserExtensionConfiguration {
|
public interface ICPPParserExtensionConfiguration {
|
||||||
|
@ -76,16 +67,6 @@ public interface ICPPParserExtensionConfiguration {
|
||||||
*/
|
*/
|
||||||
public boolean supportComplexNumbers();
|
public boolean supportComplexNumbers();
|
||||||
|
|
||||||
/**
|
|
||||||
* Support for the GNU <code>__restrict__</code> keyword.
|
|
||||||
*
|
|
||||||
* @return <code>true</code> if support for the extension should be
|
|
||||||
* enabled
|
|
||||||
* @deprecated configure extra keywords, via {@link IScannerExtensionConfiguration#getAdditionalKeywords()}
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public boolean supportRestrictKeyword();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Support for GNU long long types.
|
* Support for GNU long long types.
|
||||||
*
|
*
|
||||||
|
@ -129,16 +110,6 @@ public interface ICPPParserExtensionConfiguration {
|
||||||
*/
|
*/
|
||||||
public boolean supportKnRC();
|
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.
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public boolean supportGCCOtherBuiltinSymbols();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* See http://gcc.gnu.org/onlinedocs/gcc/Attribute-Syntax.html for more
|
* See http://gcc.gnu.org/onlinedocs/gcc/Attribute-Syntax.html for more
|
||||||
* information on GCC's Attribute Specifiers.
|
* information on GCC's Attribute Specifiers.
|
||||||
|
@ -163,4 +134,24 @@ public interface ICPPParserExtensionConfiguration {
|
||||||
* <code>null</code>
|
* <code>null</code>
|
||||||
*/
|
*/
|
||||||
public IBuiltinBindingsProvider getBuiltinBindingsProvider();
|
public IBuiltinBindingsProvider getBuiltinBindingsProvider();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Skips information in brackets provided at the beginning of a parameter declaration:
|
||||||
|
* <br>
|
||||||
|
* void accelerate([proc=marsh] const Speed &data);
|
||||||
|
* @since 5.1
|
||||||
|
*/
|
||||||
|
public boolean supportParameterInfoBlock();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated configure extra keywords, via {@link IScannerExtensionConfiguration#getAdditionalKeywords()}
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public boolean supportRestrictKeyword();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated use {@link #getBuiltinBindingsProvider()} instead.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public boolean supportGCCOtherBuiltinSymbols();
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2008 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:
|
||||||
|
* Markus Schorn - initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.core.dom.parser.cpp;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Configures the parser to accept POP C++,
|
||||||
|
* see <a href=http://gridgroup.tic.hefr.ch/popc/index.php/Documentation>Documentation</a>
|
||||||
|
* @since 5.1
|
||||||
|
*/
|
||||||
|
public class POPCPPParserExtensionConfiguration extends GPPParserExtensionConfiguration {
|
||||||
|
private static POPCPPParserExtensionConfiguration sInstance= new POPCPPParserExtensionConfiguration();
|
||||||
|
public static POPCPPParserExtensionConfiguration getInstance() {
|
||||||
|
return sInstance;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean supportParameterInfoBlock() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,39 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2008 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:
|
||||||
|
* Markus Schorn - initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.core.dom.parser.cpp;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.parser.IToken;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Configures the preprocessor for parsing POP C++,
|
||||||
|
* see <a href=http://gridgroup.tic.hefr.ch/popc/index.php/Documentation>Documentation</a>
|
||||||
|
* @since 5.1
|
||||||
|
*/
|
||||||
|
public class POPCPPScannerExtensionConfiguration extends GPPScannerExtensionConfiguration {
|
||||||
|
private static POPCPPScannerExtensionConfiguration sInstance= new POPCPPScannerExtensionConfiguration();
|
||||||
|
public static POPCPPScannerExtensionConfiguration getInstance() {
|
||||||
|
return sInstance;
|
||||||
|
}
|
||||||
|
@SuppressWarnings("nls")
|
||||||
|
protected POPCPPScannerExtensionConfiguration() {
|
||||||
|
addMacro("@pack(...)", "");
|
||||||
|
addMacro("__concat__(x,y)", "x##y");
|
||||||
|
addMacro("__xconcat__(x,y)", "__concat__(x,y)");
|
||||||
|
addMacro("@", "; void __xconcat__(@, __LINE__)()");
|
||||||
|
|
||||||
|
addKeyword("parclass".toCharArray(), IToken.t_class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean supportAtSignInIdentifiers() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
|
@ -92,6 +92,7 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
||||||
protected final boolean supportKnRC;
|
protected final boolean supportKnRC;
|
||||||
protected final boolean supportAttributeSpecifiers;
|
protected final boolean supportAttributeSpecifiers;
|
||||||
protected final boolean supportDeclspecSpecifiers;
|
protected final boolean supportDeclspecSpecifiers;
|
||||||
|
protected boolean supportParameterInfoBlock;
|
||||||
protected final IBuiltinBindingsProvider builtinBindingsProvider;
|
protected final IBuiltinBindingsProvider builtinBindingsProvider;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -124,7 +125,7 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
||||||
this.supportDeclspecSpecifiers = supportDeclspecSpecifiers;
|
this.supportDeclspecSpecifiers = supportDeclspecSpecifiers;
|
||||||
this.builtinBindingsProvider= builtinBindingsProvider;
|
this.builtinBindingsProvider= builtinBindingsProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
private AbstractParserLogService wrapLogService(IParserLogService logService) {
|
private AbstractParserLogService wrapLogService(IParserLogService logService) {
|
||||||
if (logService instanceof AbstractParserLogService) {
|
if (logService instanceof AbstractParserLogService) {
|
||||||
return (AbstractParserLogService) logService;
|
return (AbstractParserLogService) logService;
|
||||||
|
@ -2188,4 +2189,23 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void skipBrackets(int left, int right) throws EndOfFileException, BacktrackException {
|
||||||
|
consume(left);
|
||||||
|
int nesting= 0;
|
||||||
|
while(true) {
|
||||||
|
final int lt1= LT(1);
|
||||||
|
if (lt1 == IToken.tEOC)
|
||||||
|
throwBacktrack(LA(1));
|
||||||
|
|
||||||
|
consume();
|
||||||
|
if (lt1 == left) {
|
||||||
|
nesting++;
|
||||||
|
} else if (lt1 == right) {
|
||||||
|
if (--nesting < 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -146,6 +146,7 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
config.supportDeclspecSpecifiers(),
|
config.supportDeclspecSpecifiers(),
|
||||||
config.getBuiltinBindingsProvider());
|
config.getBuiltinBindingsProvider());
|
||||||
supportGCCStyleDesignators = config.supportGCCStyleDesignators();
|
supportGCCStyleDesignators = config.supportGCCStyleDesignators();
|
||||||
|
supportParameterInfoBlock= config.supportParameterInfoBlock();
|
||||||
this.index= index;
|
this.index= index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -434,22 +435,24 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
endOffset= figureEndOffset(declSpec, declarators);
|
endOffset= figureEndOffset(declSpec, declarators);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
insertSemi= true;
|
if (declOption != DeclarationOptions.LOCAL) {
|
||||||
if (markBeforDtor == null || !isOnSameLine(calculateEndOffset(declSpec), markBeforDtor.getOffset())) {
|
insertSemi= true;
|
||||||
if (markBeforDtor != null) {
|
if (markBeforDtor == null || !isOnSameLine(calculateEndOffset(declSpec), markBeforDtor.getOffset())) {
|
||||||
backup(markBeforDtor);
|
if (markBeforDtor != null) {
|
||||||
|
backup(markBeforDtor);
|
||||||
|
}
|
||||||
|
declarators= IASTDeclarator.EMPTY_DECLARATOR_ARRAY;
|
||||||
|
endOffset= calculateEndOffset(declSpec);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
endOffset= figureEndOffset(declSpec, declarators);
|
||||||
|
if (lt1 == 0 || !isOnSameLine(endOffset, LA(1).getOffset())) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (declarators.length == 1 && declarators[0] instanceof IASTFunctionDeclarator) {
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
declarators= IASTDeclarator.EMPTY_DECLARATOR_ARRAY;
|
|
||||||
endOffset= calculateEndOffset(declSpec);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
endOffset= figureEndOffset(declSpec, declarators);
|
|
||||||
if (lt1 == 0 || !isOnSameLine(endOffset, LA(1).getOffset())) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (declarators.length == 1 && declarators[0] instanceof IASTFunctionDeclarator) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
throwBacktrack(LA(1));
|
throwBacktrack(LA(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2014,7 +2017,10 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
protected IASTParameterDeclaration parameterDeclaration(DeclarationOptions option) throws BacktrackException, EndOfFileException {
|
protected IASTParameterDeclaration parameterDeclaration(DeclarationOptions option) throws BacktrackException, EndOfFileException {
|
||||||
final IToken current = LA(1);
|
final IToken current = LA(1);
|
||||||
int startingOffset = current.getOffset();
|
int startingOffset = current.getOffset();
|
||||||
|
if (current.getType() == IToken.tLBRACKET && supportParameterInfoBlock) {
|
||||||
|
skipBrackets(IToken.tLBRACKET, IToken.tRBRACKET);
|
||||||
|
}
|
||||||
|
|
||||||
IASTDeclSpecifier declSpec = null;
|
IASTDeclSpecifier declSpec = null;
|
||||||
IASTDeclarator declarator = null;
|
IASTDeclarator declarator = null;
|
||||||
IASTDeclSpecifier altDeclSpec = null;
|
IASTDeclSpecifier altDeclSpec = null;
|
||||||
|
|
|
@ -1775,6 +1775,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
supportExtendedTemplateSyntax = config.supportExtendedTemplateSyntax();
|
supportExtendedTemplateSyntax = config.supportExtendedTemplateSyntax();
|
||||||
supportMinAndMaxOperators = config.supportMinAndMaxOperators();
|
supportMinAndMaxOperators = config.supportMinAndMaxOperators();
|
||||||
supportLongLong = config.supportLongLongs();
|
supportLongLong = config.supportLongLongs();
|
||||||
|
supportParameterInfoBlock= config.supportParameterInfoBlock();
|
||||||
this.index= index;
|
this.index= index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2558,26 +2559,28 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
case IToken.tLBRACE:
|
case IToken.tLBRACE:
|
||||||
return functionDefinition(firstOffset, declSpec, declarators, false);
|
return functionDefinition(firstOffset, declSpec, declarators, false);
|
||||||
default:
|
default:
|
||||||
insertSemi= true;
|
if (declOption != DeclarationOptions.LOCAL) {
|
||||||
if (validWithoutDtor(declOption, declSpec)) {
|
insertSemi= true;
|
||||||
// class definition without semicolon
|
if (validWithoutDtor(declOption, declSpec)) {
|
||||||
if (markBeforDtor == null || !isOnSameLine(calculateEndOffset(declSpec), markBeforDtor.getOffset())) {
|
// class definition without semicolon
|
||||||
if (markBeforDtor != null) {
|
if (markBeforDtor == null || !isOnSameLine(calculateEndOffset(declSpec), markBeforDtor.getOffset())) {
|
||||||
backup(markBeforDtor);
|
if (markBeforDtor != null) {
|
||||||
|
backup(markBeforDtor);
|
||||||
|
}
|
||||||
|
declarators= IASTDeclarator.EMPTY_DECLARATOR_ARRAY;
|
||||||
|
endOffset= calculateEndOffset(declSpec);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
declarators= IASTDeclarator.EMPTY_DECLARATOR_ARRAY;
|
}
|
||||||
endOffset= calculateEndOffset(declSpec);
|
endOffset= figureEndOffset(declSpec, declarators);
|
||||||
|
if (lt1 == 0 || !isOnSameLine(endOffset, LA(1).getOffset())) {
|
||||||
|
insertSemi= true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
if (declarators.length == 1 && declarators[0] instanceof IASTFunctionDeclarator) {
|
||||||
endOffset= figureEndOffset(declSpec, declarators);
|
break;
|
||||||
if (lt1 == 0 || !isOnSameLine(endOffset, LA(1).getOffset())) {
|
}
|
||||||
insertSemi= true;
|
}
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (declarators.length == 1 && declarators[0] instanceof IASTFunctionDeclarator) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
throwBacktrack(LA(1));
|
throwBacktrack(LA(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2756,6 +2759,10 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
protected ICPPASTParameterDeclaration parameterDeclaration() throws BacktrackException, EndOfFileException {
|
protected ICPPASTParameterDeclaration parameterDeclaration() throws BacktrackException, EndOfFileException {
|
||||||
final int startOffset= LA(1).getOffset();
|
final int startOffset= LA(1).getOffset();
|
||||||
|
|
||||||
|
if (LT(1) == IToken.tLBRACKET && supportParameterInfoBlock) {
|
||||||
|
skipBrackets(IToken.tLBRACKET, IToken.tRBRACKET);
|
||||||
|
}
|
||||||
|
|
||||||
IASTDeclSpecifier declSpec;
|
IASTDeclSpecifier declSpec;
|
||||||
IASTDeclarator declarator;
|
IASTDeclarator declarator;
|
||||||
try {
|
try {
|
||||||
|
@ -2776,7 +2783,6 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
return parm;
|
return parm;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected ICPPASTParameterDeclaration createParameterDeclaration() {
|
protected ICPPASTParameterDeclaration createParameterDeclaration() {
|
||||||
return new CPPASTParameterDeclaration();
|
return new CPPASTParameterDeclaration();
|
||||||
}
|
}
|
||||||
|
|
|
@ -147,7 +147,8 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable {
|
||||||
IScannerExtensionConfiguration configuration, ICodeReaderFactory readerFactory) {
|
IScannerExtensionConfiguration configuration, ICodeReaderFactory readerFactory) {
|
||||||
fLog = log;
|
fLog = log;
|
||||||
fAdditionalNumericLiteralSuffixes= nonNull(configuration.supportAdditionalNumericLiteralSuffixes());
|
fAdditionalNumericLiteralSuffixes= nonNull(configuration.supportAdditionalNumericLiteralSuffixes());
|
||||||
fLexOptions.fSupportDollarInitializers= configuration.support$InIdentifiers();
|
fLexOptions.fSupportDollarInIdentifiers= configuration.support$InIdentifiers();
|
||||||
|
fLexOptions.fSupportAtSignInIdentifiers= configuration.supportAtSignInIdentifiers();
|
||||||
fLexOptions.fSupportMinAndMax = configuration.supportMinAndMaxOperators();
|
fLexOptions.fSupportMinAndMax = configuration.supportMinAndMaxOperators();
|
||||||
fKeywords= new CharArrayIntMap(40, -1);
|
fKeywords= new CharArrayIntMap(40, -1);
|
||||||
fPPKeywords= new CharArrayIntMap(40, -1);
|
fPPKeywords= new CharArrayIntMap(40, -1);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2007 Wind River Systems, Inc. and others.
|
* Copyright (c) 2007, 2008 Wind River Systems, Inc. and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -46,7 +46,8 @@ final public class Lexer {
|
||||||
private static final int ORIGIN_LEXER = OffsetLimitReachedException.ORIGIN_LEXER;
|
private static final int ORIGIN_LEXER = OffsetLimitReachedException.ORIGIN_LEXER;
|
||||||
|
|
||||||
public final static class LexerOptions implements Cloneable {
|
public final static class LexerOptions implements Cloneable {
|
||||||
public boolean fSupportDollarInitializers= true;
|
public boolean fSupportDollarInIdentifiers= true;
|
||||||
|
public boolean fSupportAtSignInIdentifiers= true;
|
||||||
public boolean fSupportMinAndMax= true;
|
public boolean fSupportMinAndMax= true;
|
||||||
public boolean fCreateImageLocations= true;
|
public boolean fCreateImageLocations= true;
|
||||||
|
|
||||||
|
@ -357,7 +358,12 @@ final public class Lexer {
|
||||||
return identifier(start, 1);
|
return identifier(start, 1);
|
||||||
|
|
||||||
case '$':
|
case '$':
|
||||||
if (fOptions.fSupportDollarInitializers) {
|
if (fOptions.fSupportDollarInIdentifiers) {
|
||||||
|
return identifier(start, 1);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case '@':
|
||||||
|
if (fOptions.fSupportAtSignInIdentifiers) {
|
||||||
return identifier(start, 1);
|
return identifier(start, 1);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -820,7 +826,10 @@ final public class Lexer {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case '$':
|
case '$':
|
||||||
isPartOfIdentifier= fOptions.fSupportDollarInitializers;
|
isPartOfIdentifier= fOptions.fSupportDollarInIdentifiers;
|
||||||
|
break;
|
||||||
|
case '@':
|
||||||
|
isPartOfIdentifier= fOptions.fSupportAtSignInIdentifiers;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case '{': case '}': case '[': case ']': case '#': case '(': case ')': case '<': case '>':
|
case '{': case '}': case '[': case ']': case '#': case '(': case ')': case '<': case '>':
|
||||||
|
|
|
@ -50,8 +50,8 @@ import org.eclipse.core.runtime.content.IContentType;
|
||||||
*/
|
*/
|
||||||
public class InternalASTServiceProvider implements IASTServiceProvider {
|
public class InternalASTServiceProvider implements IASTServiceProvider {
|
||||||
|
|
||||||
protected static final GCCScannerExtensionConfiguration C_GNU_SCANNER_EXTENSION = new GCCScannerExtensionConfiguration();
|
protected static final GCCScannerExtensionConfiguration C_GNU_SCANNER_EXTENSION = GCCScannerExtensionConfiguration.getInstance();
|
||||||
protected static final GPPScannerExtensionConfiguration CPP_GNU_SCANNER_EXTENSION = new GPPScannerExtensionConfiguration();
|
protected static final GPPScannerExtensionConfiguration CPP_GNU_SCANNER_EXTENSION = GPPScannerExtensionConfiguration.getInstance();
|
||||||
private static final String[] dialects = {
|
private static final String[] dialects = {
|
||||||
"C99", //$NON-NLS-1$
|
"C99", //$NON-NLS-1$
|
||||||
"C++98", //$NON-NLS-1$
|
"C++98", //$NON-NLS-1$
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package org.eclipse.cdt.core.dom.lrparser;
|
package org.eclipse.cdt.core.dom.lrparser;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.parser.IScannerExtensionConfiguration;
|
import org.eclipse.cdt.core.dom.parser.AbstractScannerExtensionConfiguration;
|
||||||
import org.eclipse.cdt.core.parser.IMacro;
|
import org.eclipse.cdt.core.parser.IMacro;
|
||||||
import org.eclipse.cdt.core.parser.util.CharArrayIntMap;
|
import org.eclipse.cdt.core.parser.util.CharArrayIntMap;
|
||||||
|
|
||||||
|
@ -19,32 +19,39 @@ import org.eclipse.cdt.core.parser.util.CharArrayIntMap;
|
||||||
* @author Mike Kucera
|
* @author Mike Kucera
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class ScannerExtensionConfiguration implements IScannerExtensionConfiguration {
|
public class ScannerExtensionConfiguration extends AbstractScannerExtensionConfiguration {
|
||||||
|
|
||||||
|
@Override
|
||||||
public CharArrayIntMap getAdditionalKeywords() {
|
public CharArrayIntMap getAdditionalKeywords() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public IMacro[] getAdditionalMacros() {
|
public IMacro[] getAdditionalMacros() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public CharArrayIntMap getAdditionalPreprocessorKeywords() {
|
public CharArrayIntMap getAdditionalPreprocessorKeywords() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean initializeMacroValuesTo1() {
|
public boolean initializeMacroValuesTo1() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean support$InIdentifiers() {
|
public boolean support$InIdentifiers() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public char[] supportAdditionalNumericLiteralSuffixes() {
|
public char[] supportAdditionalNumericLiteralSuffixes() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean supportMinAndMaxOperators() {
|
public boolean supportMinAndMaxOperators() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue