I am building a program in C++ which involves parsing and interpreting user input. For instance, the user might type in "move player up 2* (2 + 3 )" and the program will respond by moving the player up by 10 spaces. There will be many other possible commands, and the execution will not necessarily happen from left-to-right order (as in the example above, where the brackets indicate order of operations). My knowledge of computational linguistics is very limited, but I believe that I am describing a Domain Specific Language with a context-free grammar. (Please correct me if I am wrong about this).

I could write code myself that defines the syntax of this language, but I'd be re-inventing the wheel. What C++ libraries are available that would help me parse input strings according to a specific grammar and then interpret them at run-time?

Important note: most of the DSL oriented libraries that I've researched (ie. Boost.proto and Boost.spirit) seem to be geared towards designing DSL's which will be implemented at compile-time, within the C++ code itself. This is not what I want; instead, I want libraries that will help me define and manage a DSL that is operated exclusively at run-time, through user inputted strings.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.