interpreter needed
-
Hi ! My C++ app needs to read an external text file and display it on screen. But, this text file can contain specific commands to change what has to be displayed by my app. For instance, the text file could be : Hello [if foo] Foo [else] Bar [endif] and my app should display (depending of foo) : Hello Foo. The problem is that I don't know where to start. Should I just parse the text file and just check each [] ? Should I write a real interpreter (I have no idea how to do this). Can I reuse something existing ? Any help, suggestions or idea are welcome ! THanks ! Jerome
-
Hi ! My C++ app needs to read an external text file and display it on screen. But, this text file can contain specific commands to change what has to be displayed by my app. For instance, the text file could be : Hello [if foo] Foo [else] Bar [endif] and my app should display (depending of foo) : Hello Foo. The problem is that I don't know where to start. Should I just parse the text file and just check each [] ? Should I write a real interpreter (I have no idea how to do this). Can I reuse something existing ? Any help, suggestions or idea are welcome ! THanks ! Jerome
Depends how hardcore you want to get. If it's simple you could get away with just parsing and using a simple hash table for your variables. Either way you'll want to take a look at these [http://www.codeproject.com/cpp/crafting\_interpreter\_p1.asp](http://
http://www.codeproject.com/cpp/crafting_interpreter_p1.asp)[[^](http://
http://www.codeproject.com/cpp/crafting_interpreter_p1.asp)] http://www.codeproject.com/cpp/crafting_interpreter_p2.asp[^]