From 2ceaa0c8b06181757181e0f0e580784c1fde2b59 Mon Sep 17 00:00:00 2001 From: "Tristan B. Kildaire" Date: Wed, 3 Mar 2021 11:05:57 +0200 Subject: [PATCH] Added Token class for future use in lexer --- source/tlang/compiler/lexer.d | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/source/tlang/compiler/lexer.d b/source/tlang/compiler/lexer.d index 67c2fd5..420c82d 100644 --- a/source/tlang/compiler/lexer.d +++ b/source/tlang/compiler/lexer.d @@ -4,6 +4,28 @@ import std.container.slist; import gogga; import std.conv : to; +/* TODO: Add Token type (which matches column and position too) */ +public final class Token +{ + /* The token */ + private string token; + + /* Line number information */ + private ulong line, column; + + this(string token, ulong line, ulong column) + { + this.token = token; + this.line = line; + this.column = column; + } + + override string toString() + { + return token~" at ("~to!(string)(line)~", "~to!(string)(column)~")"; + } +} + public final class Lexer { /* The source to be lexed */