src

Go monorepo.
git clone git://code.dwrz.net/src
Log | Files | Refs

ws_token.go (437B)


      1 package ini
      2 
      3 import (
      4 	"unicode"
      5 )
      6 
      7 // isWhitespace will return whether or not the character is
      8 // a whitespace character.
      9 //
     10 // Whitespace is defined as a space or tab.
     11 func isWhitespace(c rune) bool {
     12 	return unicode.IsSpace(c) && c != '\n' && c != '\r'
     13 }
     14 
     15 func newWSToken(b []rune) (Token, int, error) {
     16 	i := 0
     17 	for ; i < len(b); i++ {
     18 		if !isWhitespace(b[i]) {
     19 			break
     20 		}
     21 	}
     22 
     23 	return newToken(TokenWS, b[:i], NoneType), i, nil
     24 }