public static List<ScriptVariable> GetLocalVariableDeclarationsFromScriptExtract(string scriptToParse, int relativeCharacterIndex)
{
FastString script = scriptToParse;
List<ScriptVariable> variables = new List<ScriptVariable>();
string lastWord = string.Empty;
while (script.Length > 0)
{
string nextWord = GetNextWord(ref script);
if (nextWord.Length == 0)
{
continue;
}
if ((Char.IsLetter(nextWord[0])) || (nextWord == "*") || (nextWord[0] == '_'))
{
if ((lastWord.Length > 0) && (script.Length > 0))
{
bool isPointer = false;
if (nextWord == "*")
{
isPointer = true;
nextWord = GetNextWord(ref script);
if ((script.Length == 0) || (!Char.IsLetter(nextWord[0])))
{
lastWord = string.Empty;
continue;
}
}
string variableName = nextWord;
nextWord = GetNextWord(ref script);
bool isArray = false;
if (nextWord == "[")
{
isArray = true;
while ((script.Length > 0) && (GetNextWord(ref script) != "]")) ;
nextWord = GetNextWord(ref script);
}
if (((nextWord == "=") || (nextWord == ";") || (nextWord == ",")) &&
(lastWord != "return") && (lastWord != "else"))
{
variables.Add(new ScriptVariable(variableName, lastWord, isArray, isPointer, null, null, false, false, false, false, (scriptToParse.Length - script.Length) + relativeCharacterIndex));
}
if (nextWord != ",")
{
lastWord = string.Empty;
}
}
else
{
lastWord = nextWord;
}
}
else
{
lastWord = string.Empty;
}
}
return variables;
}