// scanStringliteral consumes the current rune and all contiguous literal tokens.
// Both surrounding quotes are excluded.
//todo: are Line Breaks in literals allowed ?
scanStringliteral consumes the current rune and all contiguous literal tokens.
Both surrounding quotes are excluded.
// scanStringliteral consumes the current rune and all contiguous literal tokens . // Both surrounding quotes are excluded . // todo : are Line Breaks in literals allowed ?
func (s *Scanner) scanStringliteral() (tok Token, lit string) {
	var buf bytes.Buffer
	s.read() 
	var chPrev rune
	for {
		ch := s.read()
		if ch == eof {
			s.unread()
			break
		}
		if ch == '"' && chPrev != '\\' {
			break
		}
		buf.WriteRune(ch)
		chPrev = ch
	}
	return STRINGLIT, buf.String()
}
func ( s * Scanner ) scanStringliteral ( ) ( tok Token , lit string ) { var buf bytes . Buffer s . read ( ) var chPrev rune for { ch := s . read ( ) if ch == eof { s . unread ( ) break } if ch == '"' && chPrev != '\\' { break } buf . WriteRune ( ch ) chPrev = ch } return STRINGLIT , buf . String ( ) }
scanStringliteral consumes the current rune and all contiguous literal tokens.
scanStringliteral consumes the current rune and all contiguous literal tokens .
// Create a buffer and read the current character into it. // first quote // buf.WriteRune(s.read()) // Read every subsequent string literal character into the buffer. // Quote end EOF will cause the loop to exit. // break at "