Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » how to validate C syntax with CDT? thanks
how to validate C syntax with CDT? thanks [message #223935] Tue, 23 September 2008 09:18 Go to next message
Eclipse UserFriend
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 Go to previous message
Eclipse UserFriend
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.
Previous Topic:Support for 0b binary numbers
Next Topic:Documentation to create my own C/C++ Project from a template
Goto Forum:
  


Current Time: Sat Dec 21 17:22:45 GMT 2024

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

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

Back to the top