Ejemplo n.º 1
0
Archivo: proof.py Proyecto: jamella/ivy
 def __init__(self, filename):
     ag = ivy_new()
     try:
         ivy_load_file(open(filename), ag)
     except IvyError as e:
         e.filename = filename
         raise e
     self.ivy_ag = ag
     self.ivy_interp = ag.domain
Ejemplo n.º 2
0
 def __init__(self, filename):
     ag = ivy_new()
     try:
         ivy_load_file(open(filename), ag)
     except IvyError as e:
         e.filename = filename
         raise e
     self.ivy_ag = ag
     self.ivy_interp = ag.domain
Ejemplo n.º 3
0
def source_file(fn, f, **kwargs):
    try:
        with iu.SourceFile(fn):
            ivy_load_file(f, **kwargs)
            ivy_module.module.name = fn[:fn.rindex('.')]
    except IvyError as e:
        if not hasattr(e, 'filename'):
            e.filename = fn
        print str(e)
        sys.exit(1)
Ejemplo n.º 4
0
Archivo: ivy.py Proyecto: odedp/ivy
def source_file(fn,f,**kwargs):
    try:
        with iu.SourceFile(fn):
            ivy_load_file(f,**kwargs)
            ivy_module.module.name = fn[:fn.rindex('.')]
    except IvyError as e:
        if not hasattr(e,'filename'):
            e.filename = fn
        print str(e)
        sys.exit(1)
Ejemplo n.º 5
0
def source_file(fn, f, **kwargs):
    try:
        with iu.SourceFile(fn):
            ivy_load_file(f, **kwargs)
            ivy_module.module.name = fn[:fn.rindex('.')]
    except IvyError as e:
        if not hasattr(e, 'filename'):
            e.filename = fn
        print str(e)

        if hasattr(e, 'source_location'):
            print e.source_location.context_line
            if e.source_location.column:
                print ' ' * (e.source_location.column - 1) + '^'
        sys.exit(1)
Ejemplo n.º 6
0
Archivo: ivy.py Proyecto: asyaf/ivy
def ivy_init():
    read_params()

    #    if mode.get() == "ivy2":
    #        return ivy_init2()

    if len(sys.argv) < 2 or len(sys.argv) > 3:
        usage()

    files = [(fn, open_read(fn)) for fn in sys.argv[1:]]

    if files[0][0].endswith('.a2g'):
        fn, f = files.pop(0)
        ag = pickle.load(f)

        if not hasattr(ag.domain, 'all_relations'):
            #            print "reconstructing all_relations"
            ag.domain.all_relations = []
            for x in ag.domain.relations:
                ag.domain.all_relations.append((x, ag.domain.relations[x]))
            for (x, y) in ag.domain.concepts:
                ag.domain.all_relations.append(
                    (x.atom.relname, len(x.atom.args)))
        ivy_logic.sig = ag.domain.sig  # TODO: make this an environment
        f.close()
    else:
        #        print "creating new"
        ag = ivy_new()

    if files:
        fn, f = files.pop(0)
        if not fn.endswith('.ivy') and not fn.endswith('.dfy'):
            usage()
        try:
            #            print "loading file %s" % fn
            with iu.SourceFile(fn):
                ivy_load_file(f, ag)
        except IvyError as e:
            if not hasattr(e, 'filename'):
                e.filename = fn
            print repr(e)
            sys.exit(1)
    return ag
Ejemplo n.º 7
0
Archivo: ivy.py Proyecto: ZZHGit/ivy
def ivy_init():
    read_params()

#    if mode.get() == "ivy2":
#        return ivy_init2()

    if len(sys.argv) < 2 or len(sys.argv) > 3:
        usage()

    files = [(fn,open_read(fn)) for fn in sys.argv[1:]]

    if files[0][0].endswith('.a2g'):
        fn,f = files.pop(0)
        ag = pickle.load(f)

        if not hasattr(ag.domain,'all_relations'):
#            print "reconstructing all_relations"
            ag.domain.all_relations = []
            for x in ag.domain.relations:
                ag.domain.all_relations.append((x,ag.domain.relations[x]))
            for (x,y) in ag.domain.concepts:
                ag.domain.all_relations.append((x.atom.relname,len(x.atom.args)))
        ivy_logic.sig = ag.domain.sig # TODO: make this an environment
        f.close()
    else:
#        print "creating new"
        ag = ivy_new()

    if files:
        fn,f = files.pop(0)
        if not fn.endswith('.ivy') and not fn.endswith('.dfy'):
            usage()
        try:
#            print "loading file %s" % fn
            with iu.SourceFile(fn):
                ivy_load_file(f,ag)
        except IvyError as e:
            if not hasattr(e,'filename'):
                e.filename = fn
            print repr(e)
            sys.exit(1)
    return ag