Using Context Free Grammers
-
hi Suppose I want an application which takes a source file and outputs its data members and functions. Supposed to develop into a kind of class view explorer. Regarding parsing the source file .... should i go for using regular expressions rules for this parsing or should i go for a language representation in context free grammer[CFG] and use the CFG rules for parsing or is there any other possible ideas for source file parsing awaiting advice fordge
-
hi Suppose I want an application which takes a source file and outputs its data members and functions. Supposed to develop into a kind of class view explorer. Regarding parsing the source file .... should i go for using regular expressions rules for this parsing or should i go for a language representation in context free grammer[CFG] and use the CFG rules for parsing or is there any other possible ideas for source file parsing awaiting advice fordge
-
hi Suppose I want an application which takes a source file and outputs its data members and functions. Supposed to develop into a kind of class view explorer. Regarding parsing the source file .... should i go for using regular expressions rules for this parsing or should i go for a language representation in context free grammer[CFG] and use the CFG rules for parsing or is there any other possible ideas for source file parsing awaiting advice fordge
I think that you should use a CF Grammer for parsing the file. The advantage of the CFG is, that when you have your grammer and rules, you can easely deduce code from it by yourself or a tool. An other advantage of a CFG over RegEx is that with a CFG, you almost always have a good overview of what you are doing and where you are doing it, RegEx tend to get complicated really fast. A recursive parser (from a CFG) is also easier to debug, than a state based RegEx parser, since you always have stack traces and you exacty know where you are and how you came there. IMHO I think that regular expressions are great for validating strings (like postal codes, phone numbers, etc..), but for the real parsing you shouls stick with grammers and parsers. Behind every great black man... ... is the police. - Conspiracy brother Blog[^]
-
hi Suppose I want an application which takes a source file and outputs its data members and functions. Supposed to develop into a kind of class view explorer. Regarding parsing the source file .... should i go for using regular expressions rules for this parsing or should i go for a language representation in context free grammer[CFG] and use the CFG rules for parsing or is there any other possible ideas for source file parsing awaiting advice fordge
Probably CFG. If you want to try regular expressions, then go download and install Regex++. It has some example programs like taking C++ file and (thru callbacks) outputs an html file. INTP "The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes." Andrew W. Troelsen