This question already has an answer here:
Currently I have got a system set up where I split each sentence handed to me into it's baser parts and then compare each word against a list of known words. Once I have the verbs, adjectives and nouns contained in each sentence (ignoring all other words in the sentence) I go left to right in the list and try and create a recognisable command from it. However this doesn't allow for multiple commands in one line.
e.g. get the shiny sword and hit troll.
This would read get, shiny, sword, troll. It would ignore the hit part because currently I've only written the parser to handle one verb per line, but this would not be a recognisable command and would tell the player that it doesn't know what they're asking them.
I think my current system of tokenising the words and parsing them as arguments to an arbitrary action function is simple enough but not very elegant.
So I was just wondering what are some good ways to implement text adventure parsers? Are there any tried and true algorithms or ways to approach it?