private void RecursivePrintParameters(ADLFunction function, int num) { string tabString = ""; for (int i = 0; i < num; i++) { tabString += "\t"; } //Debug.Log (tabString + " Function : " + function.name + " (" + function.parameters.Count + ")"); for (int i = 0; i < function.parameters.Count; i++) { //Debug.Log (tabString + "\t" + "Param #" + i + " : "); object[] objects = function.parameters[i].Tokens.ToArray(); for (int j = 0; j < objects.Length; j++) { if (objects[j].ToString() == "ADLFunction") { RecursivePrintParameters((ADLFunction)objects[j], num + 2); } else { //Debug.Log(tabString + "\t\tToken #" + j + " : " + objects[j].ToString()); } } } }
private string ParseLevelParameter(string parsingState, Match token) { if (token.Groups["EndAction"].Length != 0 || token.Groups["EndIfBracket"].Length != 0) { parsingState = this.compilerStack.Pop(); //Remove the first parameter from action if its number of tokens is zero if (this.currentAction.parameters.Count == 1 && this.currentParameter.Tokens.Count == 0) { this.currentAction.parameters.Remove(this.currentParameter); } } else if (token.Groups["EndBracket"].Length != 0) { //The token is the ) of an ADLFunction if (this.functionStack.Count > 0) { //Remove the first parameter from function if its number of tokens is zero if (this.currentFunction.parameters.Count == 1 && this.currentParameter.Tokens.Count == 0) { this.currentFunction.parameters.Remove(this.currentParameter); } functionStack.Pop(); if (functionStack.Count > 0) { this.currentFunction = functionStack.Peek(); this.currentParameter = this.currentFunction.parameters[this.currentFunction.parameters.Count - 1]; } else { this.currentFunction = null; this.currentParameter = this.currentAction.parameters[this.currentAction.parameters.Count - 1]; } } } else if (token.Groups["StartBracket"].Length != 0) { } else if (token.Groups["Function"].Length != 0) { this.Log("Function : " + token.Groups["Function"].Value); //Create new Function and push it to Function Stack //To tell the compiler that the next parameter found in this state will be a parameter of the recently generated function ADLFunction function = this.createNewADLFunction(token.Groups["Function"].Value); ADLParameter parameter = new ADLParameter(); this.currentParameter.Tokens.Enqueue(new ADLToken(function)); this.currentFunction = function; this.currentParameter = parameter; this.currentFunction.parameters.Add(parameter); this.functionStack.Push(function); } else if (token.Groups["Comma"].Length == 0) { if (token.Groups["Double"].Length != 0) { this.currentParameter.Tokens.Enqueue(new ADLToken(float.Parse(token.Value))); } else if (token.Groups["Int"].Length != 0) { this.currentParameter.Tokens.Enqueue(new ADLToken(int.Parse(token.Value))); } else if (token.Groups["Pi"].Length != 0) { this.currentParameter.Tokens.Enqueue(new ADLToken(System.Convert.ToSingle(Math.PI))); } else if (token.Groups["Boolean_True"].Length != 0 || token.Groups["Boolean_False"].Length != 0) { this.currentParameter.Tokens.Enqueue(new ADLToken(bool.Parse(token.Value))); } else { this.currentParameter.Tokens.Enqueue(new ADLToken(token.Value)); } } else if (token.Groups["Comma"].Length > 0) { ADLParameter paramater = new ADLParameter(); if (functionStack.Count == 0) { this.currentAction.parameters.Add(paramater); } else { this.currentFunction.parameters.Add(paramater); } this.currentParameter = paramater; } return(parsingState); }