1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-24 09:25:31 +02:00

Support for @ in identifiers, bug 237028.

This commit is contained in:
Markus Schorn 2008-06-25 11:55:36 +00:00
parent e50931293e
commit e6baa5b577
27 changed files with 476 additions and 302 deletions

View file

@ -165,9 +165,9 @@ public class AST2BaseTest extends BaseTestCase {
IScannerInfo scannerInfo, boolean parseComments) {
IScannerExtensionConfiguration configuration = null;
if( lang == ParserLanguage.C )
configuration = new GCCScannerExtensionConfiguration();
configuration= GCCScannerExtensionConfiguration.getInstance();
else
configuration = new GPPScannerExtensionConfiguration();
configuration= GPPScannerExtensionConfiguration.getInstance();
IScanner scanner;
scanner= new CPreprocessor(codeReader, scannerInfo, lang, NULL_LOG, configuration,
FileCodeReaderFactory.getInstance());

View file

@ -85,7 +85,7 @@ public class ExpansionExplorerTests extends BaseTestCase {
private MacroExpander createExpander(final String macrodefs) throws OffsetLimitReachedException {
CPreprocessor cpp= new CPreprocessor(new CodeReader(macrodefs.toCharArray()),
new ScannerInfo(), ParserLanguage.C, new NullLogService(),
new GCCScannerExtensionConfiguration(), NullCodeReaderFactory.getInstance());
GCCScannerExtensionConfiguration.getInstance(), NullCodeReaderFactory.getInstance());
int type;
do {
type= cpp.nextTokenRaw().getType();

View file

@ -53,7 +53,7 @@ public class LexerTests extends BaseTestCase {
private void init(String input, boolean dollar, boolean minmax) throws Exception {
fLog.clear();
final LexerOptions lexerOptions = new LexerOptions();
lexerOptions.fSupportDollarInitializers= dollar;
lexerOptions.fSupportDollarInIdentifiers= dollar;
lexerOptions.fSupportMinAndMax= minmax;
fLexer= new Lexer(input.toCharArray(), lexerOptions, fLog, null);
fLexer.nextToken();

View file

@ -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
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@ -80,10 +80,10 @@ public class PreprocessorSpeedTest {
ICodeReaderFactory readerFactory= FileCodeReaderFactory.getInstance();
IScannerExtensionConfiguration scannerConfig;
if (lang == ParserLanguage.C) {
scannerConfig= new GCCScannerExtensionConfiguration();
scannerConfig= GCCScannerExtensionConfiguration.getInstance();
}
else {
scannerConfig= new GPPScannerExtensionConfiguration();
scannerConfig= GPPScannerExtensionConfiguration.getInstance();
}
ParserMode mode = ParserMode.COMPLETE_PARSE;
CPreprocessor cpp= new CPreprocessor(reader, info, lang, new NullLogService(), scannerConfig, readerFactory);

View file

@ -67,10 +67,10 @@ public abstract class PreprocessorTestsBase extends BaseTestCase {
IScannerExtensionConfiguration scannerConfig;
if (lang == ParserLanguage.C) {
scannerConfig= new GCCScannerExtensionConfiguration();
scannerConfig= GCCScannerExtensionConfiguration.getInstance();
}
else {
scannerConfig= new GPPScannerExtensionConfiguration();
scannerConfig= GPPScannerExtensionConfiguration.getInstance();
}
fScanner= new CPreprocessor(input, scannerInfo, lang, NULL_LOG, scannerConfig, readerFactory);

View file

@ -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
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@ -12,7 +12,6 @@
* Anton Leherbauer (Wind River Systems)
* Mike Kucera - IBM
*******************************************************************************/
package org.eclipse.cdt.core.dom.ast.gnu.c;
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.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.index.IIndex;
import org.eclipse.cdt.core.parser.IParserLogService;
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 {
protected static final GCCScannerExtensionConfiguration C_GNU_SCANNER_EXTENSION = new GCCScannerExtensionConfiguration();
protected static final GCCParserExtensionConfiguration C_GNU_PARSER_EXTENSION = new GCCParserExtensionConfiguration();
protected static final GCCScannerExtensionConfiguration C_GNU_SCANNER_EXTENSION= GCCScannerExtensionConfiguration.getInstance();
protected static final GCCParserExtensionConfiguration C_GNU_PARSER_EXTENSION= GCCParserExtensionConfiguration.getInstance();
// Must match the id in the extension
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;
}
/**
* Returns the extension configuration used for creating the parser.
* @since 5.1
*/
protected ICParserExtensionConfiguration getParserExtensionConfiguration() {
return C_GNU_PARSER_EXTENSION;
}
@Override
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
protected ParserLanguage getParserLanguage() {
return ParserLanguage.C;

View file

@ -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
* are made available under the terms of the Eclipse Public License v1.0
* 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.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.index.IIndex;
import org.eclipse.cdt.core.parser.IParserLogService;
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 {
protected static final GPPScannerExtensionConfiguration CPP_GNU_SCANNER_EXTENSION = new GPPScannerExtensionConfiguration();
protected static final GPPParserExtensionConfiguration CPP_GNU_PARSER_EXTENSION = new GPPParserExtensionConfiguration();
protected static final GPPScannerExtensionConfiguration CPP_GNU_SCANNER_EXTENSION= GPPScannerExtensionConfiguration.getInstance();
protected static final GPPParserExtensionConfiguration CPP_GNU_PARSER_EXTENSION= GPPParserExtensionConfiguration.getInstance();
public static final String ID = CCorePlugin.PLUGIN_ID + ".g++"; //$NON-NLS-1$
private static final GPPLanguage DEFAULT_INSTANCE = new GPPLanguage();
@ -70,9 +71,17 @@ public class GPPLanguage extends AbstractCLikeLanguage {
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
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

View file

@ -11,22 +11,23 @@
*******************************************************************************/
package org.eclipse.cdt.core.dom.parser;
import java.util.ArrayList;
import org.eclipse.cdt.core.parser.IMacro;
import org.eclipse.cdt.core.parser.IToken;
import org.eclipse.cdt.core.parser.util.CharArrayIntMap;
/**
* 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 {
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 {
private char[] fSignature;
private char[] fExpansion;
@ -44,14 +45,9 @@ public abstract class AbstractScannerExtensionConfiguration implements IScannerE
}
}
/**
* @deprecated see {@link IScannerExtensionConfiguration#initializeMacroValuesTo1()}
*/
@Deprecated
public boolean initializeMacroValuesTo1() {
return false;
public AbstractScannerExtensionConfiguration() {
}
/*
* @see org.eclipse.cdt.core.dom.parser.IScannerExtensionConfiguration#support$InIdentifiers()
*/
@ -59,6 +55,14 @@ public abstract class AbstractScannerExtensionConfiguration implements IScannerE
return false;
}
/**
* {@inheritDoc}
* @since 5.1
*/
public boolean supportAtSignInIdentifiers() {
return false;
}
/*
* @see org.eclipse.cdt.core.dom.parser.IScannerExtensionConfiguration#supportAdditionalNumericLiteralSuffixes()
*/
@ -73,41 +77,82 @@ public abstract class AbstractScannerExtensionConfiguration implements IScannerE
return false;
}
/*
* @see org.eclipse.cdt.core.dom.parser.IScannerExtensionConfiguration#getAdditionalKeywords()
*/
public CharArrayIntMap getAdditionalKeywords() {
return null;
public CharArrayIntMap getAdditionalPreprocessorKeywords() {
return fAddPreprocessorKeywords;
}
public CharArrayIntMap getAdditionalKeywords() {
return fAddKeywords;
}
public IMacro[] getAdditionalMacros() {
return null;
}
/*
* @see org.eclipse.cdt.core.dom.parser.IScannerExtensionConfiguration#getAdditionalPreprocessorKeywords()
*/
public CharArrayIntMap getAdditionalPreprocessorKeywords() {
return null;
if (fAddMacros == null) {
if (fAddMacroList == null) {
fAddMacros= EMPTY_MACRO_ARRAY;
} else {
fAddMacros= fAddMacroList.toArray(new IMacro[fAddMacroList.size()]);
}
}
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 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) {
return new MacroDefinition(signature.toCharArray(), value.toCharArray());
}
/**
* Helper method to add a function style macro to the given map.
*
* @param name the macro name
* @param value the macro value
* @param arguments the macro arguments
* @deprecated use {@link #addMacro(String, String)}
*/
@Deprecated
protected static IMacro createFunctionStyleMacro(String name, String value, String[] arguments) {
StringBuffer buf= new StringBuffer();
buf.append(name);
@ -123,4 +168,13 @@ public abstract class AbstractScannerExtensionConfiguration implements IScannerE
buf.getChars(0, signature.length, signature, 0);
return new MacroDefinition(signature, value.toCharArray());
}
/**
* @deprecated see {@link IScannerExtensionConfiguration#initializeMacroValuesTo1()}
*/
@Deprecated
public boolean initializeMacroValuesTo1() {
return false;
}
}

View file

@ -21,47 +21,52 @@ import org.eclipse.cdt.core.parser.Keywords;
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 {
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;
}
private static GNUScannerExtensionConfiguration sInstance;
public static void addAdditionalGNUKeywords(CharArrayIntMap target) {
target.put(GCCKeywords.cp__ALIGNOF__, IGCCToken.t___alignof__ );
target.put(GCCKeywords.cp__ALIGNOF__, IGCCToken.t___alignof__ );
target.put(GCCKeywords.cp__ASM, IToken.t_asm);
target.put(GCCKeywords.cp__ASM__, IToken.t_asm);
target.put(GCCKeywords.cp__ATTRIBUTE, IGCCToken.t__attribute__ );
target.put(GCCKeywords.cp__ATTRIBUTE__, IGCCToken.t__attribute__ );
target.put(GCCKeywords.cp__CONST, IToken.t_const);
target.put(GCCKeywords.cp__CONST__, IToken.t_const);
target.put(GCCKeywords.cp__DECLSPEC, IGCCToken.t__declspec );
target.put(GCCKeywords.cp__INLINE, IToken.t_inline);
target.put(GCCKeywords.cp__INLINE__, IToken.t_inline);
target.put(GCCKeywords.cp__RESTRICT, IToken.t_restrict);
target.put(GCCKeywords.cp__RESTRICT__, IToken.t_restrict);
target.put(GCCKeywords.cp__VOLATILE, IToken.t_volatile);
target.put(GCCKeywords.cp__VOLATILE__, IToken.t_volatile);
target.put(GCCKeywords.cp__SIGNED, IToken.t_signed);
target.put(GCCKeywords.cp__SIGNED__, IToken.t_signed);
target.put(GCCKeywords.cp__TYPEOF, IGCCToken.t_typeof);
target.put(GCCKeywords.cp__TYPEOF__, IGCCToken.t_typeof);
target.put(GCCKeywords.cpTYPEOF, IGCCToken.t_typeof );
@SuppressWarnings("nls")
public GNUScannerExtensionConfiguration() {
addMacro("__complex__", "_Complex");
addMacro("__extension__", "");
addMacro("__imag__", "(int)");
addMacro("__null", "(void *)0");
addMacro("__real__", "(int)");
addMacro("__stdcall", "");
addMacro("__builtin_va_arg(ap,type)", "*(type *)ap");
addMacro("__builtin_constant_p(exp)", "0");
addPreprocessorKeyword(Keywords.cINCLUDE_NEXT, IPreprocessorDirective.ppInclude_next);
addPreprocessorKeyword(Keywords.cIMPORT, IPreprocessorDirective.ppImport);
addPreprocessorKeyword(Keywords.cWARNING, IPreprocessorDirective.ppWarning);
addPreprocessorKeyword(Keywords.cIDENT, IPreprocessorDirective.ppIgnore);
addPreprocessorKeyword(Keywords.cSCCS, IPreprocessorDirective.ppIgnore);
addPreprocessorKeyword(Keywords.cASSERT, IPreprocessorDirective.ppIgnore);
addPreprocessorKeyword(Keywords.cUNASSERT, IPreprocessorDirective.ppIgnore);
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
@ -73,25 +78,28 @@ public abstract class GNUScannerExtensionConfiguration extends AbstractScannerEx
public char[] supportAdditionalNumericLiteralSuffixes() {
return "ij".toCharArray(); //$NON-NLS-1$
}
@Override
public IMacro[] getAdditionalMacros() {
return sAdditionalMacros;
}
/*
* @see org.eclipse.cdt.internal.core.parser.scanner2.IScannerExtensionConfiguration#getAdditionalPreprocessorKeywords()
*/
@Override
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;
}
/**
* @deprecated simply derive from this class and use {@link #addMacro(String, String)} to
* add additional macros.
*/
@Deprecated
public static IMacro[] getAdditionalGNUMacros() {
if (sInstance == null) {
sInstance= new GNUScannerExtensionConfiguration() {};
}
return sInstance.getAdditionalMacros();
}
/**
* @deprecated simply derive from this class and use {@link #addKeyword(char[], int)} to
* add additional keywords.
*/
@Deprecated
public static void addAdditionalGNUKeywords(CharArrayIntMap target) {
if (sInstance == null) {
sInstance= new GNUScannerExtensionConfiguration() {};
}
target.putAll(sInstance.getAdditionalKeywords());
}
}

View file

@ -18,19 +18,9 @@ import org.eclipse.cdt.core.parser.util.CharArrayIntMap;
/**
* Scanner extension configuration interface.
*
* <p>
* This interface is not intended to be implemented directly. Clients should
* 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
*
* @noimplement This interface is not intended to be implemented by clients. Clients can subclass
* {@link AbstractScannerExtensionConfiguration}, instead.
*/
public interface IScannerExtensionConfiguration {
@ -50,6 +40,14 @@ public interface IScannerExtensionConfiguration {
*/
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>&lt;?</code>
* and <code>&gt;?</code>).

View file

@ -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
* 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:
* Anton Leherbauer (Wind River Systems) - initial API and implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/
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.
*
* <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 {
@ -95,4 +88,11 @@ public abstract class AbstractCParserExtensionConfiguration implements ICParserE
return null;
}
/**
* {@inheritDoc}
* @since 5.1
*/
public boolean supportParameterInfoBlock() {
return false;
}
}

View file

@ -6,8 +6,9 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM Rational Software - Initial API and implementation
* Ed Swartz (Nokia)
* IBM Rational Software - Initial API and implementation
* Ed Swartz (Nokia)
* Markus Schorn (Wind River Systems)
*******************************************************************************/
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;
/**
* @author jcamelon
* Configures the parser for c-source code as accepted by gcc.
*/
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()

View file

@ -13,24 +13,22 @@
package org.eclipse.cdt.core.dom.parser.c;
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 {
private static IMacro[] sAdditionalMacros;
private static CharArrayIntMap sAdditionalKeywords;
static {
final IMacro[] macros = GNUScannerExtensionConfiguration.getAdditionalGNUMacros();
sAdditionalMacros= new IMacro[macros.length+1];
System.arraycopy(macros, 0, sAdditionalMacros, 0, macros.length);
sAdditionalMacros[macros.length]= createMacro("_Pragma(arg)", ""); //$NON-NLS-1$//$NON-NLS-2$
sAdditionalKeywords= new CharArrayIntMap(10, -1);
GNUScannerExtensionConfiguration.addAdditionalGNUKeywords(sAdditionalKeywords);
private static GCCScannerExtensionConfiguration sInstance= new GCCScannerExtensionConfiguration();
/**
* @since 5.1
*/
public static GCCScannerExtensionConfiguration getInstance() {
return sInstance;
}
public GCCScannerExtensionConfiguration() {
addMacro("_Pragma(arg)", ""); //$NON-NLS-1$//$NON-NLS-2$
}
/* (non-Javadoc)
@ -40,22 +38,4 @@ public class GCCScannerExtensionConfiguration extends GNUScannerExtensionConfigu
public boolean supportMinAndMaxOperators() {
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;
}
}

View file

@ -6,9 +6,10 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM Rational Software - Initial API and implementation
* Ed Swartz (Nokia)
* Anton Leherbauer (Wind River Systems)
* IBM Rational Software - Initial API and implementation
* Ed Swartz (Nokia)
* Anton Leherbauer (Wind River Systems)
* Markus Schorn (Wind River Systems)
*******************************************************************************/
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.
*
* <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>
* @noimplement This interface is not intended to be implemented by clients.
* Clients can subclass {@link AbstractCParserExtensionConfiguration} instead.
*
* @see "http://gcc.gnu.org/onlinedocs/gcc/C-Extensions.html"
*
* @author jcamelon
* @since 4.0
*/
public interface ICParserExtensionConfiguration {
@ -78,17 +69,6 @@ public interface ICParserExtensionConfiguration {
*/
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
* information on GCC's Attribute Specifiers.
@ -113,4 +93,23 @@ public interface ICParserExtensionConfiguration {
* <code>null</code>
*/
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();
}

View file

@ -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
* 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:
* Anton Leherbauer (Wind River Systems) - initial API and implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/
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.
*
* <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 {
@ -121,6 +115,14 @@ public abstract class AbstractCPPParserExtensionConfiguration implements ICPPPar
return false;
}
/**
* {@inheritDoc}
* @since 5.1
*/
public boolean supportParameterInfoBlock() {
return false;
}
/*
* @see org.eclipse.cdt.core.dom.parser.cpp.ICPPParserExtensionConfiguration#getBuiltinBindingsProvider()
*/
@ -130,5 +132,4 @@ public abstract class AbstractCPPParserExtensionConfiguration implements ICPPPar
}
return null;
}
}

View file

@ -6,8 +6,9 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM Rational Software - Initial API and implementation
* Ed Swartz (Nokia)
* IBM Rational Software - Initial API and implementation
* Ed Swartz (Nokia)
* Markus Schorn (Wind River Systems)
*******************************************************************************/
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;
/**
* @author jcamelon
* Configures the parser for c++-sources as accepted by g++.
*/
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()

View file

@ -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.parser.IToken;
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 {
private static CharArrayIntMap sAdditionalKeywords;
static {
sAdditionalKeywords= new CharArrayIntMap(10, -1);
GNUScannerExtensionConfiguration.addAdditionalGNUKeywords(sAdditionalKeywords);
sAdditionalKeywords.put( Keywords.cRESTRICT, IToken.t_restrict );
sAdditionalKeywords.put( Keywords.c_COMPLEX, IToken.t__Complex );
sAdditionalKeywords.put( Keywords.c_IMAGINARY, IToken.t__Imaginary );
private static GPPScannerExtensionConfiguration sInstance= new GPPScannerExtensionConfiguration();
/**
* @since 5.1
*/
public static GPPScannerExtensionConfiguration getInstance() {
return sInstance;
}
public GPPScannerExtensionConfiguration() {
addKeyword(Keywords.cRESTRICT, IToken.t_restrict);
addKeyword(Keywords.c_COMPLEX, IToken.t__Complex);
addKeyword(Keywords.c_IMAGINARY, IToken.t__Imaginary);
}
/* (non-Javadoc)
@ -39,12 +43,4 @@ public class GPPScannerExtensionConfiguration extends GNUScannerExtensionConfigu
public boolean supportMinAndMaxOperators() {
return true;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.scanner2.IScannerConfiguration#getAdditionalKeywords()
*/
@Override
public CharArrayIntMap getAdditionalKeywords() {
return sAdditionalKeywords;
}
}

View file

@ -6,9 +6,10 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM Rational Software - Initial API and implementation
* Ed Swartz (Nokia)
* Anton Leherbauer (Wind River Systems)
* IBM Rational Software - Initial API and implementation
* Ed Swartz (Nokia)
* Anton Leherbauer (Wind River Systems)
* Markus Schorn (Wind River Systems)
*******************************************************************************/
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.
*
* <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>
* @noimplement This interface is not intended to be implemented by clients.
* Clients can subclass {@link AbstractCPPParserExtensionConfiguration} instead.
*
* @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 {
@ -76,16 +67,6 @@ public interface ICPPParserExtensionConfiguration {
*/
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.
*
@ -129,16 +110,6 @@ public interface ICPPParserExtensionConfiguration {
*/
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
* information on GCC's Attribute Specifiers.
@ -163,4 +134,24 @@ public interface ICPPParserExtensionConfiguration {
* <code>null</code>
*/
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();
}

View file

@ -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;
}
}

View file

@ -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;
}
}

View file

@ -92,6 +92,7 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
protected final boolean supportKnRC;
protected final boolean supportAttributeSpecifiers;
protected final boolean supportDeclspecSpecifiers;
protected boolean supportParameterInfoBlock;
protected final IBuiltinBindingsProvider builtinBindingsProvider;
/**
@ -124,7 +125,7 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
this.supportDeclspecSpecifiers = supportDeclspecSpecifiers;
this.builtinBindingsProvider= builtinBindingsProvider;
}
private AbstractParserLogService wrapLogService(IParserLogService logService) {
if (logService instanceof AbstractParserLogService) {
return (AbstractParserLogService) logService;
@ -2188,4 +2189,23 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
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;
}
}
}
}
}

View file

@ -146,6 +146,7 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
config.supportDeclspecSpecifiers(),
config.getBuiltinBindingsProvider());
supportGCCStyleDesignators = config.supportGCCStyleDesignators();
supportParameterInfoBlock= config.supportParameterInfoBlock();
this.index= index;
}
@ -434,22 +435,24 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
endOffset= figureEndOffset(declSpec, declarators);
break;
default:
insertSemi= true;
if (markBeforDtor == null || !isOnSameLine(calculateEndOffset(declSpec), markBeforDtor.getOffset())) {
if (markBeforDtor != null) {
backup(markBeforDtor);
if (declOption != DeclarationOptions.LOCAL) {
insertSemi= true;
if (markBeforDtor == null || !isOnSameLine(calculateEndOffset(declSpec), markBeforDtor.getOffset())) {
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));
}
@ -2014,7 +2017,10 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
protected IASTParameterDeclaration parameterDeclaration(DeclarationOptions option) throws BacktrackException, EndOfFileException {
final IToken current = LA(1);
int startingOffset = current.getOffset();
if (current.getType() == IToken.tLBRACKET && supportParameterInfoBlock) {
skipBrackets(IToken.tLBRACKET, IToken.tRBRACKET);
}
IASTDeclSpecifier declSpec = null;
IASTDeclarator declarator = null;
IASTDeclSpecifier altDeclSpec = null;

View file

@ -1775,6 +1775,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
supportExtendedTemplateSyntax = config.supportExtendedTemplateSyntax();
supportMinAndMaxOperators = config.supportMinAndMaxOperators();
supportLongLong = config.supportLongLongs();
supportParameterInfoBlock= config.supportParameterInfoBlock();
this.index= index;
}
@ -2558,26 +2559,28 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
case IToken.tLBRACE:
return functionDefinition(firstOffset, declSpec, declarators, false);
default:
insertSemi= true;
if (validWithoutDtor(declOption, declSpec)) {
// class definition without semicolon
if (markBeforDtor == null || !isOnSameLine(calculateEndOffset(declSpec), markBeforDtor.getOffset())) {
if (markBeforDtor != null) {
backup(markBeforDtor);
if (declOption != DeclarationOptions.LOCAL) {
insertSemi= true;
if (validWithoutDtor(declOption, declSpec)) {
// class definition without semicolon
if (markBeforDtor == null || !isOnSameLine(calculateEndOffset(declSpec), markBeforDtor.getOffset())) {
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;
}
}
endOffset= figureEndOffset(declSpec, declarators);
if (lt1 == 0 || !isOnSameLine(endOffset, LA(1).getOffset())) {
insertSemi= true;
break;
}
if (declarators.length == 1 && declarators[0] instanceof IASTFunctionDeclarator) {
break;
}
if (declarators.length == 1 && declarators[0] instanceof IASTFunctionDeclarator) {
break;
}
}
throwBacktrack(LA(1));
}
@ -2756,6 +2759,10 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
protected ICPPASTParameterDeclaration parameterDeclaration() throws BacktrackException, EndOfFileException {
final int startOffset= LA(1).getOffset();
if (LT(1) == IToken.tLBRACKET && supportParameterInfoBlock) {
skipBrackets(IToken.tLBRACKET, IToken.tRBRACKET);
}
IASTDeclSpecifier declSpec;
IASTDeclarator declarator;
try {
@ -2776,7 +2783,6 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
return parm;
}
protected ICPPASTParameterDeclaration createParameterDeclaration() {
return new CPPASTParameterDeclaration();
}

View file

@ -147,7 +147,8 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable {
IScannerExtensionConfiguration configuration, ICodeReaderFactory readerFactory) {
fLog = log;
fAdditionalNumericLiteralSuffixes= nonNull(configuration.supportAdditionalNumericLiteralSuffixes());
fLexOptions.fSupportDollarInitializers= configuration.support$InIdentifiers();
fLexOptions.fSupportDollarInIdentifiers= configuration.support$InIdentifiers();
fLexOptions.fSupportAtSignInIdentifiers= configuration.supportAtSignInIdentifiers();
fLexOptions.fSupportMinAndMax = configuration.supportMinAndMaxOperators();
fKeywords= new CharArrayIntMap(40, -1);
fPPKeywords= new CharArrayIntMap(40, -1);

View file

@ -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
* are made available under the terms of the Eclipse Public License v1.0
* 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;
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 fCreateImageLocations= true;
@ -357,7 +358,12 @@ final public class Lexer {
return identifier(start, 1);
case '$':
if (fOptions.fSupportDollarInitializers) {
if (fOptions.fSupportDollarInIdentifiers) {
return identifier(start, 1);
}
break;
case '@':
if (fOptions.fSupportAtSignInIdentifiers) {
return identifier(start, 1);
}
break;
@ -820,7 +826,10 @@ final public class Lexer {
break;
case '$':
isPartOfIdentifier= fOptions.fSupportDollarInitializers;
isPartOfIdentifier= fOptions.fSupportDollarInIdentifiers;
break;
case '@':
isPartOfIdentifier= fOptions.fSupportAtSignInIdentifiers;
break;
case '{': case '}': case '[': case ']': case '#': case '(': case ')': case '<': case '>':

View file

@ -50,8 +50,8 @@ import org.eclipse.core.runtime.content.IContentType;
*/
public class InternalASTServiceProvider implements IASTServiceProvider {
protected static final GCCScannerExtensionConfiguration C_GNU_SCANNER_EXTENSION = new GCCScannerExtensionConfiguration();
protected static final GPPScannerExtensionConfiguration CPP_GNU_SCANNER_EXTENSION = new GPPScannerExtensionConfiguration();
protected static final GCCScannerExtensionConfiguration C_GNU_SCANNER_EXTENSION = GCCScannerExtensionConfiguration.getInstance();
protected static final GPPScannerExtensionConfiguration CPP_GNU_SCANNER_EXTENSION = GPPScannerExtensionConfiguration.getInstance();
private static final String[] dialects = {
"C99", //$NON-NLS-1$
"C++98", //$NON-NLS-1$

View file

@ -8,7 +8,7 @@
******************************************************************************/
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.util.CharArrayIntMap;
@ -19,32 +19,39 @@ import org.eclipse.cdt.core.parser.util.CharArrayIntMap;
* @author Mike Kucera
*
*/
public class ScannerExtensionConfiguration implements IScannerExtensionConfiguration {
public class ScannerExtensionConfiguration extends AbstractScannerExtensionConfiguration {
@Override
public CharArrayIntMap getAdditionalKeywords() {
return null;
}
@Override
public IMacro[] getAdditionalMacros() {
return null;
}
@Override
public CharArrayIntMap getAdditionalPreprocessorKeywords() {
return null;
}
@Override
public boolean initializeMacroValuesTo1() {
return false;
}
@Override
public boolean support$InIdentifiers() {
return true;
}
@Override
public char[] supportAdditionalNumericLiteralSuffixes() {
return null;
}
@Override
public boolean supportMinAndMaxOperators() {
return false;
}