def runTest(self): xml = b'<Function name="f"><Parameters><Parameter name="a" typing="int"/></Parameters><Instruction>do_this</Instruction></Function>' f = pypeg2.xmlast.xml2thing(xml, globals()) self.assertEqual(f.name, pypeg2.Symbol("f")) self.assertEqual(f.parms["a"].name, pypeg2.Symbol("a")) self.assertEqual(f.parms["a"].typing, pypeg2.Symbol("int")) self.assertEqual(f[0], "do_this")
def runTest(self): parser = pypeg2.Parser() r = parser.parse("hello, world", (pypeg2.name(), ",", pypeg2.name())) self.assertEqual( r, ( '', [ pypeg2.attr.Class(name='name', thing=pypeg2.Symbol('hello'), subtype=None), pypeg2.attr.Class(name='name', thing=pypeg2.Symbol('world'), subtype=None) ] ) )
def runTest(self): parser = pypeg2.Parser() r = parser.parse("hello, world", pypeg2.attr("some", pypeg2.Symbol)) self.assertEqual( r, ( ', world', pypeg2.attr.Class(name='some', thing=pypeg2.Symbol('hello'), subtype=None) ) )
def runTest(self): xml = b'<Key name="foo">bar</Key>' thing = pypeg2.xmlast.xml2thing(xml, globals()) self.assertEqual(thing.name, pypeg2.Symbol("foo")) self.assertEqual(thing, "bar")
def runTest(self): parser = pypeg2.Parser() r = parser.parse("hello, world", pypeg2.Symbol) self.assertEqual(r, (", world", pypeg2.Symbol("hello")))
def runTest(self): x = ComposeAttribute() x.name = pypeg2.Symbol("hello") t = pypeg2.compose(x) self.assertEqual(t, "hello")