Support for several splitter characters added
This commit is contained in:
parent
ce7ea36b0b
commit
acab7dd5f3
|
@ -38,7 +38,7 @@ public final class Lexer
|
||||||
|
|
||||||
position++;
|
position++;
|
||||||
}
|
}
|
||||||
else if(currentChar == ';' && !stringMode)
|
else if(isSpliter(currentChar) && !stringMode)
|
||||||
{
|
{
|
||||||
/* Flush the current token (if one exists) */
|
/* Flush the current token (if one exists) */
|
||||||
if(currentToken.length)
|
if(currentToken.length)
|
||||||
|
@ -100,4 +100,14 @@ public final class Lexer
|
||||||
{
|
{
|
||||||
return tokens;
|
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 == '!';
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -15,8 +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;";
|
// string sourceCode = "hello;";
|
||||||
Lexer currentLexer = new Lexer(sourceCode);
|
Lexer currentLexer = new Lexer(sourceCode);
|
||||||
currentLexer.performLex();
|
currentLexer.performLex();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue