ziggy.hdmc.code_generator

Package ziggy :: Package hdmc :: Module code_generator |
[hide private]
[frames] | no frames]

# Source Code for Module ziggy.hdmc.code_generator

     1  '''
     2  Created on Jul 28, 2010
     3
     4  @author: dwmclary
     5  '''
     6  import sys, string
     7
     8 -class CodeGenerator:
     9
    10 -    def begin(self, tab="\t"):
    11          self.code = []
    12          self.tab = tab
    13          self.level = 0
    14
    15 -    def end(self):
    16          return string.join(self.code, "")
    17
    18 -    def write(self, string):
    19          self.code.append(self.tab * self.level + string)
    20
    21 -    def indent(self):
    22          self.level += 1
    23
    24 -    def dedent(self):
    25          if self.level > 0:
    26              self.level -= 1
    27