Two-word parser

From IFWiki

A rudimentary parser which can only handle commands one or two words in length (most commonly of the form VERB NOUN, e.g., "GET KNIFE", "OPEN CHEST", "EXAMINE ROCK"). Many homebrew parsers are of this type, because of the relative ease of programming. Modern parsers, on the other hand, can handle much more complex commands; in particular, multiple-object commands and multiple commands in a single input line (e.g., "OPEN THE CHEST THEN GET THE KNIFE AND THE ROCK").

The best-known game using a two-word parser is probably the original Adventure.

Whereas Infocom-type parsers are based on a grammar of English, the appeal of the two-word parser is that it is easy to accept a wide variety of inputs. For example, the Adventure parser divides its vocabulary into "motion words", "action words", "nouns", and "canned responses", and parses the one- or two-word command according to its words' categories rather than their position in the sentence. Thus, "LAMP GET" works just as well as "GET LAMP"; and the game successfully responds to both "CROSS [motion word] BRIDGE [unrecognized word]" and "FOLLOW [unrecognized word] STREAM [motion word]" because unrecognized words are ignored in a command containing a motion word.

Later iterations of the two-word parser brought it closer in spirit to an Infocom-type parser. David Long's Adventure 5 supported a list of "appropriate adjectives" for each noun, in order to make "GET BRASS LAMP" a valid synonym for "GET LAMP"; and also implemented multi-command parsing, so that "GET KEYS AND LAMP" would be parsed into the pair of commands "GET KEYS" and (subsequently) "GET LAMP". David Platt's Adventure 3 implemented a list of "ignoreable words", in order to make "GET THE LAMP" a valid synonym for "GET LAMP". However, unlike a strictly grammar-based parser, the Long and Platt parsers would happily respond to commands such as "BRASS LAMP GET" and "GET THE THE THE LAMP" respectively.