pyccel.parser package¶
Subpackages¶
Submodules¶
pyccel.parser.errors module¶
pyccel.parser.messages module¶
pyccel.parser.parser module¶
-
class
pyccel.parser.parser.Parser(inputs, debug=False, headers=None, static=None, show_traceback=True, output_folder='', context_import_path={})[source]¶ Bases:
objectClass for a Parser.
-
ast¶
-
blocking¶
-
bounding_box¶
-
classes¶
-
code¶
-
current_class¶
-
d_parsers¶ Returns the d_parsers parser.
-
dump(filename=None)[source]¶ Dump the current ast using Pickle.
- filename: str
- output file name. if not given name.pyccel will be used and placed in the Pyccel directory ($HOME/.pyccel)
-
filename¶
-
fst¶
-
functions¶
-
headers¶
-
imports¶
-
is_header_file¶ Returns True if we are treating a header file.
-
load(filename=None)[source]¶ Load the current ast using Pickle.
- filename: str
- output file name. if not given name.pyccel will be used and placed in the Pyccel directory ($HOME/.pyccel)
-
macros¶
-
metavars¶
-
namespace¶
-
parents¶ Returns the parents parser.
-
python_functions¶
-
semantic_done¶
-
show_traceback¶
-
sons¶ Returns the sons parser.
-
static_functions¶
-
symbolic_functions¶
-
syntax_done¶
-
variables¶
-
-
class
pyccel.parser.parser.PyccelParser(inputs, debug=False, headers=None, static=None, show_traceback=True, output_folder='', context_import_path={})[source]¶ Bases:
pyccel.parser.parser.Parser
pyccel.parser.utilities module¶
-
pyccel.parser.utilities.acc_statement(x)¶
-
pyccel.parser.utilities.accelerator_statement(stmt, accel)[source]¶ Returns stmt if an accelerator statement. otherwise it returns None. this function can be used as the following >>> if accelerator_statement(stmt, ‘omp’):
# do stuff …In general you can use the functions omp_statement and acc_statement
-
pyccel.parser.utilities.fst_move_directives(x)[source]¶ - This function moves OpenMP/OpenAcc directives from loop statements to
their appropriate parent. This function will have inplace effect. In order to understand why it is needed, let’s take a look at the following exampe
>>> code = ''' ... #$ omp do schedule(runtime) ... for i in range(0, n): ... for j in range(0, m): ... a[i,j] = i-j ... #$ omp end do nowait ... ''' >>> from redbaron import RedBaron >>> red = RedBaron(code) >>> red 0 '
- ‘
1 #$ omp do schedule(runtime) 2 for i in range(0, n):
- for j in range(0, m):
- a[i,j] = i-j
#$ omp end do nowait
As you can see, the statement #$ omp end do nowait is inside the For statement, while we would like to have it outside. Now, let’s apply our function
>>> fst_move_directives(red) 0 #$ omp do schedule(runtime) 1 for i in range(0, n): for j in range(0, m): a[i,j] = i-j 2 #$ omp end do nowait
-
pyccel.parser.utilities.get_comments(y)¶
-
pyccel.parser.utilities.get_default_path(name)[source]¶ this function takes a an import name and returns the path full bash of the library if the library is in stdlib
-
pyccel.parser.utilities.get_defs(y)¶
-
pyccel.parser.utilities.get_ifblocks(y)¶
-
pyccel.parser.utilities.get_ifs(y)¶
-
pyccel.parser.utilities.get_loops(y)¶
-
pyccel.parser.utilities.get_withs(y)¶
-
pyccel.parser.utilities.header_statement(stmt, accel)[source]¶ Returns stmt if a header statement. otherwise it returns None. this function can be used as the following >>> if header_statement(stmt):
# do stuff …
-
pyccel.parser.utilities.is_valid_filename_py(filename)[source]¶ Returns True if filename is an existing python file.
-
pyccel.parser.utilities.is_valid_filename_pyh(filename)[source]¶ Returns True if filename is an existing pyccel header file.
-
pyccel.parser.utilities.omp_statement(x)¶