Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_semantic(f):
pyccel = Parser(f)
pyccel.parse()
settings = {}
pyccel.annotate(**settings)
# reset Errors singleton
errors = Errors()
errors.reset()
def test_codegen(f):
pyccel = Parser(f)
ast = pyccel.parse()
settings = {}
ast = pyccel.annotate(**settings)
name = os.path.basename(f)
name = os.path.splitext(name)[0]
codegen = Codegen(ast, name)
codegen.doprint()
# reset Errors singleton
errors = Errors()
errors.reset()
def test_codegen(f):
pyccel = Parser(f)
ast = pyccel.parse()
settings = {}
ast = pyccel.annotate(**settings)
name = os.path.basename(f)
name = os.path.splitext(name)[0]
codegen = Codegen(ast, name)
codegen.doprint(language='python')
# reset Errors singleton
errors = Errors()
errors.reset()
######################
def test_codegen_warnings(f):
pyccel = Parser(f, show_traceback=False)
ast = pyccel.parse()
settings = {}
ast = pyccel.annotate(**settings)
name = os.path.basename(f)
name = os.path.splitext(name)[0]
codegen = Codegen(ast, name)
code = codegen.doprint()
# reset Errors singleton
errors = Errors()
assert(errors.num_messages()!=0)
errors.reset()
def test_syntax(f):
pyccel = Parser(f)
pyccel.parse()
# reset Errors singleton
errors = Errors()
errors.reset()
for all involved files.
"""
imports = self.imports.keys()
treated = d_parsers.keys()
not_treated = [i for i in imports if i not in treated]
for source in not_treated:
if verbose:
print ('>>> treating :: {}'.format(source))
# get the absolute path corresponding to source
filename = get_filename_from_import(source, self._input_folder)
q = Parser(filename)
q.parse(d_parsers=d_parsers)
if q.module_parser:
d_parsers[source] = q.module_parser
else:
d_parsers[source] = q
# link self to its sons
for source in imports:
d_parsers[source].append_parent(self)
self.append_son(d_parsers[source])
return d_parsers
for all involved files.
"""
treated = set(d_parsers.keys())
imports = set(self.imports.keys())
imports = imports.difference(treated)
if not imports:
return d_parsers
for source in imports:
if verbose:
print('>>> treating :: {}'.format(source))
# get the absolute path corresponding to source
filename = get_filename_from_import(source)
q = Parser(filename)
q.parse(d_parsers=d_parsers)
d_parsers[source] = q
# link self to its sons
imports = list(self.imports.keys())
for source in imports:
d_parsers[source].append_parent(self)
self.append_son(d_parsers[source])
return d_parsers
class PyccelParser(Parser):
pass
######################################################
if __name__ == '__main__':
import sys
try:
filename = sys.argv[1]
except:
raise ValueError('Expecting an argument for filename')
pyccel = Parser(filename)
pyccel.parse(verbose=True)
settings = {}
pyccel.annotate(**settings)
parser = SyntaxParser(self._filename, **self._kwargs)
self._syntax_parser = parser
parse_result = parser.ast
if d_parsers is None:
d_parsers = self._d_parsers
self._d_parsers = self._parse_sons(d_parsers, verbose=verbose)
if parse_result.has_additional_module():
new_mod_filename = os.path.join(os.path.dirname(self._filename),parse_result.mod_name+'.py')
new_prog_filename = os.path.join(os.path.dirname(self._filename),parse_result.prog_name+'.py')
self._filename = new_prog_filename
q = Parser(new_mod_filename)
q._syntax_parser = copy.copy(parser)
q._syntax_parser._namespace = copy.deepcopy(parser.namespace)
q._d_parsers = q._parse_sons(self._d_parsers)
q._syntax_parser._ast = parse_result.module
d_parsers[parse_result.mod_name] = q
q.append_parent(self)
self.append_son(q)
parser._ast = parse_result.program
self.module_parser = q
else:
parser._ast = parse_result.get_focus()
self.module_parser = None
if p.sons:
if verbose:
print ('>>> treating :: {}'.format(p.filename))
p.annotate(**settings)
#==============================================================================
if __name__ == '__main__':
import sys
try:
filename = sys.argv[1]
except IndexError:
raise ValueError('Expecting an argument for filename')
pyccel = Parser(filename)
pyccel.parse(verbose=True)
settings = {}
pyccel.annotate(**settings)