Example #1
0
    def test_simple_values(self):
        ast, _ = self.ftl_parser.parse(ftl('''
            foo = Foo
            bar = Bar
        '''))

        self.assertEqual(
            ast.traverse(lambda x: x).toJSON(),
            ast.toJSON()
        )
Example #2
0
    def test_complex_values(self):
        ast, _ = self.ftl_parser.parse(ftl('''
            foo = Foo
            foo = Foo { bar }
                [bar]  AAA { $num ->
                           [one] One
                          *[other] Many { NUMBER($num) }
                       } BBB
        '''))

        self.assertEqual(
            ast.traverse(lambda x: x).toJSON(),
            ast.toJSON()
        )
Example #3
0
def ftl_message_to_json(code):
    ast, errors = ftl_parser.parse(ftl(code), with_source=False)
    return ast.body[0].toJSON()
Example #4
0
def ftl_resource_to_json(code):
    ast, errors = ftl_parser.parseResource(ftl(code), with_source=False)
    return ast