Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » Ignoring multiline assembler blocks(How can I get the parse to ignore inline assembler blocks?)
Ignoring multiline assembler blocks [message #645047] Wed, 15 December 2010 11:22 Go to next message
A HoyleFriend
Messages: 22
Registered: November 2010
Junior Member
Hi All

I would like to be able to use multi-line in-line assembler blocks of code without the parser highlighting lots of syntax errors.

I have successfully extended org.eclipse.cdt.core.language extensions point with a new lanugage class. I have written a class that extends GNUScannerExtensionConfiguration which adds some keywords and macros which successfully prevent syntax error for most of my additional keywords.

The problem I am having is with multi-line in-line assembler blocks. My compiler accepts __asm and __endasm as start and stop marks for in-line assembler blocks. I have tried defining them at GNU in-line assemble commands, but that only works for single line blocks.

addMacro("__asm", " asm( ");
addMacro("__endasm", ")");

I have tried to comment them out using;

addMacro("__asm", " /* ");
addMacro("__endasm", " */ ");

but that didn't work.

I have tried to mark it as inactive code by
addMacro("__asm", "/n#if 0 ");
addMacro("__endasm", "/n#endif ");

and
addKeyword("__asm".toCharArray(), IToken.tINACTIVE_CODE_START);
addKeyword("__endasm".toCharArray(), IToken.tINACTIVE_CODE_START);

but this cause the follow exception apparently when it gets to the "__endasm" token.

Has anyone successfully modified CDT to ignore multi-line block?

Any suggestions welcome.


java.lang.ClassCastException: org.eclipse.cdt.internal.core.parser.scanner.TokenWithImage cannot be cast to org.eclipse.cdt.core.parser.IInactiveCodeToken
at org.eclipse.cdt.internal.core.dom.parser.AbstractGNUSourceCo deParser.acceptInactiveCodeBoundary(AbstractGNUSourceCodePar ser.java:357)
at org.eclipse.cdt.internal.core.dom.parser.AbstractGNUSourceCo deParser.declarationList(AbstractGNUSourceCodeParser.java:12 95)
at org.eclipse.cdt.internal.core.dom.parser.AbstractGNUSourceCo deParser.parseTranslationUnit(AbstractGNUSourceCodeParser.ja va:1265)
at org.eclipse.cdt.internal.core.dom.parser.AbstractGNUSourceCo deParser.translationUnit(AbstractGNUSourceCodeParser.java:12 60)
at org.eclipse.cdt.internal.core.dom.parser.AbstractGNUSourceCo deParser.parse(AbstractGNUSourceCodeParser.java:645)
at org.eclipse.cdt.core.dom.parser.AbstractCLikeLanguage.getAST TranslationUnit(AbstractCLikeLanguage.java:143)
at org.eclipse.cdt.internal.core.model.TranslationUnit.getAST(T ranslationUnit.java:801)
at org.eclipse.cdt.internal.core.model.TranslationUnit.getAST(T ranslationUnit.java:765)
at org.eclipse.cdt.internal.core.model.ASTCache$1.run(ASTCache. java:293)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.cdt.internal.core.model.ASTCache.createAST(ASTCa che.java:287)
at org.eclipse.cdt.internal.core.model.ASTCache.getAST(ASTCache .java:168)
at org.eclipse.cdt.internal.core.model.ASTCache.runOnAST(ASTCac he.java:215)
at org.eclipse.cdt.internal.ui.editor.ASTProvider.runOnAST(ASTP rovider.java:344)
at org.eclipse.cdt.internal.ui.viewsupport.SelectionListenerWit hASTManager$PartListenerGroup.calculateASTandInform(Selectio nListenerWithASTManager.java:168)
at org.eclipse.cdt.internal.ui.viewsupport.SelectionListenerWit hASTManager$PartListenerGroup$3.run(SelectionListenerWithAST Manager.java:142)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
Re: Ignoring multiline assembler blocks [message #645762 is a reply to message #645047] Mon, 20 December 2010 13:04 Go to previous messageGo to next message
No real name is currently offline No real nameFriend
Messages: 2
Registered: June 2010
Junior Member
I have the same problem with embedded sql. Can anyone help please?!
Re: Ignoring multiline assembler blocks [message #645776 is a reply to message #645762] Mon, 20 December 2010 14:41 Go to previous messageGo to next message
Anton Leherbauer is currently offline Anton LeherbauerFriend
Messages: 490
Registered: July 2009
Senior Member
On 12/20/2010 2:04 PM, skirschbaum@commitwork.de wrote:
> I have the same problem with embedded sql. Can anyone help please?!

You could wrap the embedded asm/sql sections with preprocessor
directives like

#ifndef __CDT_PARSER__
// embedded asm or sql
#endif

The CDT parser will then ignore those sections.

--
Anton Leherbauer
Wind River Systems, Austria
CDT Committer - http://www.eclipse.org/cdt
Re: Ignoring multiline assembler blocks [message #645790 is a reply to message #645776] Mon, 20 December 2010 15:29 Go to previous messageGo to next message
No real name is currently offline No real nameFriend
Messages: 2
Registered: June 2010
Junior Member
I am sorry, but I don't understand, because I am a newbie. Where should I wrap the preprocessor directives. In my ScannerExtensionConfiguration-Class with addMacro?
The SQL-parts starts always with "EXEC SQL" and ends with a semicolon. Please give me a little example. Thank you very much!
Re: Ignoring multiline assembler blocks [message #645926 is a reply to message #645790] Tue, 21 December 2010 08:23 Go to previous messageGo to next message
Anton Leherbauer is currently offline Anton LeherbauerFriend
Messages: 490
Registered: July 2009
Senior Member
On 12/20/2010 4:30 PM, skirschbaum@commitwork.de wrote:
> I am sorry, but I don't understand, because I am a newbie. Where should
> I wrap the preprocessor directives. In my
> ScannerExtensionConfiguration-Class with addMacro?
> The SQL-parts starts always with "EXEC SQL" and ends with a semicolon.
> Please give me a little example. Thank you very much!

You would need to change the C code which contains the
emebedded SQL. Maybe that's not what you want, but I don't
see a way to accomplish the same using a ScannerExtensionConfiguration
or similar.

--
Anton Leherbauer
Wind River Systems, Austria
CDT Committer - http://www.eclipse.org/cdt
Re: Ignoring multiline assembler blocks [message #646449 is a reply to message #645047] Fri, 24 December 2010 11:21 Go to previous messageGo to next message
A HoyleFriend
Messages: 22
Registered: November 2010
Junior Member
Hi Anton

I would not want to change the source code. I could not #ifdef the assembler code out because it would then be ignored by the compiler. I just want to tell the built-in parser not to parser these blocks to prevent unwanted syntax warnings.

I think I am going to have to modify / re-write the parser to do this properly. But I realise this would be a huge task. So for the time being I am just having to live with the unwanted syntax warnings.

Thanks for all your suggestions.
If anyone has any more suggestions please let us know.
Re: Ignoring multiline assembler blocks [message #1832992 is a reply to message #645926] Wed, 30 September 2020 12:31 Go to previous messageGo to next message
Eric Wills is currently offline Eric WillsFriend
Messages: 4
Registered: September 2020
Junior Member
I am not very good at this.
Tell me where can I get Scanner Extension Configuration?


Business before pleasure
Cheap Essay Writing Service


Re: Ignoring multiline assembler blocks [message #1833008 is a reply to message #1832992] Wed, 30 September 2020 14:00 Go to previous message
David VavraFriend
Messages: 1426
Registered: October 2012
Senior Member
You don't really need it to address this thread's topic.

You can use __CDT_PARSER__ in preprocessor ifdef and ifndef statements to show and hide code during parsing.

You can also define troublesome function calls as empty macros using User Settings in
Project --> Properties --> C/C++ General --> Preprocessor Include Paths, Macros etc. --> Entries tab
Previous Topic:Edit source lookup path options are not working
Next Topic:Windows - meson build problem
Goto Forum:
  


Current Time: Thu Oct 10 21:25:42 GMT 2024

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

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

Back to the top