printParsedToken function

void printParsedToken(
  1. Token token,
  2. int level,
  3. int indents
)

Implementation

void printParsedToken(Token token, int level, int indents) {
  String indentstr = '';
  for(int i=0;i<level-1;i++) {
    for(int j=0;j<indents;j++){
      indentstr+=' ';
    }
  }
  if(level>0) {
    indentstr+="|";
    for(int i=0;i<indents-1;i++) {
      indentstr+='-';
    }
  }
  if(token is ComposedToken) {
    print('${indentstr}${token.typeName.toUpperCase()}: ${token.toCodeString()}');
    ComposedToken composedToken = token;
    for(Token subToken in composedToken.tokens) {
      printParsedToken(subToken, level+1, indents);
    }
  }else{
    print('${indentstr}${token.typeName.toUpperCase()} -> ${token.toCodeString()}');
  }
}