Пример #1
0
  def create(outdir, tc):
    grammar = tc.grammar
    c = adpc.Config
    os.chdir(c.workdir)
    shutil.copy(os.path.join(c.grammars, grammar), c.workdir)

    os.mkdir(grammar[:-4])

    out = tc.unique_filename() + Suffix.mf + Suffix.out
    testbox.checkFilename(out)
    err = tc.unique_filename() + Suffix.mf + Suffix.err
    testbox.checkFilename(err)
    f1 = os.path.join(outdir, out)
    f2 = os.path.join(outdir, err)
    i = sysext.sys(c.fe,
        [ grammar, '-p', c.fe_path, '--pure-prefix' ],
        f1, f2)
    if i != 0:
      raise cg.CallError('Metafrontend failed'
          + testbox.look_into([f1, f2]))
    out = tc.unique_filename() + Suffix.java + Suffix.out
    testbox.checkFilename(out)
    err = tc.unique_filename() + Suffix.java + Suffix.err
    testbox.checkFilename(err)
    f1 = os.path.join(outdir, out)
    f2 = os.path.join(outdir, err)
    i = sysext.sys(c.javac,
        [ '-cp', c.classpath,
          grammar[:-4] + os.path.sep + grammar[:-4] + '.java' ],
        f1, f2)
    if i != 0:
      raise cg.CallError('Java Compiler failed'
          + testbox.look_into([f1, f2]))
Пример #2
0
  def execute(outdir, progname, filename, tc, sys_fn = sysext.sys):
    c = adpc.Config
    os.chdir(c.workdir)

    para = []
    if tc.flavour == 'rna' or tc.flavour == 'window':
      para += Call.default_opts_rna
    else:
      para += Call.default_opts
    if hasattr(tc, 'parameter'):
      para += tc.parameter.split()

    out = tc.unique_filename() + Suffix.out
    testbox.checkFilename(out)
    err = tc.unique_filename() + Suffix.err
    testbox.checkFilename(err)
    f1 = os.path.join(outdir, out)
    f2 = os.path.join(outdir, err)
    i = sys_fn(c.java,
        [ '-cp', c.classpath,
          progname + '.' + progname, "-f", os.path.join(c.input, filename)]
        + tc.default_parameter + para,
        f1, f2)
    if i != 0:
      raise cg.CallError("error executing adp program (exit status: " + str(i) + ")"
        + testbox.look_into([f1, f2]))
Пример #3
0
Файл: call.py Проект: u-u-h/adpc
 def clean(outdir, tc):
   c = adpc.Config
   os.chdir(c.workdir)
   out = tc.unique_filename() + Suffix.clean + Suffix.out
   testbox.checkFilename(out)
   err = tc.unique_filename() + Suffix.clean + Suffix.err
   testbox.checkFilename(err)
   f1 = os.path.join(outdir, out)
   f2 = os.path.join(outdir, err)
   i = sysext.sys(c.make, ["clean"], f1, f2)
   if i != 0:
     raise cg.CallError("make clean failed" + testbox.look_into([f1, f2]))
   os.unlink(tc.grammar)
   ls = os.listdir(c.workdir)
   if not (ls == [] or ls == ['.svn'] or ls == ['.hg']):
     raise cg.CallError("make clean doesn't clean everything"
         + testbox.look_into([c.workdir]))
Пример #4
0
  def clean(outdir, tc):
    grammar = tc.grammar
    c = adpc.Config
    os.chdir(c.workdir)

    for i in os.listdir(grammar[:-4]):
      os.unlink(grammar[:-4] + os.path.sep + i)
    os.rmdir(grammar[:-4])
    os.unlink(grammar)
    ls = os.listdir(c.workdir)
    if not (ls == [] or ls == ['.svn'] or ls == ['.hg']):
      raise cg.CallError("not everything is clean" + 
          testbox.look_into([c.workdir]))
Пример #5
0
Файл: call.py Проект: u-u-h/adpc
 def _create_b(outdir, tc):
   c = adpc.Config
   out = tc.unique_filename() + Suffix.make + Suffix.out
   testbox.checkFilename(out)
   err = tc.unique_filename() + Suffix.make + Suffix.err
   testbox.checkFilename(err)
   f1 = os.path.join(outdir, out)
   f2 = os.path.join(outdir, err)
   i = sysext.sys(c.make, ["BINPATH=" + c.binpath,
       "ADPCOMPILE=" + c.adpcompile,
       "ADPC=" + c.adpc_bin + " " + c.binpath],
       f1, f2)
   if i != 0:
     raise cg.CallError('making adp program failed' + 
         testbox.look_into([f1, f2]))
Пример #6
0
Файл: call.py Проект: u-u-h/adpc
 def _create_a(outdir, tc):
   c = adpc.Config
   os.chdir(c.workdir)
   shutil.copy(os.path.join(c.grammars, tc.grammar), c.workdir)
   out = tc.unique_filename() + Suffix.adp + Suffix.out
   testbox.checkFilename(out)
   err = tc.unique_filename() + Suffix.adp + Suffix.err
   testbox.checkFilename(err)
   f1 = os.path.join(outdir, out)
   f2 = os.path.join(outdir, err)
   i = sysext.sys(c.adpc_bin, [c.binpath, tc.grammar],
       f1, f2)
   if i != 0:
     raise cg.CallError('generating c src from adp program failed'
         + testbox.look_into([f1, f2]))
Пример #7
0
Файл: call.py Проект: u-u-h/adpc
  def execute(outdir, progname, filename, tc, sys_fn = sysext.sys):
    c = adpc.Config
    os.chdir(c.workdir)

    if hasattr(tc, 'parameter'):
      para = tc.parameter.split()
    else:
      para = []

    out = tc.unique_filename() + Suffix.out
    testbox.checkFilename(out)
    err = tc.unique_filename() + Suffix.err
    testbox.checkFilename(err)
    f1 = os.path.join(outdir, out)
    f2 = os.path.join(outdir, err)
    i = sys_fn('./' + progname,
       [ "-f", c.input + os.path.sep + filename] + para,
       f1, f2)
    if i != 0:
      raise cg.CallError("error executing adp program (exit status: " + str(i) + ")" 
          + testbox.look_into([f1, f2]))
Пример #8
0
Файл: call.py Проект: u-u-h/adpc
 def create(outdir, tc):
   grammar = tc.grammar
   c = adpc.Config
   Call._create_a(outdir, tc)
   out = tc.unique_filename() + Suffix.make + 'tup.' + Suffix.out
   testbox.checkFilename(out)
   err = tc.unique_filename() + Suffix.make + 'tup.' + Suffix.err
   f1 = os.path.join(outdir, out)
   f2 = os.path.join(outdir, err)
   i = sysext.sys(c.make, ["BINPATH=" + c.binpath,
       "ADPCOMPILE=" + c.adpcompile,
       "ADPC=" + c.adpc_bin + " " + c.binpath,
       grammar[:-4] + '.c'], f1, f2)
   if i != 0:
     raise cg.CallError('making tupel step failed'
         + testbox.look_into([f1, f2]))
   sed_file = grammar[:-4] + '_' + CallTuple.algebra + '.sed'
   tmp = sed_file + '.tmp'
   pat = re.compile('result_score')
   pat_head = re.compile('int maxloop;\\\\')
   shutil.move(sed_file, tmp)
   f = open(tmp)
   g = open(sed_file, 'w')
   for i in f:
     if pat.search(i):
       j = pat.sub('result_score.tup1', i)
     elif pat_head.match(i):
       j = i
       g.write('#undef is_suboptimal\\\n#define is_suboptimal(a, b, c) abs(a.tup1 - b) <= c\\\n')
     else:
       j = i
     g.write(j)
   f.close()
   g.close()
   os.unlink(tmp)
   Call._create_b(outdir, tc)