예제 #1
0
파일: parse.go 프로젝트: uberj/bindparse.go
func ParseNewLines(s *scanner.Scanner) (bool, error) {
	// ParseNewLines: Consume newlines
	ret := false
	for {
		peek := <-s.Peek()
		//if err := goodToken(&peek); err != nil {return false, err}
		if peek.Value == "\n" {
			ret = true
			<-s.Next()
			continue
		}
		break
	}
	return ret, nil
}
예제 #2
0
파일: parse.go 프로젝트: uberj/bindparse.go
func ParseComment(s *scanner.Scanner) (bool, string, error) {
	// ParseComment: Consume a comment if it exists. Stop leaving \n next
	// return:
	//  - bool: if a comment was parsed
	//  - string: the comment that was parsed
	//  - error: errors
	next := <-s.PeekUntil(`[\n;]`)
	if next.Value != ";" {
		return false, "", nil
	}
	for {
		peek := <-s.Peek()
		if peek.Value == "\n" || peek.End {
			break
		}
		<-s.Next()
	}
	return true, "", nil
}