templates support
This commit is contained in:
44
Inspectron.Epson.Templates/Language/Token.cs
Normal file
44
Inspectron.Epson.Templates/Language/Token.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
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));
|
||||
}
|
||||
Reference in New Issue
Block a user