Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-dev] How to add Keyword to CDT Parser

I have to extend CDT Parser to recognize some new Keywords and understand
them. Ex: _c_status 

Towards this I have added an extension to org.eclipse.cdt.core.language in
the plugin.xml file. 

<extension point="org.eclipse.cdt.core.language">
name="NEW C">

I have provided an implementation for the class as below: 

public class NewCLanguage extends GCCLanguage implements ICLanguageKeywords,
ILanguage { 
private static final NewCLanguage DEFAULT_INSTANCE = new NewCLanguage(); 
protected static final NCScannerExtensionConfiguration NC_SCANNER_EXTENSION
new NCScannerExtensionConfiguration(); 

public static NewCLanguage getDefault() { 

public String getId() { 
return ""; 

public Object getAdapter(NewCLanguage language) { 
return getAdapter(this); 

public String[] getKeywords() { 
return new String[] {"_c_status"}; 

protected IScannerExtensionConfiguration getScannerExtensionConfiguration()

And provided the implementation for the ScannerConfiguration as below: 

public class NCScannerExtensionConfiguration extends 
GCCScannerExtensionConfiguration { 
public static final String CSTATUS = "_c_status";	
public static final char[] extendcCSTATUS = "_c_status".toCharArray(); 

public CharArrayIntMap getAdditionalKeywords() { 
CharArrayIntMap additionalCKeywords = new CharArrayIntMap(0, 0); 
additionalCKeywords.put( NCScannerExtensionConfiguration.extendcppCCSTATUS,

return additionalCKeywords; 

I have also linked the source files to be associated with NewCLanguage in
the Language Mappings under Preferences. Yet I don't think the new keywords
are being recognized. Is there a way i could check if the keywords are
recognized. The keyword is not highlighted in the editor. Should i also
extend the editor? 

My second part of the query is how to extend the parser to provide the
implementation for the keyword. the keyword _c_status is always associated
with a function call. It means that the function call with this keyword need
to follow a different syntax. Can you please help me with how I could
achieve this. I need this on priority basis. 

Thanks in advance.

View this message in context:
Sent from the Eclipse CDT - Development mailing list archive at

Back to the top