Ensure the last read byte and following bytes match expected.

If it is, read one more byte. If not, fire a fatal error using context. context is the part of the message that gives the context. For example, in Unexpected `xin y. Expectingz`., the value of context is " in y".

Return true if and only if the last read byte and following bytes match expected.

Property definitions

saxophonit $ XophonLexer :: expect_string
	# Ensure the last read byte and following bytes match `expected`.
	#
	# If it is, read one more byte. If not, fire a fatal error using
	# `context`. `context` is the part of the message that gives the context.
	# For example, in `Unexpected ``x`` in y. Expecting ``z``.`, the value of
	# `context` is `" in y"`.
	#
	# Return `true` if and only if the last read byte and following bytes
	# match `expected`.
	fun expect_string(expected: String, context: String): Bool do
		var chars = expected.chars
		var i = 0

		while i < chars.length do
			if not accept(chars[i]) then
				if is_xml_char then
					return fire_fatal_error("Unexpected " +
							"`{expected.substring(0, i)}{last_char.code_point.to_s}`" +
							"{context}. Expecting `{expected}`.")
				else if eof then
					return fire_fatal_error("Unexpected end of file{context}. " +
							"Expecting `{expected}`.")
				else
					return fire_fatal_error("Forbidden character.")
				end
			end
			i += 1
		end
		return true
	end
lib/saxophonit/lexer.nit:349,2--378,4