Source code for ctree.cpp.nodes

"""
C preprocessor nodes supported by ctree.
"""

from ctree.nodes import CtreeNode


[docs]class CppNode(CtreeNode): """Base class for all C Preprocessor nodes in ctree."""
[docs] def codegen(self, indent=0): from ctree.cpp.codegen import CppCodeGen return CppCodeGen(indent).visit(self)
[docs] def label(self): from ctree.cpp.dotgen import CppDotLabeller return CppDotLabeller().visit(self)
def _requires_semicolon(self): return False
[docs]class CppInclude(CppNode): """Represents #include <foo.h>.""" def __init__(self, target="", angled_brackets=True): self.target = target self.angled_brackets = angled_brackets
[docs]class CppComment(CppNode): """Represents // foo""" def __init__(self, text=""): self.text = text
[docs]class CppDefine(CppNode): _fields = ['name', 'params', 'body'] def __init__(self, name=None, params=None, body=None): self.name = name self.params = params self.body = body super(CppDefine, self).__init__()