예제 #1
0
                SubpKind.alt_procedure("procedure"),
                SubpKind.alt_function("function")
            ),
            A.defining_name, "is",
            "new", A.static_name,
            Opt("(", List(A.param_assoc, sep=",", list_cls=AssocList), ")"),
            A.aspect_spec, sc(),
        ),
    ),

    exception_decl=ExceptionDecl(
        A.defining_id_list, ":", "exception",
        Opt(A.renaming_clause), A.aspect_spec, sc()
    ),

    basic_decls=List(Or(A.basic_decl, Skip(ErrorDecl)), empty_valid=True),

    package_renaming_decl=PackageRenamingDecl(
        "package", A.defining_name, A.renaming_clause, A.aspect_spec, sc()
    ),

    package_decl=package_decl_factory(PackageDecl),

    basic_decl=Or(
        A.null_subp_decl,
        A.abstract_subp_decl,
        A.expr_fn,
        A.subp_renaming_decl,
        A.body_stub,
        A.generic_instantiation,
        A.body,
예제 #2
0
파일: test.py 프로젝트: nyulacska/langkit
    print('== {} =='.format(label))

    @has_abstract_list
    class FooNode(ASTNode):
        pass

    class Example(FooNode):
        f = Field(FooNode)

    @synthetic
    class SynthExample(FooNode):
        pass

    @synthetic
    class ListSynthExample(FooNode.list):
        pass

    foo_grammar = Grammar('main_rule')
    foo_grammar.add_rules(main_rule=Example(
        'example', parser_constructor(SynthExample, ListSynthExample)))

    emit_and_print_errors(foo_grammar)
    print('')


run('List', lambda _, cls: List('example', list_cls=cls))
run('Null', lambda cls, _: Null(cls))
run('Skip', lambda cls, _: Skip(cls))
run('Transform', lambda cls, _: cls())
print('Done')
예제 #3
0
        ";",
    ),
    context_clauses=List(A.with_decl, empty_valid=True),

    # Ada context clauses parsing
    #########################################
    ada_with_clause=AdaWith(
        Limited("limited"),
        Private("private"),
        "with",
        List(A.static_name, sep=","),
        ";",
    ),
    ada_context=List(A.ada_context_item, empty_valid=True),
    ada_context_item=Or(A.ada_with_clause, A.ada_use_clause, A.ada_pragma),
    ada_context_skip=List(Or(Skip(AdaSkip), )),
    ada_use_clause=AdaUse("use", A.ada_context_skip.dont_skip(";"), ";"),
    ada_pragma=AdaPragma("pragma", A.ada_context_skip.dont_skip(";"), ";"),
    ada_subp_kind=Or(AdaEntityKind.alt_procedure(l_id("procedure")),
                     AdaEntityKind.alt_function(l_id("function"))),
    ada_pkg_kind=AdaEntityKind.alt_package("package"),
    ada_library_item=AdaLibraryItem(
        Opt(
            AdaGeneric(
                l_id("generic"),
                List(
                    Or(
                        # Parse formals that start with "with".
                        AdaWithFormal(
                            "with",