How to use lark - 10 common examples

To help you get started, we’ve selected a few lark examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github simon816 / Command-Block-Assembly / cmd_ir / reader.py View on Github external
def extern_func(self, node):
        name, params, returns, newline = self.visit_children(node)
        name = name.value
        if isinstance(params, Token):
            params = self.token_to_val(params)
        if isinstance(returns, Token):
            returns = self.token_to_val(returns)
        from .variables import VarType
        params = [(VarType._init_from_parser(params[i*2]), params[(i*2)+1]) \
            for i in range(len(params or []) // 2)]
        returns = [VarType._init_from_parser(r) for r in returns or []]
        existing = self.top.lookup_func(name)
        extern = ExternFunction(name, params, returns)
        if existing:
            existing.expect_signature(extern)
            if not existing.finished and \
               not isinstance(existing, ExternFunction):
                # This is a forward-referenced function, replace references
                # with our extern
                mapping = {existing: extern}
github tartiflette / tartiflette / tests / unit / sdl / test_parse_graphql_sdl_to_ast.py View on Github external
                                                            Token('IDENT', 'Custom'),
                                                        ]),
                                                    ]),
                                                ]),
                                            ]),
                                        ]),
                                    ]),
                                ]),
                            ]),
                        ]),
                    ]),
                ]),
            ]),
        ]),
    ),
    # Schema with invalid double ! modifier
    (
github tartiflette / tartiflette / tests / unit / sdl / test_parse_graphql_sdl_to_ast_full_sdl.py View on Github external
Token('IDENT', 'Date'),
                                    ]),
                                ]),
                            ]),
                        ]),
                    ]),
                ]),
            ]),
        ]),
        Tree('type_system_definition', [
            Tree('type_extension', [
                Tree('input_object_type_extension', [
                    Token('EXTEND', 'extend'),
                    Token('INPUT', 'input'),
                    Tree('name', [
                        Token('IDENT', 'FilterCharacters'),
                    ]),
                    Tree('input_fields_definition', [
                        Tree('input_value_definition', [
                            Tree('name', [
                                Token('IDENT', 'existsSince'),
                            ]),
                            Tree('type', [
                                Tree('named_type', [
                                    Tree('name', [
                                        Token('IDENT', 'Date'),
                                    ]),
                                ]),
                            ]),
                        ]),
                    ]),
                ]),
github tartiflette / tartiflette / tests / unit / sdl / test_parse_graphql_sdl_to_ast.py View on Github external
                                    Token('IDENT', 'acl'),
                                ]),
                                Tree('arguments', [
                                    Tree('argument', [
                                        Tree('name', [
                                            Token('IDENT', 'role'),
                                        ]),
                                        Tree('value', [
                                            Tree('string_value', [
                                                Token('STRING', '"can-filter"'),
                                            ]),
                                        ]),
                                    ]),
                                ]),
                            ]),
                        ]),
                        Tree('input_fields_definition', [
github nightblade9 / dragon / tests / transpiler / lark / transformers / test_haxe_transformer.py View on Github external
def test_string_turns_list_into_empty_string(self):
        h = HaxeTransformer()
        metadata = '@:build(flixel.system.FlxAssets.buildFileReferences("assets", true))'
        data = [Token("LONG_STRING", '"""{}"""'.format(metadata))]
        output = h.string(data)
        self.assertEqual("", output)
github tartiflette / tartiflette / tests / unit / sdl / test_parse_graphql_sdl_to_ast.py View on Github external
                                        Token('IDENT', 'INACTIVE'),
                                    ]),
                                ]),
                            ]),
                            Tree('enum_value_definition', [
                                Tree('enum_value', [
                                    Tree('name', [
                                        Token('IDENT', 'SUSPENDED'),
                                    ]),
                                ]),
                            ]),
                        ]),
                    ]),
                ]),
            ]),
        ]),
    ),
github tartiflette / tartiflette / tests / unit / sdl / test_parse_graphql_sdl_to_ast.py View on Github external
                                        Token('IDENT', 'str'),
                                    ]),
                                    Tree('value', [
                                        Tree('string_value', [
                                            Token('STRING', '"test"')
                                        ]),
                                    ]),
                                ]),
                                Tree('argument', [
                                    Tree('name', [
                                        Token('IDENT', 'int'),
                                    ]),
                                    Tree('value', [
                                        Tree('int_value', [
                                            Token('SIGNED_INT', '14')
                                        ]),
                                    ]),
github tartiflette / tartiflette / tests / unit / sdl / test_parse_graphql_sdl_to_ast.py View on Github external
                                        Token('IDENT', 'NOT_FOUND'),
                                    ]),
                                ]),
                            ]),
                            Tree('enum_value_definition', [
                                Tree('enum_value', [
                                    Tree('name', [
                                        Token('IDENT', 'ACTIVE'),
                                    ]),
                                ]),
                                Tree('directives', [
                                    Tree('directive', [
                                        Tree('name', [
                                            Token('IDENT', 'cache'),
                                        ]),
                                        Tree('arguments', [
                                            Tree('argument', [