private Token toASIToken(ILeafNode leaf){
  if (leaf.isHidden()) {
    return newSemicolonToken(leaf);
  }
 else {
    if (!leafNodes.hasNext()) {
      int tokenType=tokenTypeMapper.getInternalTokenType(leaf);
      int semicolonTokenType=tokenTypeMapper.getInternalTokenType(semicolon);
      if (tokenType == semicolonTokenType) {
        return new CommonToken(semicolonTokenType,leaf.getText());
      }
      if (leaf.getTotalEndOffset() == endOffset) {
        leafNodes=Iterators.emptyIterator();
        return new CommonToken(tokenType,leaf.getText());
      }
      next=new CommonToken(semicolonTokenType,leaf.getText());
      return new CommonToken(tokenType,leaf.getText());
    }
 else     if (leaf.getGrammarElement() == rightCurlyInBlock || leaf.getGrammarElement() == rightCurlyInArrowExpression) {
      int tokenType=tokenTypeMapper.getInternalTokenType(leaf);
      next=new CommonToken(tokenType);
      return new CommonToken(tokenTypeMapper.getInternalTokenType(semicolon),leaf.getText());
    }
 else {
      return newSemicolonToken(leaf);
    }
  }
}

private Token toASIToken ( ILeafNode leaf ) { if ( leaf . isHidden ( ) ) { return newSemicolonToken ( leaf ) ; } else { if ( ! leafNodes . hasNext ( ) ) { int tokenType = tokenTypeMapper . getInternalTokenType ( leaf ) ; int semicolonTokenType = tokenTypeMapper . getInternalTokenType ( semicolon ) ; if ( tokenType == semicolonTokenType ) { return new CommonToken ( semicolonTokenType , leaf . getText ( ) ) ; } if ( leaf . getTotalEndOffset ( ) == endOffset ) { leafNodes = Iterators . emptyIterator ( ) ; return new CommonToken ( tokenType , leaf . getText ( ) ) ; } next = new CommonToken ( semicolonTokenType , leaf . getText ( ) ) ; return new CommonToken ( tokenType , leaf . getText ( ) ) ; } else if ( leaf . getGrammarElement ( ) == rightCurlyInBlock || leaf . getGrammarElement ( ) == rightCurlyInArrowExpression ) { int tokenType = tokenTypeMapper . getInternalTokenType ( leaf ) ; next = new CommonToken ( tokenType ) ; return new CommonToken ( tokenTypeMapper . getInternalTokenType ( semicolon ) , leaf . getText ( ) ) ; } else { return newSemicolonToken ( leaf ) ; } } }
produces either one or two tokens from the given leaf which represents a location where the production parser inserted a semicolon .
