refine blocks detection

This commit is contained in:
2026-08-17 12:45:46 +02:00
parent ed51ddc449
commit 550654bacb
3 changed files with 133 additions and 153 deletions
+9
View File
@@ -233,6 +233,9 @@ export class EftlParser {
case TokenType.VALUE_OF:
case TokenType.SIZE_OF:
case TokenType.HEADER:
if (!token.value.endsWith('/]')) {
this.pushBlock(token);
}
this.advance();
break;
@@ -249,6 +252,9 @@ export class EftlParser {
}
private pushBlock(token: Token): void {
if (token.value.endsWith('/]')) {
return; // It's self-closing, don't push to stack
}
this.blockStack.push({ type: token.type, token });
}
@@ -295,6 +301,9 @@ export class EftlParser {
[TokenType.TRIM_OPEN]: '[/TRIM]',
[TokenType.CONTAINS_OPEN]: '[/CONTAINS]',
[TokenType.FORMAT_OPEN]: '[/FORMAT]',
[TokenType.VALUE_OF]: '[/VALUE_OF]',
[TokenType.SIZE_OF]: '[/SIZE_OF]',
[TokenType.HEADER]: '[/HEADER]',
[TokenType.EXPR_OPEN]: '%]',
[TokenType.EXPR_OUTPUT_OPEN]: '%]',
[TokenType.COMMENT_OPEN]: '--]'
+2 -8
View File
@@ -298,7 +298,7 @@ export class EftlTokenizer {
private scanVarOpen(startLine: number, startColumn: number): void {
let value = '[VAR';
// Scan until we find ] or ]
// Scan until we find ]
while (this.pos < this.source.length && this.peek() !== ']') {
value += this.advance();
}
@@ -328,13 +328,7 @@ export class EftlTokenizer {
break;
}
if (ch === ']') {
// Not self-closing, error
this.errors.push({
message: `Expected self-closing tag: [${tagName} ... /]`,
line: startLine,
column: startColumn,
length: value.length
});
// Could be block start, let parser handle it if it's supposed to be self-closing
break;
}
}