예제 #1
0
파일: states.go 프로젝트: hfern/luao
func stComment(l lex.Lexer) lex.StateFn {
	isComment := '-' == l.NextRune() && '-' == l.NextRune()
	if !isComment {
		emitError("Comment parser called without comment.")
		return nil
	}

	// check if this is going to be a block comment
	if longStringEquals('[', l) >= 0 {
		// consume the string portion
		if !readLongString(l) {
			emitError("Error reading block-comment contents")
			return nil
		}
	} else {
		// read til \n is found
		l.NonMatchZeroOrMoreRunes([]rune{'\n', lex.RuneEOF})
	}

	emit(l, Comment)
	return stStart
}