moo.core.parse.Parser

class moo.core.parse.Parser(lexer, caller)

The parser instance is created by the avatar. A new instance is created for each command invocation.

__init__(lexer, caller)

Create a new parser object for the given command, as issued by the given caller, using the registry.

Methods

__init__(lexer, caller)

Create a new parser object for the given command, as issued by the given caller, using the registry.

find_object(specifier, name[, return_list])

Look for an object, with the optional specifier, in the area around the person who entered this command.

get_dobj([lookup])

Return the direct object as an Object.

get_dobj_str()

Return the direct object as a raw string.

get_iobj([lookup])

Return the first indirect-object Object found across any preposition in the command, or raise NoSuchObjectError if none resolved.

get_pobj(prep[, lookup])

Return the indirect object for prep as an Object.

get_pobj_spec_str(prep[, return_list])

Return the specifier (my, the, possessive form) used with the indirect object for prep.

get_pobj_str(prep[, return_list])

Return the indirect object for prep as a raw string.

get_pronoun_object(pronoun)

Resolve pronoun-like dobj/iobj strings to the object they refer to.

get_search_order()

Return the canonical list of objects to search for verbs, in priority order: caller, inventory, location, dobj, pobj objects.

get_verb()

For each of these items the parser will look for a verb using the following rules:

has_dobj([lookup])

Return True if the parser resolved a direct object to a real Object.

has_dobj_str()

Return True if a direct object string was given on the command line, regardless of whether it resolved to an object.

has_iobj()

Return True if any preposition resolved to a real object.

has_pobj(prep)

Return True if the parser resolved an indirect object for prep to a real Object.

has_pobj_str(prep)

Return True if an indirect object string was given for prep, regardless of whether it resolved to an object.

Attributes

caller

The Object that issued the command (the player who typed it).

command

The full, unparsed command string.

words

The tokenised words from the command.

dobj_str

The direct-object substring.

dobj_spec_str

Direct-object specifier.

dobj

The resolved direct object as an Object, or None if it could not be resolved or no direct object was given.

prepositions

Dict mapping each preposition that appeared to [spec_str, obj_str, obj] triples.

verb

The Verb selected by dispatch, set after get_verb() runs.

this

The Object the verb was matched on (last-match-wins; see Command Parser Reference).