This commit is contained in:
EugeneTes
2026-01-23 12:57:01 +01:00
parent fcb192b797
commit 71300aab24
15 changed files with 811 additions and 658 deletions

View File

@@ -73,38 +73,38 @@ public class TemplateInterpreter
// Styled text - flush buffer, emit styled content, continue accumulating
case StyledTextNode styledNode:
FlushLineBuffer();
InterpretStyledText(styledNode, context, commands, style);
break;
// Block nodes - flush buffer first, then process
case SeparatorNode separatorNode:
FlushLineBuffer();
InterpretSeparator(separatorNode, commands, style);
break;
case EmptyLineNode:
case NewLineNode:
FlushLineBuffer();
commands.Add(CreateCommand(string.Empty, style));
break;
case IfNode ifNode:
FlushLineBuffer();
InterpretIf(ifNode, context, commands, style);
break;
case ForeachNode foreachNode:
FlushLineBuffer();
InterpretForeach(foreachNode, context, commands, style);
break;
case RowNode rowNode:
FlushLineBuffer();
InterpretRow(rowNode, context, commands, style);
break;
case ColumnNode columnNode:
FlushLineBuffer();
InterpretColumn(columnNode, context, commands, style);
break;
}

View File

@@ -1,6 +1,6 @@
namespace Inspectron.Epson.Templates.Language.Nodes;
public record EmptyLineNode(SourcePosition Position) : ITemplateNode
public record NewLineNode(SourcePosition Position) : ITemplateNode
{
public IReadOnlyList<ITemplateNode> Children => Array.Empty<ITemplateNode>();
}

View File

@@ -46,12 +46,10 @@ public class Parser
{
case TokenType.NewLine:
Advance();
// Check if this was an empty line (previous was also newline or start)
if (_position >= 2 && _tokens[_position - 2].Type == TokenType.NewLine)
{
return new EmptyLineNode(token.Position);
}
return null;
if(token.Position.Column==1)
return new NewLineNode(token.Position);
else
return null;
case TokenType.Text:
return ParseText();

View File

@@ -139,7 +139,7 @@ public class TemplateValidator
case TextNode:
case SeparatorNode:
case EmptyLineNode:
case NewLineNode:
// No additional validation needed
break;
}