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.Return the direct object as a raw string.
get_iobj([lookup])Return the first indirect-object
Objectfound across any preposition in the command, or raiseNoSuchObjectErrorif none resolved.get_pobj(prep[, lookup])Return the indirect object for
prepas anObject.get_pobj_spec_str(prep[, return_list])Return the specifier (
my,the, possessive form) used with the indirect object forprep.get_pobj_str(prep[, return_list])Return the indirect object for
prepas 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
Trueif the parser resolved a direct object to a realObject.Return
Trueif a direct object string was given on the command line, regardless of whether it resolved to an object.has_iobj()Return
Trueif any preposition resolved to a real object.has_pobj(prep)Return
Trueif the parser resolved an indirect object forprepto a realObject.has_pobj_str(prep)Return
Trueif an indirect object string was given forprep, regardless of whether it resolved to an object.Attributes
The
Objectthat issued the command (the player who typed it).The full, unparsed command string.
The tokenised words from the command.
The direct-object substring.
Direct-object specifier.
The resolved direct object as an
Object, orNoneif it could not be resolved or no direct object was given.Dict mapping each preposition that appeared to
[spec_str, obj_str, obj]triples.The
Verbselected by dispatch, set afterget_verb()runs.The Object the verb was matched on (last-match-wins; see Command Parser Reference).