コード例 #1
0
ファイル: optimizations.py プロジェクト: vraman/Party
def parse_expr(expr_as_text:str) -> Expr:
    whole_text = '''
    [INPUT_VARIABLES]
    [OUTPUT_VARIABLES]
    [ASSUMPTIONS]
    [GUARANTEES]
    {0};
    '''.format(expr_as_text)

    return dict(par_parser.parse(whole_text))[PAR_GUARANTEES][0]
コード例 #2
0
def parse_ltl(par_text: str, logger: Logger) -> dict:
    #TODO: current version of parser is very restrictive: it allows only the specs of the form:
    # Forall (i,j..) ass_i_j -> (Forall(k) gua_k * Forall(l,m) gua_l_m)
    # it is impossible to have:
    # (Forall(i) a_i  ->  Forall(k) g_k) * (Forall(i,j) a_i_j  ->  Forall(i) g_i)
    # what we can have is:
    # (Forall(i,j,k) ((a_i -> g_i)) * (Forall(i,j) a_i_j -> g_i)
    """ Return {section:data}, see sections in syntax_desc """

    logger.info('parsing input spec..')
    section_name_to_data = dict(par_parser.parse(par_text, lexer=par_lexer))

    #TODO: check unknown signals
    return section_name_to_data
コード例 #3
0
ファイル: par_parser.py プロジェクト: 5nizza/Party
    def test_priorities(self):
        whole_text = '''
        [INPUT_VARIABLES]
        [OUTPUT_VARIABLES]
        [ASSUMPTIONS]
        [GUARANTEES]
        {0};
        '''
        text = whole_text.format('b_0=1 -> c_0=1 * c_1=1 * c_2=1 * c_3=1')

        section_data = dict(par_parser.parse(text))

        expressions = section_data[PAR_GUARANTEES]

        assert len(expressions) == 1, str(expressions)
        assert expressions[0].name == '->'
コード例 #4
0
    def test_priorities(self):
        whole_text = '''
        [INPUT_VARIABLES]
        [OUTPUT_VARIABLES]
        [ASSUMPTIONS]
        [GUARANTEES]
        {0};
        '''
        text = whole_text.format('b_0=1 -> c_0=1 * c_1=1 * c_2=1 * c_3=1')

        section_data = dict(par_parser.parse(text))

        expressions = section_data[PAR_GUARANTEES]

        assert len(expressions) == 1, str(expressions)
        assert expressions[0].name == '->'
コード例 #5
0
ファイル: par_parser.py プロジェクト: 5nizza/Party
def parse_ltl(par_text:str, logger:Logger) -> dict:
    #TODO: current version of parser is very restrictive: it allows only the specs of the form:
    # Forall (i,j..) ass_i_j -> (Forall(k) gua_k * Forall(l,m) gua_l_m)
    # it is impossible to have:
    # (Forall(i) a_i  ->  Forall(k) g_k) * (Forall(i,j) a_i_j  ->  Forall(i) g_i)
    # what we can have is:
    # (Forall(i,j,k) ((a_i -> g_i)) * (Forall(i,j) a_i_j -> g_i)

    """ Return {section:data}, see sections in syntax_desc """

    logger.info('parsing input spec..')
    section_name_to_data = dict(par_parser.parse(par_text, lexer=par_lexer))



    #TODO: check unknown signals
    return section_name_to_data