Esempio n. 1
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]))
Esempio n. 2
0
 def generate(self):
     self.call(self.config.state)
     if self.language != self.default_language:
         return
     filename = self.unique_filename() + Suffix.out
     d = self.extract(os.path.join(self.config.state, filename))
     filename = self.unique_filename(['language']) + Suffix.pickle
     testbox.checkFilename(filename)
     f = open(os.path.join(self.config.state, filename), 'w')
     pickle.dump(d, f)
     f.close()
Esempio n. 3
0
 def design(self, dest):
   os.chdir(self.config.cwd)
   out = self.unique_filename() + Suffix.out
   testbox.checkFilename(out)
   err = self.unique_filename() + Suffix.err
   testbox.checkFilename(err)
   f1 = os.path.join(dest, out)
   f2 = os.path.join(dest, err)
   i = sysext.sys(self.config.hand,
       self.hand_opts + [ os.path.join(self.config.state,
         self.grammar + Suffix.i + Suffix.out) ],
       f1, f2)
   self.failIf(i != 0, "Couldn't generate hand output"
       + testbox.look_into([f1, f2]))
Esempio n. 4
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]))
Esempio n. 5
0
 def serialize(self, out_dir):
   c = self.config
   os.chdir(c.grammars)
   out = self.grammar + Suffix.i + Suffix.out
   testbox.checkFilename(out)
   err = self.grammar + Suffix.i + Suffix.err
   testbox.checkFilename(err)
   f1 = os.path.join(out_dir, out)
   f2 = os.path.join(out_dir, err)
   i = sysext.sys(c.adpcompile,
       ['-iuc', '-te', os.path.join(c.grammars, self.grammar) ], f1, f2)
   self.failIf(i != 0, "Couldn't create serialized output."
       + testbox.look_into([f1, f2]))
   return i
Esempio n. 6
0
File: call.py Progetto: 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]))
Esempio n. 7
0
File: call.py Progetto: 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]))
Esempio n. 8
0
 def serialize(self, out_dir):
     c = self.config
     os.chdir(c.grammars)
     out = self.grammar + Suffix.i + Suffix.out
     testbox.checkFilename(out)
     err = self.grammar + Suffix.i + Suffix.err
     testbox.checkFilename(err)
     f1 = os.path.join(out_dir, out)
     f2 = os.path.join(out_dir, err)
     i = sysext.sys(c.adpcompile,
                    ['-iuc', '-te',
                     os.path.join(c.grammars, self.grammar)], f1, f2)
     self.failIf(
         i != 0,
         "Couldn't create serialized output." + testbox.look_into([f1, f2]))
     return i
Esempio n. 9
0
File: call.py Progetto: 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]))
Esempio n. 10
0
File: call.py Progetto: 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]))
Esempio n. 11
0
File: call.py Progetto: 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)