def testCanParseAndTranslateMultilineElements(self): jsx = "return <a>\n\t<b/>\n\t<b/>\n</a>" parser = MCleverParser(text=jsx) stmt = parser.doParse(parser.return_statement, True) self.assertIsNotNone(stmt.expression) writer = CodeWriter(Dialect.M, Context.newGlobalContext()) stmt.toDialect(writer) out = str(writer) self.assertEquals(jsx, out)
def testCanParseAndTranslateMultilineAttributes(self): jsx = "return <a \n\tx=\"abc\"\n\ty=\"def\"\n\tz=\"stuff\" />" parser = MCleverParser(text=jsx) stmt = parser.doParse(parser.return_statement, True) self.assertIsNotNone(stmt.expression) writer = CodeWriter(Dialect.M, Context.newGlobalContext()) stmt.toDialect(writer) out = str(writer) self.assertEquals(jsx, out)
def parseMResource(self, resourceName): stream = self.getResourceAsStream(resourceName, 'rb') self.assertIsNotNone("resource not found:" + resourceName, stream) parser = MCleverParser(stream=stream) return self.parse(MPromptoBuilder, parser)
def parseMString(self, code): parser = MCleverParser(text=code) return self.parse(MPromptoBuilder, parser)