I want to create a program that checks if the input is syntactically valid in C -
how create c program takes in command in c input, , prints if there errors? for example, input: for(i=0; i<5; i++); no errors. input: for((i=0); i>2,(i<5) ; i++); no errors. input: for(i=0, i<5; i++); error. input: for((i=0; i<5; i++)); error. i think shortest way compile input string, , check if errors occur. don't know how compile piece of code passed during runtime. also, there problem of undeclared variables. c particuraly complicated parse. if remove pre-processor side of it, there still tricky parts. if learning yourself, can c grammar (there in lex/yacc format ansi c) can at. from example guess want able recognize subset of c, not entire language, correct? if case, should define subset , write parser it. rather trying write parser hand, should learn grammars , parser generators if haven't worked them already. if it's subset of c you're interested in, use peg parse generator packcc pars...