From acab7dd5f38f10883108e7b34fa7a1877f0f9934 Mon Sep 17 00:00:00 2001 From: "Tristan B. Kildaire" Date: Tue, 2 Mar 2021 22:43:09 +0200 Subject: [PATCH] Support for several splitter characters added --- source/tlang/commandline/lexer.d | 12 +++++++++++- source/tlang/compiler/compiler.d | 4 ++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/source/tlang/commandline/lexer.d b/source/tlang/commandline/lexer.d index ac38b29..b498470 100644 --- a/source/tlang/commandline/lexer.d +++ b/source/tlang/commandline/lexer.d @@ -38,7 +38,7 @@ public final class Lexer position++; } - else if(currentChar == ';' && !stringMode) + else if(isSpliter(currentChar) && !stringMode) { /* Flush the current token (if one exists) */ if(currentToken.length) @@ -100,4 +100,14 @@ public final class Lexer { return tokens; } + + /* TODO: We need to add pop functionality if we encounter || */ + private bool isSpliter(char character) + { + return character == ';' || character == ',' || character == '(' || + character == ')' || character == '[' || character == ']' || + character == '+' || character == '-' || character == '/' || + character == '%' || character == '*' || character == '&' || + character == '|' || character == '^' || character == '!'; + } } \ No newline at end of file diff --git a/source/tlang/compiler/compiler.d b/source/tlang/compiler/compiler.d index 4567de8..444a213 100644 --- a/source/tlang/compiler/compiler.d +++ b/source/tlang/compiler/compiler.d @@ -15,8 +15,8 @@ void beginCompilation(string[] sourceFiles) gprintln("Performing tokenization on '"~sourceFile~"' ..."); /* TODO: Open source file */ - // string sourceCode = "hello \"world\";"; - string sourceCode = "hello;"; + string sourceCode = "hello \"world\";"; + // string sourceCode = "hello;"; Lexer currentLexer = new Lexer(sourceCode); currentLexer.performLex();