Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-dev] Language plugin extending Scanner

I've written a language plugin to support Cosmic's dialect of C. I had to copy a fair portion of the GCC language parser to make my own parser that extends ISourceCodeParser. It works fine except in one case: assembly code. Cosmic doesn't have GCC's asm() statement. Instead, it uses two types of preprocessor keywords:

#pragma asm
#pragma endasm


#endasm denote a block of assembly. I can add the latter pair of keywords to my ScannerExtensionConfiguration, but CPreprocessor doesn't know what do with them of course.

I have a few questions:

1) I assume all the # lines above are consumed by the scanner, and my parser will never see them. Is this correct?

2) In the case of #if #endif, the scanner inserts tINACTIVE_CODE_START into the token stream for the parser to see, right? To handle my assembly block preprocessor instructions, should I do something similar (i.e. insert tASSEMBLY_START and tASSEMBLY_END)?

3) If I do need to go about extending the scanner in my language plugin, how do I do that? IScanner "is not intended to be implemented by clients" and CPreprocessor "...should not be used directly, rather than that you should be using the IScanner interface." Furthermore, AbstractCLikeLanguage.createScanner() is marked final, so even if I could make my own scanner, how would my language provide it?



Back to the top