Home / Highlights / FAQ / Examples / Quick Start / Roadmap / Download / About Us
main()
{
	reader := OpenFile("/etc/nginx/mime.types")
	
	//Read the file from OS ensuring at least one line is ready
	reader.BufferLine() 

	//WSNL will ignore whitespace and newlines.
	//Expects will set HasError to true if the expect word didn't match
	reader.WSNL().Expect("types")
	reader.WSNL().Expect("{")
	while !reader.HasError
	{
		reader.WSNL() //WSNL will buffer a line if it reaches end of a line
		//Eat will consume characters until it finds one of these tokens or a newline
		//mime is a string slice, not a copy
		mime, tok := reader.Eat("\t }")
		if tok == '}'
			break
		while tok != ';' && !reader.HasError {
			reader.WS()
			ext, tok2 = reader.Eat("\t ;")
			tok .= tok2
			if ext.size == 0
				continue
			//Both mime and ext are availiable since no invalidating functions were called.
			//Bufferline, WSNL and IsEOF may overwrite previous data
			print("mime: $mime ext: $ext")
		}
	}
	reader.WSNL().ExpectEOF()
	//Instead of checking for errors everywhere
	//we can handle it at one location
	if reader.HasError {
		print("We did not process the file correctly")
		return
	}
	print("Done")
}