SPPCompiler.SemanticAnalysis.Utils.CodeInjection module

class SPPCompiler.SemanticAnalysis.Utils.CodeInjection.CodeInjection

Bases: object

static inject_code(code, parsing_function, *, pos_adjust)

! The code injection function is a utility function to generate extra code during semantic analysis to simplify AST construction. This is seen in preprocessing, and a range of argument manipulation and type generation.

@param code The s++ code in string format to inject. @param parsing_function The parsing rule to apply to the injected code. @param pos_adjust An position adjustment for all ASTs parsed (so errors can print the injected code).

@return The AST generated from the parser rule being applied over the code. All “pos” attributes will reflect the “pos_adjust” value.

Return type:

TypeVar(T)