You might want to investigate something like Lex.
Using BNF may (or may not) be of much use in actual parsing.
Originally Posted by
iamnew
So how do i store these rules in a program so that these rules can be used later to check for syntax validity?
This is really not very different from someone saying, "How do I store the rules of chess in a program so that I can check if a move in a game is valid?" Certainly, there are many chess games and syntax parsers around, so there should be no shortage of existing source code for you to examine, but if you are looking for some function API like:
Code:
int DefineMyChessGame (char *rules); // "rules" is a string definition
int DefineMyBNF_lexer (char *rules); // "rules" is a string definition
Well, you may (or may not) find some library around to suit your needs, there is certainly no standard procedure here. Like I said, google lex and yacc.