Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [cdt-dev] org.eclipse.cdt.core.dom.parser.c

Hi Flo,

its probably the ".toString()" thats the problem. I am using the following fragment:

IASTComment[] comms = ast.getComments();
            for(IASTComment c : comms)
            {
                String t = c.getRawSignature();

and it works like a charm. getRawSignature() is what you would use to see the actual C code (works for other IASTNodes, too).

Andreas


Am 18.08.2010 09:42, schrieb Flo Menier:
Thanks Helko. I tried to do what you said:
public static void main(String[] args) throws Exception {
IParserLogService log = new DefaultLogService();
String codeString = "int function(int toto){int a;/*doc0*/ char b;/*doc1*/ return toto+a; //*doc2*//}";
char[] code = codeString.toCharArray();
CodeReader reader = new CodeReader(code);
Map definedSymbols = new HashMap();
String[] includePaths = new String[0];
IScannerInfo info = new ScannerInfo(definedSymbols, includePaths);
ICodeReaderFactory readerFactory = FileCodeReaderFactory.getInstance();
IASTTranslationUnit translationUnit =GCCLanguage.getDefault().getASTTranslationUnit(reader, info, readerFactory, null, log); 
for (IASTComment com :translationUnit.getComments()){
System.out.println(com.getComment().toString());
}

I got nothing printed in console. getComments() gave me a IASTComment[10], value is null for all 10 IASComment?

> From: glathe.helko@xxxxxxxxxxxxxx
> Date: Wed, 18 Aug 2010 00:41:38 +0200
> Subject: Re: [cdt-dev] org.eclipse.cdt.core.dom.parser.c
> To: cdt-dev@xxxxxxxxxxx
>
> Hello,
>
> have a look at the CVS repository:
>
> " 1. Connect to CVS repository:
> :pserver:anonymous@xxxxxxxxxxxxxxx:2401/cvsroot/tools (Or
> :pserver:anonymous@xxxxxxxxxxxxxxxxx:80/cvsroot/tools from behind
> corporate firewall)
> 2. Check out: org.eclipse.cdt/all "
>
> Underneath of "all" you will find the folder "org.eclipse.cdt.core".
> Inside their is a subfolder for the "parser" where you can find the
> source code.
>
>
> But I think you can access Block Comments right know using the AST of
> the C Source Code. The IASTTranslationUnit provides a method for
> getting all comments (getComments()). This Method returns an Array of
> IASTComment's. And IASTComment provides a to determine whether it is a
> block comment or not (see IASTComment.isBlockComment()).
>
> Cheers, Helko
>
>
>
> Sincerely,
>
> Helko Glathe
>
>
>
> 2010/8/17 Flo Menier <josieenfrance@xxxxxxxxxxx>:
> > Can someone tell me where I can download the code source
> > of org.eclipse.cdt.core.dom.parser.c,
> > and org.eclipse.cdt.internal.core.parser.scanner? I want to understand how
> > lexer works in CDT? I want to get block comments in a C source file instead
> > of ignorer them.
> > Thanks a lot
> > _______________________________________________
> > cdt-dev mailing list
> > cdt-dev@xxxxxxxxxxx
> > https://dev.eclipse.org/mailman/listinfo/cdt-dev
> >
> >
> _______________________________________________
> cdt-dev mailing list
> cdt-dev@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/cdt-dev
_______________________________________________ cdt-dev mailing list cdt-dev@xxxxxxxxxxx https://dev.eclipse.org/mailman/listinfo/cdt-dev


-- 
Andreas Graf
BDM Automotive
Mobil: +49 (0) 151-10860479 (preferred)
Tel.: +49 (0) 7231 / 1 54 71-0
Fax.: +49 (0) 7231 / 1 54 71-29


Web: http://www.itemis.de
Mail: andreas.graf@xxxxxxxxx
Xing: http://www.xing.com/profile/Andreas_Graf
Twitter: http://www.twitter.com/grafandreas
Blog: http://5ise.quanxinquanyi.de

itemis GmbH
Blücherstrasse 32
D-75177 Pforzheim
Rechtlicher Hinweis:
Amtsgericht Mannheim, HRB 50700996
Ust.Id.Nr.: DE250574762
Geschäftsführer: Sebastian Neus

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature


Back to the top