Expect a Reference, without the initial &.

Append the value to the buffer.

Property definitions

saxophonit $ XophonReader :: expect_reference
	# Expect a `Reference`, without the initial `&`.
	#
	# Append the value to the buffer.
	private fun expect_reference(buffer: Buffer): Bool do
		# TODO: [WFC: Entity Declared]
		# TODO: [VC: Entity Declared]
		# TODO: [WFC: Parsed Entity]
		# TODO: [WFC: No Recursion]
		# TODO: Unicode

		var ref = new FlatBuffer

		if lexer.accept('#') then
			if lexer.accept('x') then
				if lexer.expect_hex(ref) then
					buffer.chars.add(ref.to_hex.code_point)
					return lexer.expect(';', "")
				else
					return lexer.fire_unexpected_char(
							". Expecting an hexadecimal digit")
				end
			else if lexer.accept_digits(ref) then
				buffer.chars.add(ref.to_i.code_point)
				return lexer.expect(';', "")
			else
				return lexer.fire_unexpected_char(" in a character reference. " +
						"Expecting `x` or a decimal digit")
			end
		else if lexer.expect_name(ref) then
			var name = ref.to_s
			if name.has(":") then
				model.fire_error("The entity name `{name}` contains a colon.", null)
			end
			var value = resolve_reference(name)

			if value != null then
				buffer.append(value)
				return lexer.expect(';', "")
			else
				model.fire_fatal_error("Unknown entity `{name}`.", null)
				return false
			end
		else
			return lexer.fire_unexpected_char(
					" in a reference. Expecting `#` or a name")
		end
	end
lib/saxophonit/saxophonit.nit:644,2--690,4