public static final String FILE_SEPARATOR = File.separator; public class Ist {
  public abstract static class Node {
    private final Position pos;
    
    public Node(Position pos) {
      this.pos = pos;
    }
    
    public Position pos() {
      return pos;
    }
    
    public abstract <R, C> R accept(Visitor<R, C> visitor, C context);
  }
  
  public static class ParserUnit extends Node implements Iterable<Function> {
    private final Symbol name;
    private final Symbol startName;
    private final Symbol startType;
    private final List<Function> rules;
    private final Map<Symbol, Set<Character>> nameToCharSet;

    public ParserUnit(Position pos, Symbol name, Map<Symbol, Set<Character>> nameToCharSet, Symbol startName, Symbol startType, List<Function> rules) {
      super(pos);
      this.name = name;
      this.nameToCharSet = nameToCharSet;
      this.startName = startName;
      this.startType = startType;
      this.rules = rules;
    }

    public Symbol getName() {
      return name;
    }

    public Map<Symbol, Set<Character>> getNameToCharSet() {
      return nameToCharSet;
    }
    
    public Symbol getStartName() {
      return startName;
    }
    
    public Symbol getStartType() {
      return startType;
    }

    public List<Function> getRules() {
      return rules;
    }

    public Iterator<Function> iterator() {
      return rules.iterator();
    }

    @Override
    public String toString() {
      StringBuilder builder = new StringBuilder();
      builder.append("parser ");
      builder.append(name);
      builder.append(LINE_SEPARATOR);
      builder.append(LINE_SEPARATOR);
      for(Function rule : rules){
        builder.append(rule);
        builder.append(LINE_SEPARATOR);
        builder.append(LINE_SEPARATOR);
      }
      return new String(builder);
    }
    
    public <R, C> R accept(Visitor<R, C> visitor, C context) {
      return visitor.visit(this, context);
    }
  }

  
  public static class Function extends Node {
    private final Symbol name;
    private final Symbol type;
    private final String code;
    private final boolean memoized;
    private final Statement statement;
    
    public Function(
      Position pos, Symbol name, Symbol type, String code, boolean memoized, Statement statement
    ) {
      super(pos);
      this.name = name;
      this.type = type;
      this.code = code;
      this.memoized = memoized;
      this.statement = statement;
    }

    public Symbol getName() {
      return name;
    }

    public Symbol getType() {
      return type;
    }
    
    public String getCode() {
      return code;
    }
    
    public boolean isMemoized() {
      return memoized;
    }
    
    public Statement getStatement() {
      return statement;
    }
    
    public <R, C> R accept(Visitor<R, C> visitor, C context) {
      return visitor.visit(this, context);
    }
  }
  
  public abstract static class Statement extends Node {
    public Statement(Position pos) {
      super(pos);
    }
  }
  
  public static class ActionStatement extends Statement {
    private String  code;

    public ActionStatement(Position pos, String code) {
      super(pos);
      this.code = code;
    }

    public String getCode() {
      return code;
    }
    
    public <R, C> R accept(Visitor<R, C> visitor, C context) {
      return visitor.visit(this, context);
    }
  }

  public static class SetSemanticValue extends Statement {
    private String  code;

    public SetSemanticValue(Position pos, String code) {
      super(pos);
      this.code = code;
    }

    public String getCode() {
      return code;
    }
    
    public <R, C> R accept(Visitor<R, C> visitor, C context) {
      return visitor.visit(this, context);
    }
  }
  
  public static class Block extends Statement {
    private final Symbol label;
    private final Statement[] statements;
    
    public Block(Position pos, Symbol label, Statement... statements) {
      super(pos);
      this.label = label;
      this.statements = statements;
    }
    
    public Block(Position pos, Symbol label, List<Statement> statements) {
      super(pos);
      this.label = label;
      this.statements = statements.toArray(new Statement[0]);
    }
    
    public Symbol getLabel() {
      return label;
    }
    
    public Statement[] getStatements() {
      return statements;
    }
    
    public <R, C> R accept(Visitor<R, C> visitor, C context) {
      return visitor.visit(this, context);
    }
  }
  
  public static class EscapeFrom extends Statement {
    private final Symbol label;
    
    public EscapeFrom(Position pos, Symbol label) {
      super(pos);
      this.label = label;
    }
    
    public Symbol getLabel() {
      return label;
    }
    
    public <R, C> R accept(Visitor<R, C> visitor, C context) {
      return visitor.visit(this, context);
    }
  }
  
  public static class Fail extends Statement {    
    public Fail(Position pos) {
      super(pos);
    }
    
    public <R, C> R accept(Visitor<R, C> visitor, C context) {
      return visitor.visit(this, context);
    }    
  }
  
  public static class MatchString extends Statement {
    private final Var var;
    private final String value;
    private final Symbol label;
    
    public MatchString(Position pos, Var var, String value, Symbol label) {
      super(pos);
      this.var = var;
      this.value = value;
      this.label = label;
    }
    
    public Var getVar() {
      return var;
    }
    
    public String getValue() {
      return value;
    }

    public Symbol getLabel() {
      return label;
    }
    
    public <R, C> R accept(Visitor<R, C> visitor, C context) {
      return visitor.visit(this, context);
    }
  }
  
  public static class Accept extends Statement {
    public Accept(Position pos) {
      super(pos);
    }

    @Override
    public String toString() {
      return "accept;";
    }
    
    public <R, C> R accept(Visitor<R, C> visitor, C context) {
      return visitor.visit(this, context);
    }
  }
  
  public static class GenerateSuccess extends Statement {
    public GenerateSuccess(Position pos) {
      super(pos);
    }

    @Override
    public String toString() {
      return "generate_success;";
    }
    
    public <R, C> R accept(Visitor<R, C> visitor, C context) {
      return visitor.visit(this, context);
    }
  }
  
  public static class GenerateFailure extends Statement {
    private String expected;
    
    public GenerateFailure(Position pos, String message) {
      super(pos);
      this.expected = message;
    }
    
    public String expected() { return expected; }

    @Override
    public String toString() {
      return "generate_failure;";
    }
    
    public <R, C> R accept(Visitor<R, C> visitor, C context) {
      return visitor.visit(this, context);
    }
  }
  
  public static class MatchAny extends Statement {
    private final Var var;
    private final Symbol label;
    
    public MatchAny(Position pos, Var var, Symbol label) {
      super(pos);
      this.var = var;
      this.label = label;
    }
    
    public Var getVar() {
      return var;
    }
    
    public Symbol getLabel() {
      return label;
    }
    
    public <R, C> R accept(Visitor<R, C> visitor, C context) {
      return visitor.visit(this, context);
    }
  }
  
  public static class MatchCharClass extends Statement {
    private final Symbol name;
    private final Var var;
    private final boolean positive;
    private final Symbol label;
    
    public MatchCharClass(Position pos, Symbol name, Var var, boolean positive, Symbol label) {
      super(pos);
      this.name = name;
      this.var = var;
      this.positive = positive;
      this.label = label;
    }
    
    public Symbol getName() {
      return name;
    }
    
    public Var getVar() {
      return var;
    }
    
    public boolean isPositive() {
      return positive;
    }
    
    public Symbol getLabel() {
      return label;
    }
    
    public <R, C> R accept(Visitor<R, C> visitor, C context) {
      return visitor.visit(this, context);
    }
  }
  
  public static class NewCursorVar extends Statement {
    private final Symbol name;
    
    public NewCursorVar(Position pos, Symbol name) {
      super(pos);
      this.name = name;
    }
    
    public Symbol getName() {
      return name;
    }
    
    public <R, C> R accept(Visitor<R, C> visitor, C context) {
      return visitor.visit(this, context);
    }
  }

  public static class Nop extends Statement {
    public Nop(Position pos) {
      super(pos);
    }
    
    public <R, C> R accept(Visitor<R, C> visitor, C context) {
      return visitor.visit(this, context);
    }
  }
  
  public static class Var {
    private final Symbol name;
    private final Symbol type;
    
    public Var(Symbol name, Symbol type) {
      this.name = name;
      this.type = type;
    }
    
    public Symbol getName() {
      return name;
    }
    
    public Symbol getType() {
      return type;
    }    
  }
  
  public static class MatchRule extends Statement {
    private final Var var;
    private final Symbol rule;
    private final Symbol label;
    
    public MatchRule(Position pos, Var var, Symbol rule, Symbol label) {
      super(pos);
      this.var = var;
      this.rule = rule;
      this.label = label;
    }
    
    public Var getVar() {
      return var;
    }
    
    public Symbol getRule() {
      return rule;
    }

    public Symbol getLabel() {
      return label;
    }
    
    public <R, C> R accept(Visitor<R, C> visitor, C context) {
      return visitor.visit(this, context);
    }
  }
  
  public static class BackupCursor extends Statement {
    private final Symbol var;

    public BackupCursor(Position pos, Symbol var) {
      super(pos);
      this.var = var;
    }
    
    public Symbol getVar() {
      return var;
    }
    
    public <R, C> R accept(Visitor<R, C> visitor, C context) {
      return visitor.visit(this, context);
    }
  }
  
  public static class IncrDepth extends Statement {
    public IncrDepth(Position pos) {
      super(pos);
    }
    
    public <R, C> R accept(Visitor<R, C> visitor, C context) {
      return visitor.visit(this, context);
    }
  }
  
  public static class DecrDepth extends Statement {
    public DecrDepth(Position pos) {
      super(pos);
    }
    
    public <R, C> R accept(Visitor<R, C> visitor, C context) {
      return visitor.visit(this, context);
    }
  }
  
  public static class RewindCursor extends Statement {
    private final Symbol var;

    public RewindCursor(Position pos, Symbol var) {
      super(pos);
      this.var = var;
    }
    
    public Symbol getVar() {
      return var;
    }
    
    public <R, C> R accept(Visitor<R, C> visitor, C context) {
      return visitor.visit(this, context);
    }
  }

  public static class Loop extends Statement {
    private final Symbol label;
    private final Statement[] statements;
    
    public Loop(Position pos, Symbol label, Statement... statements) {
      super(pos);
      this.label = label;
      this.statements = statements;
    }
    
    public Symbol getLabel() {
      return label;
    }
    
    public Statement[] getStatements() {
      return statements;
    }
    
    public <R, C> R accept(Visitor<R, C> visitor, C context) {
      return visitor.visit(this, context);
    }
  }
  
  public abstract static class Visitor<R, C> {
    public R visit(Accept node, C context) { return null; }
    public R visit(ActionStatement node, C context) { return null; }
    public R visit(BackupCursor node, C context) { return null; }
    public R visit(Block node, C context) { return null; }
    public R visit(DecrDepth node, C context) { return null; }
    public R visit(EscapeFrom node, C context) { return null; }
    public R visit(Fail node, C context) { return null; }
    public R visit(Function node, C context) { return null; }
    public R visit(GenerateSuccess node, C context) { return null; }
    public R visit(GenerateFailure node, C context) { return null; }
    public R visit(IncrDepth node, C context) { return null; }
    public R visit(Loop node, C context) { return null; }
    public R visit(MatchAny node, C context) { return null; }
    public R visit(MatchCharClass node, C context) { return null; }
    public R visit(MatchRule node, C context) { return null; }
    public R visit(MatchString node, C context) { return null; }
    public R visit(NewCursorVar node, C context) { return null; }
    public R visit(Nop node, C context) { return null; }
    public R visit(ParserUnit node, C context) { return null; }
    public R visit(RewindCursor node, C context) { return null; }
    public R visit(SetSemanticValue node, C context) { return null; }
  }
} public static class Accept extends Statement {
  public Accept(Position pos) {
    super(pos);
  }

  @Override
  public String toString() {
    return "accept;";
  }
    
  public <R, C> R accept(Visitor<R, C> visitor, C context) {
    return visitor.visit(this, context);
  }
} public static class ActionStatement extends Statement {
  private String  code;

  public ActionStatement(Position pos, String code) {
    super(pos);
    this.code = code;
  }

  public String getCode() {
    return code;
  }
    
  public <R, C> R accept(Visitor<R, C> visitor, C context) {
    return visitor.visit(this, context);
  }
} public static class BackupCursor extends Statement {
  private final Symbol var;

  public BackupCursor(Position pos, Symbol var) {
    super(pos);
    this.var = var;
  }
    
  public Symbol getVar() {
    return var;
  }
    
  public <R, C> R accept(Visitor<R, C> visitor, C context) {
    return visitor.visit(this, context);
  }
} public static class Block extends Statement {
  private final Symbol label;
  private final Statement[] statements;
    
  public Block(Position pos, Symbol label, Statement... statements) {
    super(pos);
    this.label = label;
    this.statements = statements;
  }
    
  public Block(Position pos, Symbol label, List<Statement> statements) {
    super(pos);
    this.label = label;
    this.statements = statements.toArray(new Statement[0]);
  }
    
  public Symbol getLabel() {
    return label;
  }
    
  public Statement[] getStatements() {
    return statements;
  }
    
  public <R, C> R accept(Visitor<R, C> visitor, C context) {
    return visitor.visit(this, context);
  }
} public static class DecrDepth extends Statement {
  public DecrDepth(Position pos) {
    super(pos);
  }
    
  public <R, C> R accept(Visitor<R, C> visitor, C context) {
    return visitor.visit(this, context);
  }
} public static class EscapeFrom extends Statement {
  private final Symbol label;
    
  public EscapeFrom(Position pos, Symbol label) {
    super(pos);
    this.label = label;
  }
    
  public Symbol getLabel() {
    return label;
  }
    
  public <R, C> R accept(Visitor<R, C> visitor, C context) {
    return visitor.visit(this, context);
  }
} public static class Fail extends Statement {    
  public Fail(Position pos) {
    super(pos);
  }
    
  public <R, C> R accept(Visitor<R, C> visitor, C context) {
    return visitor.visit(this, context);
  }    
} public static class Function extends Node {
  private final Symbol name;
  private final Symbol type;
  private final String code;
  private final boolean memoized;
  private final Statement statement;
    
  public Function(
    Position pos, Symbol name, Symbol type, String code, boolean memoized, Statement statement
  ) {
    super(pos);
    this.name = name;
    this.type = type;
    this.code = code;
    this.memoized = memoized;
    this.statement = statement;
  }

  public Symbol getName() {
    return name;
  }

  public Symbol getType() {
    return type;
  }
    
  public String getCode() {
    return code;
  }
    
  public boolean isMemoized() {
    return memoized;
  }
    
  public Statement getStatement() {
    return statement;
  }
    
  public <R, C> R accept(Visitor<R, C> visitor, C context) {
    return visitor.visit(this, context);
  }
} public static class GenerateFailure extends Statement {
  private String expected;
    
  public GenerateFailure(Position pos, String message) {
    super(pos);
    this.expected = message;
  }
    
  public String expected() { return expected; }

  @Override
  public String toString() {
    return "generate_failure;";
  }
    
  public <R, C> R accept(Visitor<R, C> visitor, C context) {
    return visitor.visit(this, context);
  }
} public static class GenerateSuccess extends Statement {
  public GenerateSuccess(Position pos) {
    super(pos);
  }

  @Override
  public String toString() {
    return "generate_success;";
  }
    
  public <R, C> R accept(Visitor<R, C> visitor, C context) {
    return visitor.visit(this, context);
  }
} public static class IncrDepth extends Statement {
  public IncrDepth(Position pos) {
    super(pos);
  }
    
  public <R, C> R accept(Visitor<R, C> visitor, C context) {
    return visitor.visit(this, context);
  }
} public static class Loop extends Statement {
  private final Symbol label;
  private final Statement[] statements;
    
  public Loop(Position pos, Symbol label, Statement... statements) {
    super(pos);
    this.label = label;
    this.statements = statements;
  }
    
  public Symbol getLabel() {
    return label;
  }
    
  public Statement[] getStatements() {
    return statements;
  }
    
  public <R, C> R accept(Visitor<R, C> visitor, C context) {
    return visitor.visit(this, context);
  }
} public static class MatchAny extends Statement {
  private final Var var;
  private final Symbol label;
    
  public MatchAny(Position pos, Var var, Symbol label) {
    super(pos);
    this.var = var;
    this.label = label;
  }
    
  public Var getVar() {
    return var;
  }
    
  public Symbol getLabel() {
    return label;
  }
    
  public <R, C> R accept(Visitor<R, C> visitor, C context) {
    return visitor.visit(this, context);
  }
} public static class MatchCharClass extends Statement {
  private final Symbol name;
  private final Var var;
  private final boolean positive;
  private final Symbol label;
    
  public MatchCharClass(Position pos, Symbol name, Var var, boolean positive, Symbol label) {
    super(pos);
    this.name = name;
    this.var = var;
    this.positive = positive;
    this.label = label;
  }
    
  public Symbol getName() {
    return name;
  }
    
  public Var getVar() {
    return var;
  }
    
  public boolean isPositive() {
    return positive;
  }
    
  public Symbol getLabel() {
    return label;
  }
    
  public <R, C> R accept(Visitor<R, C> visitor, C context) {
    return visitor.visit(this, context);
  }
} public static class MatchRule extends Statement {
  private final Var var;
  private final Symbol rule;
  private final Symbol label;
    
  public MatchRule(Position pos, Var var, Symbol rule, Symbol label) {
    super(pos);
    this.var = var;
    this.rule = rule;
    this.label = label;
  }
    
  public Var getVar() {
    return var;
  }
    
  public Symbol getRule() {
    return rule;
  }

  public Symbol getLabel() {
    return label;
  }
    
  public <R, C> R accept(Visitor<R, C> visitor, C context) {
    return visitor.visit(this, context);
  }
} public static class MatchString extends Statement {
  private final Var var;
  private final String value;
  private final Symbol label;
    
  public MatchString(Position pos, Var var, String value, Symbol label) {
    super(pos);
    this.var = var;
    this.value = value;
    this.label = label;
  }
    
  public Var getVar() {
    return var;
  }
    
  public String getValue() {
    return value;
  }

  public Symbol getLabel() {
    return label;
  }
    
  public <R, C> R accept(Visitor<R, C> visitor, C context) {
    return visitor.visit(this, context);
  }
} public static class NewCursorVar extends Statement {
  private final Symbol name;
    
  public NewCursorVar(Position pos, Symbol name) {
    super(pos);
    this.name = name;
  }
    
  public Symbol getName() {
    return name;
  }
    
  public <R, C> R accept(Visitor<R, C> visitor, C context) {
    return visitor.visit(this, context);
  }
} public static class Nop extends Statement {
  public Nop(Position pos) {
    super(pos);
  }
    
  public <R, C> R accept(Visitor<R, C> visitor, C context) {
    return visitor.visit(this, context);
  }
} public static class ParserUnit extends Node implements Iterable<Function> {
  private final Symbol name;
  private final Symbol startName;
  private final Symbol startType;
  private final List<Function> rules;
  private final Map<Symbol, Set<Character>> nameToCharSet;

  public ParserUnit(Position pos, Symbol name, Map<Symbol, Set<Character>> nameToCharSet, Symbol startName, Symbol startType, List<Function> rules) {
    super(pos);
    this.name = name;
    this.nameToCharSet = nameToCharSet;
    this.startName = startName;
    this.startType = startType;
    this.rules = rules;
  }

  public Symbol getName() {
    return name;
  }

  public Map<Symbol, Set<Character>> getNameToCharSet() {
    return nameToCharSet;
  }
    
  public Symbol getStartName() {
    return startName;
  }
    
  public Symbol getStartType() {
    return startType;
  }

  public List<Function> getRules() {
    return rules;
  }

  public Iterator<Function> iterator() {
    return rules.iterator();
  }

  @Override
  public String toString() {
    StringBuilder builder = new StringBuilder();
    builder.append("parser ");
    builder.append(name);
    builder.append(LINE_SEPARATOR);
    builder.append(LINE_SEPARATOR);
    for(Function rule : rules){
      builder.append(rule);
      builder.append(LINE_SEPARATOR);
      builder.append(LINE_SEPARATOR);
    }
    return new String(builder);
  }
    
  public <R, C> R accept(Visitor<R, C> visitor, C context) {
    return visitor.visit(this, context);
  }
} public static class RewindCursor extends Statement {
  private final Symbol var;

  public RewindCursor(Position pos, Symbol var) {
    super(pos);
    this.var = var;
  }
    
  public Symbol getVar() {
    return var;
  }
    
  public <R, C> R accept(Visitor<R, C> visitor, C context) {
    return visitor.visit(this, context);
  }
} public static class SetSemanticValue extends Statement {
  private String  code;

  public SetSemanticValue(Position pos, String code) {
    super(pos);
    this.code = code;
  }

  public String getCode() {
    return code;
  }
    
  public <R, C> R accept(Visitor<R, C> visitor, C context) {
    return visitor.visit(this, context);
  }
} public abstract static class Visitor<R, C> {
  public R visit(Accept node, C context) { return null; }
  public R visit(ActionStatement node, C context) { return null; }
  public R visit(BackupCursor node, C context) { return null; }
  public R visit(Block node, C context) { return null; }
  public R visit(DecrDepth node, C context) { return null; }
  public R visit(EscapeFrom node, C context) { return null; }
  public R visit(Fail node, C context) { return null; }
  public R visit(Function node, C context) { return null; }
  public R visit(GenerateSuccess node, C context) { return null; }
  public R visit(GenerateFailure node, C context) { return null; }
  public R visit(IncrDepth node, C context) { return null; }
  public R visit(Loop node, C context) { return null; }
  public R visit(MatchAny node, C context) { return null; }
  public R visit(MatchCharClass node, C context) { return null; }
  public R visit(MatchRule node, C context) { return null; }
  public R visit(MatchString node, C context) { return null; }
  public R visit(NewCursorVar node, C context) { return null; }
  public R visit(Nop node, C context) { return null; }
  public R visit(ParserUnit node, C context) { return null; }
  public R visit(RewindCursor node, C context) { return null; }
  public R visit(SetSemanticValue node, C context) { return null; }
} public class CollectionUtil {
  public static <T> List<T> list(T... elements) {
    return new ArrayList<T>(Arrays.asList(elements));
  }
  
  public static <A, B> Pair<A, B> t(A fst, B snd) {
    return new Pair<A, B>(fst, snd);
  }
  
  public static <K, V> Map<K, V> map(Pair<? extends K, ? extends V>... elements) {
    Map<K, V> map = new HashMap<K, V>();
    for(Pair<? extends K, ? extends V> e:elements) {
      map.put(e.fst(), e.snd());
    }
    return map;
  }
  
  public static <T> Set<T> set(T... elements) {
    return new HashSet<T>(Arrays.asList(elements));
  }
  
  public static <T> Set<T> setFrom(Collection<? extends T> collection) {
    return new HashSet<T>(collection);
  }
}
import static com.github.kmizu.yapp.util.SystemProperties.FILE_SEPARATOR;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Map;
import java.util.Set;
import com.github.kmizu.yapp.CompilationException;
import com.github.kmizu.yapp.Ist;
import com.github.kmizu.yapp.Symbol;
import com.github.kmizu.yapp.Ist.Accept;
import com.github.kmizu.yapp.Ist.ActionStatement;
import com.github.kmizu.yapp.Ist.BackupCursor;
import com.github.kmizu.yapp.Ist.Block;
import com.github.kmizu.yapp.Ist.DecrDepth;
import com.github.kmizu.yapp.Ist.EscapeFrom;
import com.github.kmizu.yapp.Ist.Fail;
import com.github.kmizu.yapp.Ist.Function;
import com.github.kmizu.yapp.Ist.GenerateFailure;
import com.github.kmizu.yapp.Ist.GenerateSuccess;
import com.github.kmizu.yapp.Ist.IncrDepth;
import com.github.kmizu.yapp.Ist.Loop;
import com.github.kmizu.yapp.Ist.MatchAny;
import com.github.kmizu.yapp.Ist.MatchCharClass;
import com.github.kmizu.yapp.Ist.MatchRule;
import com.github.kmizu.yapp.Ist.MatchString;
import com.github.kmizu.yapp.Ist.NewCursorVar;
import com.github.kmizu.yapp.Ist.Nop;
import com.github.kmizu.yapp.Ist.ParserUnit;
import com.github.kmizu.yapp.Ist.RewindCursor;
import com.github.kmizu.yapp.Ist.SetSemanticValue;
import com.github.kmizu.yapp.Ist.Visitor;
import com.github.kmizu.yapp.util.CollectionUtil;
package com.github.kmizu.yapp.translator;




public class CodeGeneratorFromIst 
  extends Visitor<Void, CodeGeneratorFromIst.CodeContext> 
  implements Translator<Ist.ParserUnit, Void> {
  static class CodeContext {
    Symbol type;
  }
  
  private static final int INDENT_SPACE = 2;
  private static final int CHUNK_SIZE   = 10;
  private static final String FUNC_PREFIX     = "parse"     ;
  private static final String MEMO_PREFIX     = "memo"      ;
  private static final String VALUE_NAME      = "value"     ;
  private static final String BASE_NAME       = "baseIndex" ;
  private static final String REGISTER_NAME   = "result"    ;
  private static final String CURSOR_NAME     = "cursor"    ;
  private static final String LOCAL_DEPTH     = "localDepth";
  private static final String DEPTH           = "depth"     ;
  private static final String INDEX_METHOD    = "realIndex" ;
  private static final String IS_ZERO         = "isZero"    ;

  private String dstPackage;
  private File dstDir;
  private PrintWriter out;
  private int indentLevel;
  private boolean joinColumns;

  public CodeGeneratorFromIst(String dstPackage, File dstDir, boolean joinColumns) {
    this.dstPackage = dstPackage;
    this.dstDir = dstDir;
    this.joinColumns = joinColumns;
  }

  
  public Void translate(ParserUnit from) {
    File dstFile = new File(dstDir + FILE_SEPARATOR + from.getName() + ".java");
    try {
      out = new PrintWriter(new FileWriter(dstFile));
      try {
        from.accept(this, new CodeContext());
        out.flush();
        return null;
      }finally{
        out.close();
      }
    }catch(IOException e) {
      throw new CompilationException(e);
    }
  }
    
  @Override
  public Void visit(Accept node, CodeContext context) {