Added support for semi-colon delimiting

This commit is contained in:
Tristan B. Velloza Kildaire 2021-03-02 22:31:18 +02:00
parent 1f103bf190
commit cce91b6615
2 changed files with 13 additions and 1 deletions

View File

@ -38,6 +38,17 @@ public final class Lexer
position++; position++;
} }
else if(currentChar == ';' && !stringMode)
{
/* Flush the current token */
currentTokens ~= currentToken;
currentToken = "";
/* Add the ; token */
currentTokens ~= ";";
position++;
}
else if(currentChar == '"') else if(currentChar == '"')
{ {
/* If we are not in string mode */ /* If we are not in string mode */

View File

@ -15,7 +15,8 @@ void beginCompilation(string[] sourceFiles)
gprintln("Performing tokenization on '"~sourceFile~"' ..."); gprintln("Performing tokenization on '"~sourceFile~"' ...");
/* TODO: Open source file */ /* TODO: Open source file */
string sourceCode = "hello \"world\";"; // string sourceCode = "hello \"world\";";
string sourceCode = "hello;";
Lexer currentLexer = new Lexer(sourceCode); Lexer currentLexer = new Lexer(sourceCode);
currentLexer.performLex(); currentLexer.performLex();