Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » How to add Keyword to CDT Parser(How to add new keywords to CDT Parser and provide implementation to support content assist and Outline view.)
icon4.gif  How to add Keyword to CDT Parser [message #1248330] Mon, 17 February 2014 06:23
Anitha Mising name is currently offline Anitha Mising nameFriend
Messages: 28
Registered: February 2010
Junior Member
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">
<language
class="com.dev.core.languages.NewCLanguage"
id="c"
name="NEW C">
<contentType
id="org.eclipse.cdt.core.cSource">
</contentType>
<contentType
id="org.eclipse.cdt.core.cHeader">
</contentType>
</language>
<extension>

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() {
return DEFAULT_INSTANCE;
}

public String getId() {
return "com.dev.core.c";
}

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

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


protected IScannerExtensionConfiguration getScannerExtensionConfiguration() {
return NC_SCANNER_EXTENSION;
}
}

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, IToken.t_class);

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.

[Updated on: Mon, 03 March 2014 05:37]

Report message to a moderator

Previous Topic:Indexer runs needlessly
Next Topic:gdbserver breakpoints on Kepler
Goto Forum:
  


Current Time: Fri Apr 19 07:56:14 GMT 2024

Powered by FUDForum. Page generated in 0.02385 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top