how to validate C syntax with CDT? thanks [message #223935] |
Tue, 23 September 2008 09:18 |
Eclipse User |
|
|
|
Originally posted by: lifesting.gmail.com
I created a plugin which contains a text control to let user input C
code. for example, the code maybe like this:
int main()
{
int a = 0;
int b=1
printf("a+b=%d",a+b);
}
In the above segment, character ';" missed at the sentence 'int b=1',
when user click a button like 'OK', 'Apply' to complete input, I would
let him know there's syntax error(s).
CDT support this function but I don't know how to invoke it, and event
don't know how to instantiate an AST Parser for code segment like JDT did.
JDT example:
ASTParser parser = ASTParser.newParser(AST.JLS3);
String c_code = "int main()......";
parser.setSource(c_code);
....
Thanks!
|
|
|
Re: how to validate C syntax with CDT? thanks [message #224533 is a reply to message #223935] |
Mon, 06 October 2008 07:43 |
Eclipse User |
|
|
|
Originally posted by: lifesting.gmail.com
David BY Chan wrote:
> I created a plugin which contains a text control to let user input C
> code. for example, the code maybe like this:
>
> int main()
> {
> int a = 0;
> int b=1
> printf("a+b=%d",a+b);
> }
>
> In the above segment, character ';" missed at the sentence 'int b=1',
> when user click a button like 'OK', 'Apply' to complete input, I would
> let him know there's syntax error(s).
>
> CDT support this function but I don't know how to invoke it, and event
> don't know how to instantiate an AST Parser for code segment like JDT did.
>
> JDT example:
>
> ASTParser parser = ASTParser.newParser(AST.JLS3);
>
> String c_code = "int main()......";
>
> parser.setSource(c_code);
>
> ...
>
> Thanks!
>
:) Still nobody help me! I debugged CDT and found that intermediate
syntax checking is provided by class GNUCSourceParser, which be packaged
in plugin org.eclipse.cdt.core.
|
|
|
Powered by
FUDForum. Page generated in 0.03420 seconds