def args(cls, player): return parser.ObjectIn(player)("item")
def args(cls, player): item = parser.ObjectIn(player) destination = parser.NearbyObject(player) return (item("item") + pyp.Keyword("to") + destination("destination") | destination("destination") + item("item") | item("item") + pyp.Keyword("in") + destination("destination"))
def args(cls, player): return parser.ObjectIn(player)("item") | parser.EmptyLine()
def test_combining_object_tokens_partial(self): grammar = parser.ObjectIn(self.player) + pyp.Word(pyp.alphas) parse_result = grammar.parseString("app pie") self.assertEqual(list(parse_result), [self.objects["apple"], "pie"])
def test_objectin_notfound(self): self.assert_error_message(parser.NotFoundError, "I don't know of an " "object in lobby called \"asdf\"", parser.ObjectIn(self.lobby).parseString, "asdf", parseAll=True)
def test_objectin_ambiguous(self): self.assertRaises(parser.AmbiguityError, parser.ObjectIn(self.lobby).parseString, "Play", parseAll=True)
def test_objectin(self): self.assert_parse(parser.ObjectIn(self.lobby), "Player", self.player) self.assert_parse(parser.ObjectIn(self.lobby), "Players", self.neighbor)