func (s *scanner) Scan() (tok token, lit string) {

	// Read the next rune.
	ch := s.read()

	// If we see whitespace then consume all contiguous whitespace.
	// If we see a letter then consume as an ident or reserved word.
	if isWhitespace(ch) {
		s.unread()
		tok, lit = s.scanWhitespace()
	} else if isLetter(ch) {
		s.unread()
		tok, lit = s.scanIdent()
	} else if isDigit(ch) || (isMinusOrPlus(ch) && (s.last == tokIllegal || s.last == tokLeftParenthesis || s.last == tokOperator)) {
		s.unread()
		tok, lit = s.scanNumber()
	} else if isOperator(ch) {
		s.unread()
		tok, lit = s.scanOperator()
	} else if isQuote(ch) {
		s.unread()
		tok, lit = s.scanString()
	} else {

		// Otherwise read the individual character.
		switch ch {
		case eof:
			tok, lit = tokEOF, ""
		case '(':
			tok, lit = tokLeftParenthesis, "("
		case ')':
			tok, lit = tokRightParenthesis, ")"
		default:
			tok, lit = tokIllegal, string(ch)
		}
	}

	if tok != tokWhitespace {
		s.last = tok
	}
	return tok, lit
}
// Scan returns the next token and literal value.
Scan returns the next token and literal value.
// Scan returns the next token and literal value .
func (s *scanner) Scan() (tok token, lit string) {
	ch := s.read()
	if isWhitespace(ch) {
		s.unread()
		tok, lit = s.scanWhitespace()
	} else if isLetter(ch) {
		s.unread()
		tok, lit = s.scanIdent()
	} else if isDigit(ch) || (isMinusOrPlus(ch) && (s.last == tokIllegal || s.last == tokLeftParenthesis || s.last == tokOperator)) {
		s.unread()
		tok, lit = s.scanNumber()
	} else if isOperator(ch) {
		s.unread()
		tok, lit = s.scanOperator()
	} else if isQuote(ch) {
		s.unread()
		tok, lit = s.scanString()
	} else {
		switch ch {
		case eof:
			tok, lit = tokEOF, ""
		case '(':
			tok, lit = tokLeftParenthesis, "("
		case ')':
			tok, lit = tokRightParenthesis, ")"
		default:
			tok, lit = tokIllegal, string(ch)
		}
	}
	if tok != tokWhitespace {
		s.last = tok
	}
	return tok, lit
}
func ( s * scanner ) Scan ( ) ( tok token , lit string ) { ch := s . read ( ) if isWhitespace ( ch ) { s . unread ( ) tok , lit = s . scanWhitespace ( ) } else if isLetter ( ch ) { s . unread ( ) tok , lit = s . scanIdent ( ) } else if isDigit ( ch ) || ( isMinusOrPlus ( ch ) && ( s . last == tokIllegal || s . last == tokLeftParenthesis || s . last == tokOperator ) ) { s . unread ( ) tok , lit = s . scanNumber ( ) } else if isOperator ( ch ) { s . unread ( ) tok , lit = s . scanOperator ( ) } else if isQuote ( ch ) { s . unread ( ) tok , lit = s . scanString ( ) } else { switch ch { case eof : tok , lit = tokEOF , " " case '(' : tok , lit = tokLeftParenthesis , " " case ')' : tok , lit = tokRightParenthesis , " " default : tok , lit = tokIllegal , string ( ch ) } } if tok != tokWhitespace { s . last = tok } return tok , lit }
Scan returns the next token and literal value.
Scan returns the next token and literal value .
// Read the next rune. // If we see whitespace then consume all contiguous whitespace. // If we see a letter then consume as an ident or reserved word. // Otherwise read the individual character.