code: func (p *parser) Next() Pattern {
  	// keep searching until we find the next pattern, or until we
  	// reach the end of the file
  	for {
  		_token, _err := p.next()
  		if _err != nil {
  			if !p.errors(_err) {
  				return nil
  			}
  
  			// we got an error from the lexer, so skip the remainder
  			// of this line and try again from the next line
  			for _err != nil {
  				_err = p.skip()
  				if _err != nil {
  					if !p.errors(_err) {
  						return nil
  					}
  				}
  			}
  			continue
  		}
  
  		switch _token.Type {
  		// we're at the end of the file
  		case EOF:
  			return nil
  
  		// we have a blank line or comment
  		case EOL:
  			continue
  		case COMMENT:
  			continue
  
  		// otherwise, attempt to build the next pattern
  		default:
  			_pattern, _err := p.build(_token)
  			if _err != nil {
  				if !p.errors(_err) {
  					return nil
  				}
  
  				// we encountered an error parsing the retrieved tokens
  				//      - skip to the end of the line
  				for _err != nil {
  					_err = p.skip()
  					if _err != nil {
  						if !p.errors(_err) {
  							return nil
  						}
  					}
  				}
  
  				// skip to the next token
  				continue
  			} else if _pattern != nil {
  				return _pattern
  			}
  		}
  	}
  }
docs: // Next returns the next well-formed .gitignore Pattern from the parser stream.
  // If an error is encountered, and the error handler is either not defined, or
  // returns true, Next will skip to the end of the current line and attempt to
  // parse the next Pattern. If the error handler returns false, or the parser
  // reaches the end of the stream, Next returns nil.