Skip to main content

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

Re: #2
- Why do you need your parser to see these assembly instructions? Are you creating a real parser to produce the code? CDT would not usually care about assembly
for indexer except not choking on it, because for indexer info it does not matter, there is too many assembly languages to know its syntax or semantics.
If you really care about it you can inject it into whatever structure you building after the parser stage by correlating code positions.

(Disclaimer: I don't actual know how it is done in CDT but just from generic view)

On Fri, Oct 24, 2014 at 1:51 PM, Peter Watkins <peter.watkins@xxxxxxxxxxxxx> wrote:
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?


cdt-dev mailing list
To change your delivery options, retrieve your password, or unsubscribe from this list, visit

Back to the top