Home / Function/ read_sequence() — svelte Function Reference

read_sequence() — svelte Function Reference

Architecture documentation for the read_sequence() function in element.js from the svelte codebase.

Function javascript Compiler Transformer calls 5 called by 2

Entity Profile

Dependency Diagram

graph TD
  babf57bd_0606_e8ec_fde4_75ed47bb1407["read_sequence()"]
  206889ff_1f9f_b6c1_d530_059d001e1cf4["element.js"]
  babf57bd_0606_e8ec_fde4_75ed47bb1407 -->|defined in| 206889ff_1f9f_b6c1_d530_059d001e1cf4
  be9cd3f4_bdc5_dc26_dae4_4a34e45ab7eb["element()"]
  be9cd3f4_bdc5_dc26_dae4_4a34e45ab7eb -->|calls| babf57bd_0606_e8ec_fde4_75ed47bb1407
  9fcb1dc7_f1ea_4501_df05_9617e7c7d114["read_attribute_value()"]
  9fcb1dc7_f1ea_4501_df05_9617e7c7d114 -->|calls| babf57bd_0606_e8ec_fde4_75ed47bb1407
  83712aa1_c83d_1cd5_c47d_1cdb04dd210c["decode_character_references()"]
  babf57bd_0606_e8ec_fde4_75ed47bb1407 -->|calls| 83712aa1_c83d_1cd5_c47d_1cdb04dd210c
  7456f942_2146_d05f_85c6_a6cf9f5fdc0e["block_invalid_placement()"]
  babf57bd_0606_e8ec_fde4_75ed47bb1407 -->|calls| 7456f942_2146_d05f_85c6_a6cf9f5fdc0e
  72b3dfd7_c10d_2733_4af8_bab2fd4e4203["tag_invalid_placement()"]
  babf57bd_0606_e8ec_fde4_75ed47bb1407 -->|calls| 72b3dfd7_c10d_2733_4af8_bab2fd4e4203
  f55653bc_77b3_5212_03f1_93bc274916e8["read_expression()"]
  babf57bd_0606_e8ec_fde4_75ed47bb1407 -->|calls| f55653bc_77b3_5212_03f1_93bc274916e8
  feea79ed_c6f7_4068_9c81_9734e5dcbfb7["unexpected_eof()"]
  babf57bd_0606_e8ec_fde4_75ed47bb1407 -->|calls| feea79ed_c6f7_4068_9c81_9734e5dcbfb7
  style babf57bd_0606_e8ec_fde4_75ed47bb1407 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/svelte/src/compiler/phases/1-parse/state/element.js lines 777–855

function read_sequence(parser, done, location) {
	/** @type {AST.Text} */
	let current_chunk = {
		start: parser.index,
		end: -1,
		type: 'Text',
		raw: '',
		data: ''
	};

	/** @type {Array<AST.Text | AST.ExpressionTag>} */
	const chunks = [];

	/** @param {number} end */
	function flush(end) {
		if (current_chunk.raw) {
			current_chunk.data = decode_character_references(current_chunk.raw, true);
			current_chunk.end = end;
			chunks.push(current_chunk);
		}
	}

	while (parser.index < parser.template.length) {
		const index = parser.index;

		if (done()) {
			flush(parser.index);
			return chunks;
		} else if (parser.eat('{')) {
			if (parser.match('#')) {
				const index = parser.index - 1;
				parser.eat('#');
				const name = parser.read_until(/[^a-z]/);
				e.block_invalid_placement(index, name, location);
			} else if (parser.match('@')) {
				const index = parser.index - 1;
				parser.eat('@');
				const name = parser.read_until(/[^a-z]/);
				e.tag_invalid_placement(index, name, location);
			}

			flush(parser.index - 1);

			parser.allow_whitespace();
			const expression = read_expression(parser);
			parser.allow_whitespace();
			parser.eat('}', true);

			/** @type {AST.ExpressionTag} */
			const chunk = {
				type: 'ExpressionTag',
				start: index,
				end: parser.index,
				expression,
				metadata: {
					expression: new ExpressionMetadata()
				}
			};

			chunks.push(chunk);

			current_chunk = {
				start: parser.index,
				end: -1,
				type: 'Text',
				raw: '',
				data: ''
			};
		} else {
			current_chunk.raw += parser.template[parser.index++];
		}
	}

	if (parser.loose) {
		return chunks;
	} else {
		e.unexpected_eof(parser.template.length);
	}
}

Domain

Subdomains

Frequently Asked Questions

What does read_sequence() do?
read_sequence() is a function in the svelte codebase, defined in packages/svelte/src/compiler/phases/1-parse/state/element.js.
Where is read_sequence() defined?
read_sequence() is defined in packages/svelte/src/compiler/phases/1-parse/state/element.js at line 777.
What does read_sequence() call?
read_sequence() calls 5 function(s): block_invalid_placement, decode_character_references, read_expression, tag_invalid_placement, unexpected_eof.
What calls read_sequence()?
read_sequence() is called by 2 function(s): element, read_attribute_value.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free