MCPcopy
hub / github.com/webpack/webpack / consumeASimpleBlock

Function consumeASimpleBlock

lib/css/syntax.js:2755–2790  ·  view source on GitHub ↗
(ts)

Source from the content-addressed store, hash-verified

2753 * @returns {SimpleBlock | undefined} the parsed simple block
2754 */
2755const consumeASimpleBlock = (ts) => {
2756 const open = ts.next();
2757 // Assert (spec): the next token of input is <{-token>, <[-token>, or <(-token>.
2758 // Mirror closing token (`opener + 3`) and the associated block char.
2759 const ending = open.type + 3;
2760 const token = BLOCK_TOKEN_CHAR[open.type - TT_LEFT_PARENTHESIS];
2761
2762 // Let block be a new simple block with its associated token set to the next token and with its value initially set to an empty list.
2763 const block = /** @type {SimpleBlock} */ (
2764 _mkContainer(T_SIMPLE_BLOCK, open.start, open.end)
2765 );
2766 _setToken(block, token);
2767 const val = _list();
2768 _setValue(block, val);
2769
2770 // Discard a token from input.
2771 ts.discard();
2772
2773 // Process input
2774 for (;;) {
2775 const t = ts.next();
2776
2777 // <eof-token>
2778 // ending token
2779 // Discard a token from input. Return block.
2780 if (t.type === TT_EOF || t.type === ending) {
2781 ts.discard();
2782 _setEnd(block, t.end);
2783 return block;
2784 }
2785
2786 // anything else
2787 // Consume a component value from input and append the result to block’s value.
2788 val.push(consumeAComponentValue(ts, t));
2789 }
2790};
2791
2792/**
2793 * Consume a function, CSS Syntax Level 3 [§5.4.10](https://drafts.csswg.org/css-syntax/#consume-function) — consumes component values up to the matching `)` or EOF (the partial function on EOF is a parse error).

Callers 1

consumeAComponentValueFunction · 0.85

Calls 5

_listFunction · 0.85
consumeAComponentValueFunction · 0.85
discardMethod · 0.80
nextMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected