final receipt update
This commit is contained in:
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user