code: func (p *Parser) scan() token.Token {
  	// If we have a token on the buffer, then return it.
  	if p.n != 0 {
  		p.n = 0
  		return p.tok
  	}
  
  	// Otherwise read the next token from the scanner and Save it to the buffer
  	// in case we unscan later.
  	prev := p.tok
  	p.tok = p.sc.Scan()
  
  	if p.tok.Type == token.COMMENT {
  		var comment *ast.CommentGroup
  		var endline int
  
  		// fmt.Printf("p.tok.Pos.Line = %+v prev: %d endline %d \n",
  		// p.tok.Pos.Line, prev.Pos.Line, endline)
  		if p.tok.Pos.Line == prev.Pos.Line {
  			// The comment is on same line as the previous token; it
  			// cannot be a lead comment but may be a line comment.
  			comment, endline = p.consumeCommentGroup(0)
  			if p.tok.Pos.Line != endline {
  				// The next token is on a different line, thus
  				// the last comment group is a line comment.
  				p.lineComment = comment
  			}
  		}
  
  		// consume successor comments, if any
  		endline = -1
  		for p.tok.Type == token.COMMENT {
  			comment, endline = p.consumeCommentGroup(1)
  		}
  
  		if endline+1 == p.tok.Pos.Line && p.tok.Type != token.RBRACE {
  			switch p.tok.Type {
  			case token.RBRACE, token.RBRACK:
  				// Do not count for these cases
  			default:
  				// The next token is following on the line immediately after the
  				// comment group, thus the last comment group is a lead comment.
  				p.leadComment = comment
  			}
  		}
  
  	}
  
  	return p.tok
  }
docs: // scan returns the next token from the underlying scanner. If a token has
  // been unscanned then read that instead. In the process, it collects any
  // comment groups encountered, and remembers the last lead and line comments.