[sorrows-mudlib] r203 committed - Add another special parsing case where a leading preposition is used.....

0 views
Skip to first unread message

sorrows...@googlecode.com

unread,
Feb 6, 2011, 6:46:04 AM2/6/11
to sorrows-mud...@googlegroups.com
Revision: 203
Author: richard.m.tew
Date: Sun Feb 6 03:45:25 2011
Log: Add another special parsing case where a leading preposition is
used.. "look in chest", "look at bob", "drink from cup".
http://code.google.com/p/sorrows-mudlib/source/detail?r=203

Modified:
/trunk/mudlib/services/parser.py

=======================================
--- /trunk/mudlib/services/parser.py Sun Feb 6 03:07:58 2011
+++ /trunk/mudlib/services/parser.py Sun Feb 6 03:45:25 2011
@@ -86,6 +86,9 @@

self.syntaxByCommand[commandName] = patterns

+ # TODO: For now this is constructed of special casing. With a few more
+ # use cases driving the fleshing out of its needs, it should be ready
+ # to do a more generic rewrite.
def ExecuteGameCommand(self, context):
"""
Called by the GameCommand class to handle parsing the arguments
that
@@ -105,6 +108,17 @@

if len(tokens) == 1 or len(tokens) == 2:
# verb OBJECT / verb preposition OBJECT
+ if len(tokens) == 2:
+ # Convert "verb preposition OBJECT" -> "verb OBJECT"
+ preposition = tokens[0]
+ if preposition.lower() != preposition:
+ continue
+
+ tokens = tokens[1:]
+ idx = argString.find(preposition)
+ if idx == -1:
+ continue
+ argString = argString[idx+len(preposition):].lstrip()

# Incorrect arguments automatically generates a usage
string.
if argString == "":

Reply all
Reply to author
Forward
0 new messages