anchor.diff:    language = Python;
   }
   
  +@header {
  +  import sys
  +}
  +
  +@members {
  +  indentLevel = 0
  +  was_indent = False
  +  was_newline = False
  +
  +  def indent(self):
  +    self.indentLevel += 1
  +
  +  def unindent(self):
  +    self.indentLevel -= 1
  +
  +  def print_indent(self):
  +    if self.was_indent:
  +      return
  +    sys.stdout.write(self.indentLevel * 2 * ' ')
  +    self.was_indent = True
  +    self.was_newline = False
  +
  +  def print_newline(self):
  +    if self.was_newline:
  +      return
  +    sys.stdout.write('\n')
  +    self.was_newline = True
  +    self.was_indent = False
  +
  +  def print_custom(self, str):
  +    sys.stdout.write(str)
  +    self.was_newline = False
  +    self.was_indent = False
  +}
  +
   program
  -  : top_statement*
  +@init {
  +  print 'import sys'
  +  print ''
  +  print 'def array(x):'
  +  print '  return [x]'
  +  print ''
  +  print 'def count(x):'
  +  print '  return len(x)'
  +  print ''
  +} : top_statement*
     ;
   
   top_statement
  -  : statement
  +@init {
  +  self.print_indent()
  +}
  +@after {
  +  self.print_newline()
  +} : statement
     | function_def
     | class_def
     | interface_def
     ;
   
   function_def
  -  : ^(KW_FUNCTION name=ID (^(Parameter ID))* statement*)
  +@init {
  +  param_list = []
  +} : ^(KW_FUNCTION name=ID
  +      {
  +        self.print_indent()
  +        self.print_custom('def ' + $name.text + '(')
  +      }
  +      (^(Parameter pname=ID { param_list.append($pname.text) }))*
  +      {
  +        self.print_custom(','.join(param_list))
  +        self.print_custom('):')
  +        self.print_newline()
  +        self.indent()
  +      }
  +      statement*)
  +      {
  +        self.unindent()
  +        self.print_indent()
  +        self.print_newline()
  +      }
     ;
   
   class_def
  
positive.code:   ;
  
  statement
    : ^(EvalExpr expr)
    | ^(Block statement+)
    | if_statement
    | while_statement
    | echo_statement
    | KW_BREAK
    | KW_CONTINUE
    ;
  
  if_statement
    : ^(KW_IF cond=expr true_stat=statement false_stat=statement?)
    ;
  
  while_statement
    : ^(KW_WHILE expr statement)
    ;
  
  echo_statement
    : ^(KW_ECHO expr)
    ;
  
  incdec_op
  
negative.code:   ;
  
  variable_name
    : ^(DOLLAR ID { self.print_custom($ID.text) })
    | ^(DOLLAR variable_name)
    | ^(DOLLAR expr)
    ;
  