45 lines
1.1 KiB
C#
45 lines
1.1 KiB
C#
namespace Inspectron.Epson.Templates.Language;
|
|
|
|
public enum TokenType
|
|
{
|
|
// Text content
|
|
Text,
|
|
|
|
// Styled text: #style1,style2# text #
|
|
StyleStart, // #style1,style2#
|
|
StyleEnd, // trailing #
|
|
|
|
// Bindings: {path} or {path:format}
|
|
Binding,
|
|
|
|
// Separators
|
|
DashSeparator, // ---
|
|
EqualsSeparator, // ===
|
|
StarSeparator, // ***
|
|
TildeSeparator, // ~~~
|
|
|
|
// Directives
|
|
If, // @if condition
|
|
ElseIf, // @elseif condition
|
|
Else, // @else
|
|
End, // @end
|
|
Foreach, // @foreach item in collection
|
|
Row, // @row
|
|
EndRow, // @endrow
|
|
Column, // |width| or |width,align|
|
|
|
|
// Structural
|
|
NewLine,
|
|
EndOfFile
|
|
}
|
|
|
|
public record struct SourcePosition(int Line, int Column)
|
|
{
|
|
public override string ToString() => $"({Line}:{Column})";
|
|
}
|
|
|
|
public record Token(TokenType Type, string Value, SourcePosition Position)
|
|
{
|
|
public static Token Eof(int line) => new(TokenType.EndOfFile, string.Empty, new SourcePosition(line, 0));
|
|
}
|