pyccel.parser.parser module#
Module containing the Parser object
- class pyccel.parser.parser.Parser(filename, *, output_folder, context_dict=None, original_filename=None, **kwargs)[source]#
Bases:
object
A wrapper class which handles dependencies between the syntactic and semantic parsers.
A wrapper class which handles dependencies between the syntactic and semantic parsers.
- Parameters:
filename (str | Path) – The absolute path to the file being translated.
output_folder (str | Path) – The output folder for the generated file.
context_dict (dict, optional) – A dictionary containing any variables that are available in the calling context. This can allow certain constants to be defined outside of the function passed to epyccel.
original_filename (str, optional) – The name of the original Python file. This won’t match the filename if the filename is a .pyi file in a __pyccel__ folder (i.e. a .pyi file that was auto-generated to describe the prototypes of the methods).
**kwargs (dict) – Any keyword arguments for BasicParser.
- annotate(verbose)[source]#
Annotate the AST collected from the syntactic stage.
Use the semantic parser to annotate the AST collected from the syntactic stage.
- Parameters:
verbose (int) – The level of verbosity.
- Returns:
The semantic parser that was used to annotate the AST.
- Return type:
- property compile_obj#
Compile object
- property d_parsers#
Returns the d_parsers parser.
- property filename#
Python file to be parsed.
- property fst#
- property imports#
- property metavars#
- property parents#
Returns the parents parser.
- parse(*, verbose, d_parsers_by_filename=None)[source]#
Parse the parent file and all its dependencies.
Parse the parent file and all its dependencies.
- Parameters:
verbose (int) – Indicates the level of verbosity.
d_parsers_by_filename (dict[str, Parser]) – A dictionary of parsed sons indexed by filename.
- Returns:
The ast created in the syntactic stage.
- Return type:
- parse_sons(d_parsers_by_filename, verbose)[source]#
Parse the files on which this file is dependent.
Recursive algorithm for syntax analysis on a given file and its dependencies. This function always terminates with an dict that contains parsers for all involved files.
- Parameters:
d_parsers_by_filename (dict) – A dictionary of parsed sons.
verbose (int) – Indicates the level of verbosity.
- Returns:
The updated dictionary of parsed sons.
- Return type:
dict
- property scope#
- property semantic_parser#
Semantic parser
- property sons#
Returns the sons parser.
- property syntax_parser#
Syntax parser