|
|
|
@ -319,13 +319,13 @@ function open(parser) {
|
|
|
|
|
|
|
|
|
|
/** @param {import('../index.js').Parser} parser */
|
|
|
|
|
function next(parser) {
|
|
|
|
|
const start = parser.index - 1;
|
|
|
|
|
const next_to_bracket = parser.index - 1;
|
|
|
|
|
|
|
|
|
|
const block = parser.current(); // TODO type should not be TemplateNode, that's much too broad
|
|
|
|
|
|
|
|
|
|
if (block.type === 'IfBlock') {
|
|
|
|
|
if (!parser.eat('else')) e.expected_token(start, '{:else} or {:else if}');
|
|
|
|
|
if (parser.eat('if')) e.block_invalid_elseif(start);
|
|
|
|
|
if (!parser.eat('else')) e.expected_token(next_to_bracket, '{:else} or {:else if}');
|
|
|
|
|
if (parser.eat('if')) e.block_invalid_elseif(next_to_bracket);
|
|
|
|
|
|
|
|
|
|
parser.allow_whitespace();
|
|
|
|
|
|
|
|
|
@ -345,7 +345,7 @@ function next(parser) {
|
|
|
|
|
|
|
|
|
|
/** @type {ReturnType<typeof parser.append<import('#compiler').IfBlock>>} */
|
|
|
|
|
const child = parser.append({
|
|
|
|
|
start: parser.index,
|
|
|
|
|
start: next_to_bracket - 1,
|
|
|
|
|
end: -1,
|
|
|
|
|
type: 'IfBlock',
|
|
|
|
|
elseif: true,
|
|
|
|
@ -367,7 +367,7 @@ function next(parser) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (block.type === 'EachBlock') {
|
|
|
|
|
if (!parser.eat('else')) e.expected_token(start, '{:else}');
|
|
|
|
|
if (!parser.eat('else')) e.expected_token(next_to_bracket, '{:else}');
|
|
|
|
|
|
|
|
|
|
parser.allow_whitespace();
|
|
|
|
|
parser.eat('}', true);
|
|
|
|
@ -383,7 +383,7 @@ function next(parser) {
|
|
|
|
|
if (block.type === 'AwaitBlock') {
|
|
|
|
|
if (parser.eat('then')) {
|
|
|
|
|
if (block.then) {
|
|
|
|
|
e.block_duplicate_clause(start, '{:then}');
|
|
|
|
|
e.block_duplicate_clause(next_to_bracket, '{:then}');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!parser.eat('}')) {
|
|
|
|
@ -402,7 +402,7 @@ function next(parser) {
|
|
|
|
|
|
|
|
|
|
if (parser.eat('catch')) {
|
|
|
|
|
if (block.catch) {
|
|
|
|
|
e.block_duplicate_clause(start, '{:catch}');
|
|
|
|
|
e.block_duplicate_clause(next_to_bracket, '{:catch}');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!parser.eat('}')) {
|
|
|
|
@ -419,10 +419,10 @@ function next(parser) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
e.expected_token(start, '{:then ...} or {:catch ...}');
|
|
|
|
|
e.expected_token(next_to_bracket, '{:then ...} or {:catch ...}');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
e.block_invalid_continuation_placement(start);
|
|
|
|
|
e.block_invalid_continuation_placement(next_to_bracket);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** @param {import('../index.js').Parser} parser */
|
|
|
|
|