using System.Collections.Generic;
public static void Main()
string exampleString = "int test = 1; Print(test1);";
StringBuilder test = new StringBuilder(exampleString);
Tokenizer.TokenizeString(test);
static List<char> splitChars = new List<char>() { '{', '}', ';', '(', ')' };
static List<string> validFunctions = new List<string>()
static List<string> validTypes = new List<string>()
public static void TokenizeString(StringBuilder text)
StringBuilder currentString = new StringBuilder();
List<StringBuilder> tokens = new List<StringBuilder>();
bool lastCharWasWhitespace = false;
for (int i = 0; i < text.Length; i++)
if (!char.IsWhiteSpace(text[i]))
if (splitChars.Contains(text[i]))
if (currentString.Length > 0)
tokens.Add(currentString);
currentString = new StringBuilder();
currentString.Append(text[i]);
tokens.Add(currentString);
currentString = new StringBuilder();
lastCharWasWhitespace = true;
lastCharWasWhitespace = false;
currentString.Append(text[i]);
if (!lastCharWasWhitespace)
lastCharWasWhitespace = true;
tokens.Add(currentString);
currentString = new StringBuilder();
if (currentString.Length > 0)
tokens.Add(currentString);
foreach (StringBuilder token in tokens)
Console.WriteLine(token);
Dictionary<string, int> variableDictionary = new Dictionary<string, int>();
int currentMemoryIndex = 1;
string currentToken = "";
List<Token> processedTokens = new List<Token>();
for (int i = 0; i < tokens.Count; i++)
currentToken = tokens[i].ToString();
if (validTypes.Contains(currentToken))
processedTokens.Add(new Token("type", currentToken));
else if (currentToken == "=")
processedTokens.Add(new Token("equator", null));
else if (currentToken == ";")
processedTokens.Add(new Token("lineTerminator", null));
public Token(string type, string? contents)
this.contents = contents;