final receipt update

This commit is contained in:
EugeneTes
2026-01-22 11:09:38 +01:00
parent 9fbc61dede
commit fcb192b797
31 changed files with 2679 additions and 655 deletions

View File

@@ -13,6 +13,7 @@ public class Lexer
private readonly List<LexerError> _errors = new();
private bool _inMultiLineComment;
private SourcePosition _multiLineCommentStart;
private bool _isCommentOnlyLine;
private static readonly Regex StyleStartRegex = new(@"^#([a-zA-Z0-9,:]+)#", RegexOptions.Compiled);
private static readonly Regex BindingRegex = new(@"^\{([^}]+)\}", RegexOptions.Compiled);
@@ -40,8 +41,14 @@ public class Lexer
while (_lineIndex < _lines.Count)
{
_isCommentOnlyLine = false;
TokenizeLine(_lines[_lineIndex]);
_tokens.Add(new Token(TokenType.NewLine, "\n", new SourcePosition(_lineIndex + 1, _columnIndex + 1)));
// Skip NewLine for comment-only lines and lines inside multi-line comments
if (!_isCommentOnlyLine && !_inMultiLineComment)
{
_tokens.Add(new Token(TokenType.NewLine, "\n", new SourcePosition(_lineIndex + 1, _columnIndex + 1)));
}
_lineIndex++;
_columnIndex = 0;
}
@@ -76,12 +83,14 @@ public class Lexer
}
else
{
// Comment close line with no content after
_isCommentOnlyLine = true;
_columnIndex = line.Length;
}
}
else
{
// Still in comment - skip entire line
// Still in comment - skip entire line (handled by _inMultiLineComment check in Tokenize)
_columnIndex = line.Length;
}
return;
@@ -107,6 +116,8 @@ public class Lexer
}
else
{
// Comment-only line (no content after *@)
_isCommentOnlyLine = true;
_columnIndex = line.Length;
}
}
@@ -114,12 +125,14 @@ public class Lexer
{
// Start of multi-line comment block
_inMultiLineComment = true;
_isCommentOnlyLine = true;
_multiLineCommentStart = new SourcePosition(lineNumber, leadingWhitespace + 1);
_columnIndex = line.Length;
}
else
{
// Single-line comment to end of line
_isCommentOnlyLine = true;
_columnIndex = line.Length;
}
return;
@@ -215,7 +228,7 @@ public class Lexer
return true;
case "@row":
_tokens.Add(new Token(TokenType.Row, string.Empty, position));
_tokens.Add(new Token(TokenType.Row, value, position));
_columnIndex = trimmed.Length + leadingWhitespace;
return true;

View File

@@ -1,6 +1,6 @@
namespace Inspectron.Epson.Templates.Language.Nodes;
public record RowNode(List<ColumnNode> Columns, SourcePosition Position) : ITemplateNode
public record RowNode(List<ColumnNode> Columns, IReadOnlyList<string> Styles, SourcePosition Position) : ITemplateNode
{
public IReadOnlyList<ITemplateNode> Children => Columns;
}

View File

@@ -254,6 +254,9 @@ public class Parser
private RowNode ParseRow()
{
var rowToken = Current;
var styles = string.IsNullOrWhiteSpace(rowToken.Value)
? Array.Empty<string>()
: rowToken.Value.Split(',', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries);
Advance(); // consume @row
SkipNewlines();
@@ -300,7 +303,7 @@ public class Parser
AddError("Expected @endrow to close @row block", Current.Position);
}
return new RowNode(columns, rowToken.Position);
return new RowNode(columns, styles, rowToken.Position);
}
private ColumnNode ParseColumnDef()