def _visit_CommentLine(self, stmt): # if annotated comment if stmt.s.startswith('#$'): env = stmt.s[2:].lstrip() if env.startswith('omp'): return omp_parse(stmts=stmt.s) elif env.startswith('acc'): return acc_parse(stmts=stmt.s) elif env.startswith('header'): expr = hdr_parse(stmts=stmt.s) if isinstance(expr, MetaVariable): # a metavar will not appear in the semantic stage. # but can be used to modify the ast self._metavars[str(expr.name)] = str(expr.value) expr = EmptyNode() else: expr.set_fst(stmt) return expr else: errors.report(PYCCEL_INVALID_HEADER, symbol=stmt, severity='error') else: txt = stmt.s[1:].lstrip() return Comment(txt)
def _visit_CommentMultiLine(self, stmt): exprs = [] # if annotated comment for com in stmt.s.split('\n'): if com.startswith('#$'): env = com[2:].lstrip() if env.startswith('omp'): exprs.append(omp_parse(stmts=com)) elif env.startswith('acc'): exprs.append(acc_parse(stmts=com)) elif env.startswith('header'): expr = hdr_parse(stmts=com) if isinstance(expr, MetaVariable): # a metavar will not appear in the semantic stage. # but can be used to modify the ast self._metavars[str(expr.name)] = str(expr.value) expr = EmptyNode() else: expr.set_fst(stmt) exprs.append(expr) else: errors.report(PYCCEL_INVALID_HEADER, symbol=stmt, severity='error') else: txt = com[1:].lstrip() exprs.append(Comment(txt)) if len(exprs) == 1: return exprs[0] else: return CodeBlock(exprs)