There are different tools for creating and playing interactive fiction. Many are using text-parsed input, like you can find it in the games "Zork" or "The Hitchhiker's Guide to the Galaxy". These are typically written using Inform or Tads.
See the site's link section for more information on text-parsed if programs. You might also be interested in a compilation of Choose-Your-Own-Adventures written in other languages.