示例#1
0
def preproof():
    while True:
        yield (proof_kwd() << shift_eq >> (
            lambda pk: choice([
                use(suppress()) << shift_eq >> (lambda supp: choice([
                    intf.locate(kwd('BY')) << times2 >> only() << times2 >>
                    use(usebody()) << times >> read_method() << apply >>
                    (lambda args: tla_ast.PreBy(supp, args[0][0][1], args[0][
                        1], args[1])),
                    intf.locate(
                        kwd('OBVIOUS') << second >> read_method() << apply >>
                        (lambda meth: tla_ast.PreObvious(supp, meth)))
                ])),

                # locate (kwd "OMITTED" <!> (PreOmitted Explicit)) ;
                intf.locate(
                    kwd('OMITTED') << bang >> tla_ast.PreOmitted(tla_ast.
                                                                 Explicit())),

                #  locate begin
                #           preno <**> use prestep
                #           <$> (fun (pn, stp) ->
                #                   PreStep (pk, pn, stp))
                #         end ;
                intf.locate(preno() << times2 >> use(prestep()) << apply >>
                            (lambda pn_stp: tla_ast.PreStep(
                                pk, pn_stp[0], pn_stp[1])))
            ])))
示例#2
0
def proof():
    while True:
        yield choice([
            star1(use(preproof())),
            intf.locate(succeed(tla_ast.PreOmitted(tla_ast.Implicit()))) <<
            apply >> (lambda pp: [pp])
        ]) << apply >> toplevel
示例#3
0
def parse_():
    def apply_module(nm_exs_mus):
        (name, extends), modunits = nm_exs_mus
        extends = list() if extends is None else extends
        return nodes.Module(name=name,
                            extendees=extends,
                            instancees=list(),
                            body=[i for j in modunits for i in j])

    while True:
        yield (intf.punct('----') << second_commit >> intf.kwd('MODULE') <<
               second_commit >> intf.locate(intf.anyname()) << first >>
               intf.punct('----') << times >> optional(
                   intf.kwd('EXTENDS') << second >> sep1(
                       intf.punct(','), intf.locate(intf.anyident()))) <<
               times2 >> use(modunits()) << first >> intf.punct('====') <<
               apply >> apply_module)
示例#4
0
 def f():
     # RULE: ('AXIOM' | 'ASSUME' | 'ASSUMPTION')
     #       [anyident '=='] expr [read_method]
     return (
         (kwd('AXIOM') << or_ >> kwd('ASSUME') << or_ >>
          kwd('ASSUMPTION')) << second_commit >> optional(
              intf.locate(intf.anyident() << first >> punct('==') <<
                          times2 >> use(ep.expr(False)))) << times >>
         optional(use(pfp.read_method())) << apply >> apply_axiom)
示例#5
0
 def f():
     return (
         (kwd('THEOREM') << or_ >> kwd('PROPOSITION') << or_ >>
          kwd('COROLLARY') << or_ >> kwd('LEMMA')) << second_commit >>
         optional(intf.locate(intf.anyident() << first >> punct('==')))
         << times >> choice([
             use(ep.sequent(False)),
             use(ep.expr(False)) << apply >>
             (lambda e: nodes.Sequent(list(), e))
         ]) << times >> optional(use(pfp.method_prs_read_method())) <<
         times >> use(pfp.proof()) << apply >> apply_theorem_proof)
示例#6
0
        def f():
            return choice([
                # ['CONSTANT' | 'CONSTANTS'] opdecl (',' opdecl)*
                kwd('CONSTANT') << or_ >> kwd('CONSTANTS') << second_commit >>
                sep1(punct(','), use(ep.opdecl())) << apply >>
                (lambda cs: [nodes.Constants(cs)]),

                # 'RECURSIVE' opdecl (',' opdecl)*
                kwd('RECURSIVE') << second_commit >> sep1(
                    punct(','), use(ep.opdecl())) << apply >>
                (lambda cs: [nodes.Recursives(cs)]),

                # ['VARIABLE' | 'VARIABLES'] anyident (',' anyident)*
                kwd('VARIABLE') << or_ >> kwd('VARIABLES') << second_commit >>
                sep1(punct(','), locate(intf.anyident())) << apply >>
                (lambda vs: [nodes.Variables(vs)])
            ])
示例#7
0
def parse():
    while True:
        yield intf.locate(use(parse_()))
示例#8
0
def definable():
    while True:
        yield intf.locate(
            sep1(intf.punct('!'), choice([intf.anyop(),
                                          intf.anyident()])) << apply >>
            (lambda ids: tla_ast.Dvar('!'.join(ids))))