Пример #1
0
def default_sort():
    ds = sig._default_sort
    if ds != None: return ds
    if not iu.get_numeric_version() <= [1, 2]:
        raise IvyError(None, 'unspecified type')
    ds = lg.UninterpretedSort('S')
    add_sort(ds)
    sig._default_sort = ds
    return ds
Пример #2
0
def default_sort():
    ds = sig._default_sort
    if ds != None: return ds
    if not iu.get_numeric_version() <= [1,2]:
        raise IvyError(None,'unspecified type')
    ds = lg.UninterpretedSort('S')
    add_sort(ds)
    sig._default_sort = ds
    return ds
Пример #3
0
def _find_sort(type_name):
    if allow_unsorted:
        if type_name == 'S': return lg.TopS
        return lg.UninterpretedSort(type_name)
    try:
        return sig.sorts[type_name]
    except KeyError:
        if type_name == 'S':
            if iu.get_numeric_version() <= [1, 2]:
                return default_sort()
            raise IvyError(None, "unspecified type")
        raise IvyError(None, "unknown type: {}".format(type_name))
Пример #4
0
def _find_sort(type_name):
    if allow_unsorted:
        if type_name == 'S': return lg.TopS
        return lg.UninterpretedSort(type_name)
    try:
        return sig.sorts[type_name]
    except KeyError:
        if type_name == 'S':
            if iu.get_numeric_version() <= [1,2]:
                return default_sort()
            raise IvyError(None,"unspecified type")
        raise IvyError(None,"unknown type: {}".format(type_name))
Пример #5
0
def parse(s, nested=False):
    global error_list
    global stack
    if not nested:
        error_list = []
        stack = []
    vernum = iu.get_numeric_version()
    with LexerVersion(vernum):
        # shallow copy the parser and lexer to try for re-entrance (!!!)
        res = copy.copy(parser).parse(s, lexer=copy.copy(lexer))
    if error_list:
        raise iu.ErrorList(error_list)
    return res
Пример #6
0
def parse(s, nested=False):
    global error_list
    global stack
    if not nested:
        error_list = []
        stack = []
    vernum = iu.get_numeric_version()
    with LexerVersion(vernum):
        # shallow copy the parser and lexer to try for re-entrance (!!!)
        res = copy.copy(parser).parse(s, lexer=copy.copy(lexer))
    if error_list:
        raise iu.ErrorList(error_list)
    return res
Пример #7
0
    p[0] = p[1]
    p[0].append(p[3])


def p_upaxes(p):
    "upaxes : "
    p[0] = []


def p_upaxes_upaxes_upax(p):
    "upaxes : upaxes upax"
    p[0] = p[1]
    p[0].append(p[2])


if True or iu.get_numeric_version() <= [1]:

    def p_upax_params_apps_in_action_arrow_ensures_fmla(p):
        "upax : PARAMS tterms IN action ARROW requires ensures"
        p[0] = UpdatePattern(ConstantDecl(*p[2]), p[4], p[6], p[7])


else:

    def p_upax_params_apps_in_action_ensures_fmla(p):
        "upax : PARAMS tterms IN action requires ensures"
        p[0] = UpdatePattern(ConstantDecl(*p[2]), p[4], p[5], p[6])


def p_requires(p):
    "requires : "
Пример #8
0
 def defines(self):
     if iu.get_numeric_version() <= [1, 6]:
         return []
     return [(c.label.relname, lineno(c), type(self)) for c in self.args]
Пример #9
0
#
# Copyright (c) Microsoft Corporation. All Rights Reserved.
#
from ivy_concept_space import NamedSpace, ProductSpace, SumSpace
from ivy_ast import *
from ivy_actions import AssumeAction, AssertAction, EnsuresAction, SetAction, AssignAction, HavocAction, IfAction, AssignFieldAction, NullFieldAction, CopyFieldAction, InstantiateAction, CallAction, LocalAction, LetAction, Sequence, UpdatePattern, PatternBasedUpdate, SymbolList, UpdatePatternList, Schema, ChoiceAction, NativeAction, WhileAction
from ivy_lexer import *
import ivy_utils as iu
import copy

import ply.yacc as yacc
import string

if not (iu.get_numeric_version() <= [1, 2]):

    precedence = (
        ('left', 'SEMI'),
        ('left', 'IF'),
        ('left', 'ELSE'),
        ('left', 'OR'),
        ('left', 'AND'),
        ('left', 'TILDA'),
        ('left', 'EQ', 'LE', 'LT', 'GE', 'GT'),
        ('left', 'TILDAEQ'),
        ('left', 'COLON'),
        ('left', 'PLUS'),
        ('left', 'MINUS'),
        ('left', 'TIMES'),
    )

else:
Пример #10
0

def get_lineno(p, n):
    return iu.Location(iu.filename, p.lineno(n))


def symbol(s):
    return Variable(s, universe) if str.isupper(s[0]) else Constant(s)


def p_atype_symbol(p):
    'atype : SYMBOL'
    p[0] = p[1]


if not (iu.get_numeric_version() <= [1, 2]):

    def p_atype_atype_dot_symbol(p):
        'atype : atype DOT SYMBOL'
        if isinstance(p[1], This):
            p[0] = p[3]
        else:
            p[0] = p[1] + '.' + p[3]

    def p_atype_this(p):
        'atype : THIS'
        p[0] = This()
        p[0].lineno = get_lineno(p, 1)


if iu.get_numeric_version() <= [1, 6]:
Пример #11
0
    return iu.Location(iu.filename,p.lineno(n))

def symbol(s):
    return Variable(s,universe) if str.isupper(s[0]) else Constant(s)

def p_aterm_symbol(p):
    'aterm : SYMBOL'
    p[0] = App(p[1])
    p[0].lineno = get_lineno(p,1)

def p_aterm_aterm_terms(p):
    'aterm : aterm LPAREN terms RPAREN'
    p[0] = p[1]
    p[0].args.extend(p[3])

if iu.get_numeric_version() <= [1,2]:

    def p_term_term_colon_term(p):
        'aterm : aterm COLON SYMBOL'
        p[0] = compose_atoms(p[1],App(p[3]))
        p[0].lineno = get_lineno(p,2)

else:

    def p_term_term_dot_term(p):
        'aterm : aterm DOT SYMBOL'
        p[0] = compose_atoms(p[1],App(p[3]))
        p[0].lineno = get_lineno(p,2)

def p_atype_symbol(p):
    'atype : SYMBOL'
Пример #12
0
 def defines(self):
     if iu.get_numeric_version() <= [1,6]:
         return []
     return [(c.label.relname,lineno(c),type(self)) for c in self.args]