public static ScriptObject[] GetClasses(ScriptString file) { var classes = new List <ScriptObject>(); int start = 0, blocks = 0; ScriptString?[] words = new ScriptString?[8]; void Rotate() { for (int i = words.Length - 1; i > 0; i--) { words[i] = words[i - 1]; } words[0] = null; } bool inString = false; for (int end = 0; end < file.Length; end++) { ScriptChar current = file[end]; if (current == '"' && (char)file[end - 1] != '\\') { inString = !inString; continue; } if (char.IsWhiteSpace((char)current)) { if (words[0].HasValue && words[0].Value != "" && blocks == 0) { Rotate(); } } else if (current == '{') { blocks++; if (blocks == 1) { start = end + 1; } } else if (current == '}') { blocks--; if (blocks == 0) { //todo: access classes.Add(new ScriptObject(words[1].Value, words[2].Value, file[start..end]));
public ScriptWord(ScriptString characters, bool ignoreCohesion = false) { if (ignoreCohesion || (characters.Length >= 2 && characters[0] == '"' && characters[^ 1] == '"')) { } else { foreach (ScriptChar character in characters) { if (char.IsWhiteSpace((char)character)) { throw new ArgumentException("Given array is not a cohesive word!", nameof(characters)); } } } ScriptString = characters; }
public ScriptFile(ScriptString scriptFile) : this(GetClasses(scriptFile)) { }