Problem: Run commands in the form of a string.command example:/user/files/ list all;equivalent to:/user/files/ ls -la;another one:post tw fb HOW DO YOU STOP THE TICKLE MONSTER?;equivalent to:    post -tf HOW DO YOU STOP THE TICKLE MONSTER?;Current solution: tokenize string(string, array);switch(first item in array) {    case command:        if ( argument1 > stuff) {           // do the actual work;        }}The problems I see in this solution are:No error checking other than nested ifs-else inside each case. Thescript becomes very big and hard to mantain.Commands and responses are hardcoded.No way of knowing if flags are correct or missing parameters.Lack of intelligence to suggest you might wanted to run $command.And the last thing I can't address is synonyms in different encodings, example:case command:case command_in_hebrew:    do stuff;break;The last one might be trivial, but well, what I want to see is the solid fundations of this kind of program.I'm currently programming this in PHP but might do it in PERL.
How to write a command interpreter/parser?
php;algorithms;perl;parsing;command line