src

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

comment_token.go (578B)


      1 package ini
      2 
      3 // isComment will return whether or not the next byte(s) is a
      4 // comment.
      5 func isComment(b []rune) bool {
      6 	if len(b) == 0 {
      7 		return false
      8 	}
      9 
     10 	switch b[0] {
     11 	case ';':
     12 		return true
     13 	case '#':
     14 		return true
     15 	}
     16 
     17 	return false
     18 }
     19 
     20 // newCommentToken will create a comment token and
     21 // return how many bytes were read.
     22 func newCommentToken(b []rune) (Token, int, error) {
     23 	i := 0
     24 	for ; i < len(b); i++ {
     25 		if b[i] == '\n' {
     26 			break
     27 		}
     28 
     29 		if len(b)-i > 2 && b[i] == '\r' && b[i+1] == '\n' {
     30 			break
     31 		}
     32 	}
     33 
     34 	return newToken(TokenComment, b[:i], NoneType), i, nil
     35 }