Can define more than one language.

pull/15/head
Jussi Pakkanen 12 years ago
parent b1ccec0cef
commit 6502708b08
  1. 20
      interpreter.py

@ -132,16 +132,20 @@ class Interpreter():
print('Message: %s' % args[0]) print('Message: %s' % args[0])
def func_language(self, node, args): def func_language(self, node, args):
self.validate_arguments(args, 1, [str]) if len(args) == 0:
raise InvalidArguments('Line %d: no arguments to function language.' % node.lineno())
for a in args:
if not isinstance(a, str):
raise InvalidArguments('Line %d: Argument %s is not a string.' % (node.lineno(), str(a)))
if len(self.compilers) > 0: if len(self.compilers) > 0:
raise InvalidCode('Function language() can only be called once (line %d).' % node.lineno()) raise InvalidCode('Function language() can only be called once (line %d).' % node.lineno())
lang = args[0] for lang in args:
if lang.lower() == 'c': if lang.lower() == 'c':
comp = environment.detect_c_compiler('gcc') comp = environment.detect_c_compiler('gcc')
comp.sanity_check(self.scratch_dir) comp.sanity_check(self.scratch_dir)
self.compilers.append(comp) self.compilers.append(comp)
else: else:
raise InvalidCode('Tried to use unknown language "%s".' % lang) raise InvalidCode('Tried to use unknown language "%s".' % lang)
def func_executable(self, node, args): def func_executable(self, node, args):
for a in args: for a in args:

Loading…
Cancel
Save