Parser

From HellWiki
Revision as of 10:17, 11 January 2009 by Spunky (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

The command parser is what interprets the commands you type and sets them into action.

Parsing

When you type a command, the first thing the parser has to do is break up your command into its component parts of speech. Since a command is essentially a sentence, the parser breaks it up like this:

  • The verb
  • The direct object
  • A prepositional phrase
  • The indirect object

Your character, of course, is always the subject. Note that the only part of speech that's required for a command is the verb. Commands can require any of these parts of speech to work properly, and most combination are valid. It's probably best to just think of what you're typing as spoken commands to your character, it usually works out to be very much like an english sentence.

Let's take a look at a few examples.

  get all from corpse

This is the most complicated form of a command. Here, the verb would be 'get', 'all' would be the direct object, 'from' is the prepositional phrase, and 'corpse' is the indirect object.

  sit

This is a command that is only the verb itself, which is very common.

 jack into cyberdeck

Here we're missing the direct object, but there is a prepositional phrase and an indirect object. But again, there's no need to get bogged down in the details of which part of speech is which... most of the time it will just make sense. This information is presented mostly to make the next section make more sense.

Matching

Once the parser can break up your command into its component parts of speech, it must then map that command to an object in the game. Since every object in the game can have its own commands, the parser looks for the command you typed on the following objects, in this order:

  1 You, the player
  2 The room you are in
  3 All other objects in the room
  4 Any special features you might have

If it can't match the command you typed to any of those objects, you'll see a message that says 'I don't understand that.' Sometimes you'll also see something like '("anus" is an ambiguous name)'. This means that there is potentially more than one object that can match your command. In that case, it helps the know about the rules for OrdinalMatching. By providing the command parser with the right clues, you can usually tell it exactly what object you want to interact with.

Execution

Once your command has been matched, the server executes it, hopefully with violent and/or hilarious results. You will not always see a message immediately if the command you type takes time, but something should happen within a second or two. If you find cases where you can type a command and nothing every happens, please post about this to the *bugs mailing list on the game.