/// <summary> /// Add values to the integer (changes the value of the object) /// </summary> /// <param name="Arguments">A list of values to add to the integer</param> /// <returns>The sum of all the arguments and the internal integer</returns> public ktValue Add(ktList Arguments) { ktValue Value = ktValue.Null; // Check so we actually got some arguments if (Arguments.IsEmpty()) { throw new ktError("Can't add nothing (null) to an integer!", ktERR.NOTDEF); } // Go through the list of arguments foreach (ktList L in Arguments) { // If there's nothing in this argument if ((L.Node == null) || (L.Node.Value == null)) { continue; } // Try to convert the argument to an int and add it to the internal integer m_value += GetAsInt((ktValue)L.Node.Value); } // Wrap this object in a ktValue ... Value = new ktValue("return", "ktInt", this, m_HardType, true); // ... and return it return Value; }
/// <summary> /// Assign a value to the float /// </summary> /// <param name="Arguments">The value to assign</param> /// <returns>ktValue with the current object</returns> public ktValue Assign(ktList Arguments) { ktValue Value = ktValue.Null; // Can't assign nothing.. if ((Arguments.IsEmpty()) || ((ktValue)Arguments.First.Node.Value).IsNull()) { throw new ktError("Can't assign nothing (null) to a float!", ktERR.NOTDEF); } // Store the first value given as argument (ignore the rest) m_value = GetAsFloat((ktValue)Arguments.First.Node.Value); // Return this object wrapped in a ktValue return new ktValue(this.Name, "ktFloat", this, m_HardType, false); }
/// <summary> /// Multiply values with the integer (changes the value of the object) /// </summary> /// <param name="Arguments">A list of values to multiply with the integer</param> /// <returns>The product of all the arguments and the internal integer</returns> public ktValue Multiply(ktList Arguments) { ktValue Value = ktValue.Null; // Check so we actually got some arguments if (Arguments.IsEmpty()) { throw new ktError("Can't multiply nothing (null) with an integer!", ktERR.NOTDEF); } // Go through the list of arguments foreach (ktList L in Arguments) { // If there's nothing in this argument if ((L.Node == null) || (L.Node.Value == null)) { continue; } // Multiply with the current argument m_value *= GetAsInt((ktValue)L.Node.Value); } // Wrap this object in a ktValue ... Value = new ktValue("return", "ktInt", this, m_HardType, true); // ... and return it return Value; }
/// <summary> /// Convert from one base to decimal /// </summary> /// <param name="Arguments">A list of arguments (Arg1: The value to convert, Arg2: The base to convert from)</param> /// <returns></returns> public ktValue FromBase(ktList Arguments) { ktValue Arg = ktValue.Null; string val = ""; int frombase = 2; // Did we get any arguments? if (Arguments.IsEmpty()) { throw new ktError("Not enough arguments for ktInt::FromBase()!", ktERR.NOTDEF); } // Did we get enough arguments? else if (Arguments.Count < 2) { throw new ktError("Not enough arguments for ktInt::FromBase(), expected 2!", ktERR.NOTDEF); } // Get the first value and convert it to a string Arg = (ktValue)Arguments.First.Node.Value; val = Arg.ToString(); // Get the second value and convert it to a string Arg = (ktValue)Arguments.First.Next.Node.Value; frombase = Arg.ToInt(); // Convert return _FromBase(val, frombase); }
/// <summary> /// Convert from one base to decimal /// </summary> /// <param name="Arguments">A list of arguments to convert to decimal (only uses the first one)</param> /// <param name="frombase">The base to convert from</param> /// <returns></returns> public ktValue FromBase(ktList Arguments, int frombase = 2) { ktValue Arg = ktValue.Null; string val = ""; // Did we get any arguments if (Arguments.IsEmpty()) { throw new ktError("Not enough arguments for ktInt::FromBase(??," + frombase + ")!", ktERR.NOTDEF); } // Get the first argument and convert it to a string Arg = (ktValue)Arguments.First.Node.Value; val = Arg.ToString(); // Convert return _FromBase(val, frombase); }
protected bool MapArguments(ktList Arguments) { if (((Arguments == null) || Arguments.IsEmpty()) && ((m_Arguments == null) || m_Arguments.IsEmpty())) { return true; } else if ((m_Arguments == null) || m_Arguments.IsEmpty()) { return true; } ktString Name = new ktString(); ktString RestName = null; ktList Rest = null, CurrArgL = null; ktValue Arg = null, CurrArg = null, Arg2Add = null; //bool GoOn = true; CurrArgL = Arguments.First; m_Arguments.Reset(); foreach (ktList AL in m_Arguments) { Arg2Add = null; /*if ((CurrArgL == null) || (CurrArgL.Node == null) || (CurrArgL.Node.Value == null)) { Arg2Add = ktValue.Null; }*/ if ((AL == null) || (AL.Node == null) || (AL.Node.Value == null)) { ktDebug.Log("NA"); // ???????????????????????????????????????????????????????????? Arg2Add = ktValue.Null; } else { Arg = (ktValue)AL.Node.Value; Name = Arg.Name; if ((CurrArgL == null) || (CurrArgL.Node == null) || (CurrArgL.Node.Value == null)) { ktDebug.Log("NULL"); if (Arg.Value != null) { Arg2Add = new ktValue(Name, Arg.Type, Arg.Value, Arg.HardType, Arg.Constant); } else { Arg2Add = new ktValue(Name, "null", null, true, true); } AddVariable(Arg2Add); continue; } CurrArg = (ktValue)CurrArgL.Node.Value; if (Name[0] == '#') { Name.RemoveFirst(); Arg2Add = new ktValue(Name, "ktList", Arguments, true, false); } else if (Name[0] == '$') { Name.RemoveFirst(); RestName = Name; Rest = new ktList(); while (CurrArgL != null) { Arg2Add = new ktValue(CurrArg); if (CurrArgL != null) { CurrArgL = CurrArgL.Next; if ((CurrArgL == null) || (CurrArgL.Node == null) || (CurrArgL.Node.Value == null)) { continue; } else { CurrArg = (ktValue)CurrArgL.Node.Value; } } } } else { if ((Arg.HardType) && (!Arg.CheckType(CurrArg))) { throw new ktError("ktFunction::MapArguments() : Didn't get a value with the right type for the argument '" + Name + "' in the function " + m_Name + "!", ktERR.WRONGTYPE); } Arg2Add = new ktValue(CurrArg); } } if (Rest == null) { Arg2Add.Name = Name; AddVariable(Arg2Add); // AddVariable( new ktValue( Name, Arg2Add.Type, Arg2Add, Arg.HardType, Arg.Constant ) ); }/* else { Rest.Add( Arg2Add ); }*/ if (CurrArgL != null) { CurrArgL = CurrArgL.Next; } } if (Rest != null) { AddVariable(new ktValue(RestName, "ktList", Rest, true, false)); } return true; }
/// <summary> /// Multiply values with the integer (doesn't change the value of the object) /// </summary> /// <param name="Arguments">A list of values to multiply with the integer</param> /// <returns>The product of all the arguments and the internal integer</returns> public ktValue _Multiply(ktList Arguments) { ktValue Value = ktValue.Null; int res = m_value; // Check so we actually got some arguments if (Arguments.IsEmpty()) { throw new ktError("Can't multiply nothing (null) to an integer!", ktERR.NOTDEF); } // Go through the list of arguments foreach (ktList L in Arguments) { // If there's nothing in this argument if ((L.Node == null) || (L.Node.Value == null)) { continue; } // Multiply with the current argument res *= GetAsInt((ktValue)L.Node.Value); } // Create a new ktInt and wrap it in a ktValue Value = new ktValue("return", "ktInt", new ktInt(res), true, true); return Value; }
/// <summary> /// Calculate the value of the integer XOR with the power of the arguments (doesn't change the value of the object) /// </summary> /// <param name="Arguments">A list of values to XOR the integer with</param> public ktValue _ExclusiveOr(ktList Arguments) { ktValue Value = ktValue.Null; int res = m_value; int a = 1; // Check so we actually got some arguments if (Arguments.IsEmpty()) { throw new ktError("Can't divide an integer with nothing (null)!", ktERR.NOTDEF); } // Go through the list of arguments foreach (ktList L in Arguments) { if ((L.Node == null) || (L.Node.Value == null)) { continue; } // Get the argument as an integer a = GetAsInt((ktValue)L.Node.Value); // Perform an XOR-operation res ^= a; } // Create a new ktInt and wrap it in a ktValue Value = new ktValue("return", "ktInt", new ktInt(res), false, true); return Value; }
/// <summary> /// Add values to the integer (doesn't change the value of the object) /// </summary> /// <param name="Arguments">A list of values to add to the integer</param> /// <returns>The sum of all the arguments and the internal integer</returns> public ktValue _Add(ktList Arguments) { ktValue Value = ktValue.Null; int res = 0; // Check so we actually got some arguments if (Arguments.IsEmpty()) { throw new ktError("Can't add nothing (null) to an integer!", ktERR.NOTDEF); } // Go through the list of arguments foreach (ktList L in Arguments) { // If there's nothing in this argument if ((L.Node == null) || (L.Node.Value == null)) { continue; } // Try to convert the argument to an int and add it to the sum res += GetAsInt((ktValue)L.Node.Value); } // Add the current sum to the internal integer, create a new ktInt and wrap it in a ktValue Value = new ktValue("return", "ktInt", new ktInt(m_value + res), true, true); // Return the result return Value; }
/// <summary> /// Calculate the value of the float raised to the power of the arguments (changes the value of the object) /// </summary> /// <param name="Arguments">A list of values to raise the float with</param> /// <returns>The value of the internal float to the power of the arguments</returns> public ktValue Power(ktList Arguments) { ktValue Value = ktValue.Null; float a = 1; // Check so we actually got some arguments if (Arguments.IsEmpty()) { throw new ktError("Can't raise a float with nothing (null)!", ktERR.NOTDEF); } // Go through the list of arguments foreach (ktList L in Arguments) { // If there's nothing in this argument if ((L.Node == null) || (L.Node.Value == null)) { continue; } // Get the argument as an float a = GetAsFloat((ktValue)L.Node.Value); // Raise it to the power of the argument m_value = (int)Math.Pow((double)m_value, (double)a); } // Wrap this object in a ktValue ... Value = new ktValue("return", "ktFloat", this, m_HardType, true); // ... and return it return Value; }
/// <summary> /// Calculate the modulus of the float and the arguments (changes the value of the object) /// </summary> /// <param name="Arguments">A list of values to multiply with the float</param> /// <returns>The product of all the arguments and the internal float</returns> public ktValue Modulus(ktList Arguments) { ktValue Value = ktValue.Null; ktValue Arg = ktValue.Null; float a = 1; // Check so we actually got some arguments if (Arguments.IsEmpty()) { throw new ktError("Can't divide a float with nothing (null)!", ktERR.NOTDEF); } // Go through the list of arguments foreach (ktList L in Arguments) { // If there's nothing in this argument if ((L.Node == null) || (L.Node.Value == null)) { continue; } // Get the argument as an float a = GetAsFloat((ktValue)L.Node.Value); // Do modulus with the current argument m_value %= a; } // Wrap this object in a ktValue ... Value = new ktValue("return", "ktFloat", this, m_HardType, true); // ... and return it return Value; }
/// <summary> /// Divide values with the float (changes the value of the object) /// </summary> /// <param name="Arguments">A list of values to divide the float with</param> /// <returns>The quotient of all the arguments and the internal float</returns> public ktValue Divide(ktList Arguments) { ktValue Value = ktValue.Null; ktValue Arg = ktValue.Null; float a = 1; // Check so we actually got some arguments if (Arguments.IsEmpty()) { throw new ktError("Can't divide an float with nothing (null)!", ktERR.NOTDEF); } // Go through the list of arguments foreach (ktList L in Arguments) { // If there's nothing in this argument if ((L.Node == null) || (L.Node.Value == null)) { continue; } // Get the argument as an float a = GetAsFloat((ktValue)L.Node.Value); // Check so it isn't zero if (a == 0) { // Oops, can't do that!!! throw new ktError("You can't divide by zero!", ktERR.DIV_BY_ZERO); } // Divide with the current argument m_value /= a; } // Wrap this object in a ktValue ... Value = new ktValue("return", "ktFloat", this, m_HardType, true); // ... and return it return Value; }
/// <summary> /// Round the float /// </summary> /// <param name="Arguments"></param> /// <returns></returns> private ktValue Round(ktList Arguments) { ktValue Value = ktValue.Null; float res = m_value; int precision = 0; // Check if we got some arguments if (!Arguments.IsEmpty()) { ktValue arg = (ktValue)Arguments.FirstNode.Value; if (!arg.IsNull()) { //ktClass obj = (ktClass)arg.Value; if (arg.Type == "ktInt") { precision = arg.ToInt(); } else { throw new ktError("ktFloat::Round() expected an integer as argument but got a '" + arg.Type + "'!", ktERR.WRONGTYPE); } } } res = (float)Math.Round(res, precision); // Create a new ktFloat and wrap it in a ktValue Value = new ktValue("return", "ktFloat", new ktFloat(res), true, true); return Value; }
protected ktValue HandleRunStatement(ktList Statement) { #if Debug ktDebug.Log( "HrSHRSHRSHRSHRSHRSHRSHRSHRSHRSHRSHRSHRSHRSHRS" ); #endif ktValue Value = ktValue.Null; if ((Statement == null) || (Statement.IsEmpty())) { return Value; } #if Debug ktDebug.Log( Statement.Get_R() ); #endif ktRunStatement RunStatement = new ktRunStatement(Statement, this); Value = RunStatement.AsValue(); #if Debug ktDebug.Log( "EOHRS" ); #endif return Value; }
protected ktValue HandleStatement(ktList Statement) { #if Debug ktDebug.Log( "HSHSHSHSHSHSHSHSHSHSHSHSHSHSHS" ); #endif ktValue Value = ktValue.Null; ktDebug.Log(Statement.Get_R()); if ((Statement == null) || (Statement.IsEmpty()) || (Statement.First.Node == null) || (Statement.First.Node.Value == null)) { ktDebug.Log(Statement.Get_R()); return Value; } #if Debug ktDebug.Log( Statement.Get_R() ); #endif ktToken Token = (ktToken)Statement.First.Node.Value; Value = TokenToValue(Token, Statement.First); #if Debug ktDebug.Log( "EOHS" ); #endif return Value; }
private ktValue Add(ktList Arguments) { ktValue Value = ktValue.Null; ktValue Arg = ktValue.Null; float res = 0.0f; if (Arguments.IsEmpty()) { throw new ktError("Can't add nothing (null) to a float!", ktERR.NOTDEF); } foreach (ktList L in Arguments) { if ((L.Node == null) || (L.Node.Value == null)) { continue; } Arg = (ktValue)L.Node.Value; res += Arg.ToFloat(); } Value = new ktValue("return", "ktDouble", new ktDouble(m_value + res), false, true); return Value; }
/// <summary> /// Convert from decimal to another base /// </summary> /// <param name="tobase">The base to convert from (We only use the first argument in the list)</param> /// <returns></returns> public ktValue ToBase(ktList Arguments) { ktValue Arg = ktValue.Null; int tobase = 0; // If we didn't get any arguments ... if (Arguments.IsEmpty()) { // ... we use base 2 as a default value tobase = 2; } // We got arguments else { // Get the first value Arg = (ktValue)Arguments.First.Node.Value; // Convert the argument to an int tobase = Arg.ToInt(); } // Convert return _ToBase( tobase ); }
/// <summary> /// Subtract values from the float (changes the value of the object) /// </summary> /// <param name="Arguments">A list of values to subtract from the float</param> /// <returns>The difference of all the arguments and the internal float</returns> public ktValue Subtract(ktList Arguments) { ktValue Value = ktValue.Null; // Check so we actually got some arguments if (Arguments.IsEmpty()) { throw new ktError("Can't subtract nothing (null) to an float!", ktERR.NOTDEF); } // Go through the list of arguments foreach (ktList L in Arguments) { // If there's nothing in this argument if ((L.Node == null) || (L.Node.Value == null)) { continue; } // Subtract the current argument m_value -= GetAsFloat((ktValue)L.Node.Value); } // Wrap this object in a ktValue ... Value = new ktValue("return", "ktFloat", this, m_HardType, true); // ... and return it return Value; }
/// <summary> /// Divide values with the integer (doesn't change the value of the object) /// </summary> /// <param name="Arguments">A list of values to divide the integer with</param> /// <returns>The quotient of all the arguments and the internal integer</returns> public ktValue _Divide(ktList Arguments) { ktValue Value = ktValue.Null; int res = m_value; int a = 1; // Check so we actually got some arguments if (Arguments.IsEmpty()) { throw new ktError("Can't divide an integer with nothing (null)!", ktERR.NOTDEF); } // Go through the list of arguments foreach (ktList L in Arguments) { // If there's nothing in this argument if ((L.Node == null) || (L.Node.Value == null)) { continue; } // Get the argument as an integer a = GetAsInt((ktValue)L.Node.Value); // Check so it isn't zero if (a == 0) { // Oops, can't do that!!! throw new ktError("You can't divide by zero!", ktERR.DIV_BY_ZERO); } // Divide with the current argument res /= a; } // Create a new ktInt and wrap it in a ktValue Value = new ktValue("return", "ktInt", new ktInt(res), true, true); return Value; }
/// <summary> /// Subtract values from the float (doesn't change the value of the object) /// </summary> /// <param name="Arguments">A list of values to subtract from the float</param> /// <returns>The difference of all the arguments and the internal float</returns> public ktValue _Subtract(ktList Arguments) { ktValue Value = ktValue.Null; float res = m_value; // Check so we actually got some arguments if (Arguments.IsEmpty()) { throw new ktError("Can't subtract nothing (null) to an float!", ktERR.NOTDEF); } // Go through the list of arguments foreach (ktList L in Arguments) { // If there's nothing in this argument if ((L.Node == null) || (L.Node.Value == null)) { continue; } // Subtract the current argument res -= GetAsFloat((ktValue)L.Node.Value); } // Create a new ktFloat and wrap it in a ktValue Value = new ktValue("return", "ktFloat", new ktFloat(res), true, true); return Value; }
/// <summary> /// Calculate the modulus of the integer and the arguments (doesn't change the value of the object) /// </summary> /// <param name="Arguments">A list of values to multiply with the integer</param> /// <returns>The product of all the arguments and the internal integer</returns> public ktValue _Modulus(ktList Arguments) { ktValue Value = ktValue.Null; ktValue Arg = ktValue.Null; int res = m_value; int a = 1; // Check so we actually got some arguments if (Arguments.IsEmpty()) { throw new ktError("Can't divide an integer with nothing (null)!", ktERR.NOTDEF); } // Go through the list of arguments foreach (ktList L in Arguments) { // If there's nothing in this argument if ((L.Node == null) || (L.Node.Value == null)) { continue; } // Get the argument as an integer a = GetAsInt((ktValue)L.Node.Value); // Do modulus with the current argument res %= a; } // Create a new ktInt and wrap it in a ktValue Value = new ktValue("return", "ktInt", new ktInt(res), true, true); return Value; }
/// <summary> /// Calculate the value of the integer XOR with the power of the arguments (changes the value of the object) /// </summary> /// <param name="Arguments">A list of values to XOR the integer with</param> /// <returns>The result</returns> public ktValue ExclusiveOr(ktList Arguments) { ktValue Value = ktValue.Null; int a = 1; // Check so we actually got some arguments if (Arguments.IsEmpty()) { throw new ktError("Can't XOR an integer with nothing (null)!", ktERR.NOTDEF); } // Go through the list of arguments foreach (ktList L in Arguments) { if ((L.Node == null) || (L.Node.Value == null)) { continue; } // Get the argument as an integer a = GetAsInt((ktValue)L.Node.Value); // Perform an XOR-operation m_value ^= a; } // Wrap this object in a ktValue ... Value = new ktValue("return", "ktInt", this, false, true); // ... and return it return Value; }
/// <summary> /// Calculate the value of the integer raised to the power of the arguments (doesn't change the value of the object) /// </summary> /// <param name="Arguments">A list of values to raise the integer with</param> /// <returns>The value of the internal integer to the power of the arguments</returns> public ktValue _Power(ktList Arguments) { ktValue Value = ktValue.Null; int res = m_value; int a = 1; // Check so we actually got some arguments if (Arguments.IsEmpty()) { throw new ktError("Can't raise an integer with nothing (null)!", ktERR.NOTDEF); } // Go through the list of arguments foreach (ktList L in Arguments) { // If there's nothing in this argument if ((L.Node == null) || (L.Node.Value == null)) { continue; } // Get the argument as an integer a = GetAsInt((ktValue)L.Node.Value); // Raise it to the power of the argument res = (int)Math.Pow((double)res,(double)a); } // Create a new ktInt and wrap it in a ktValue Value = new ktValue("return", "ktInt", new ktInt(res), true, true); return Value; }
/// <summary> /// Scan/Parse the script into tokens /// </summary> public bool Scan(ktString Script, ktString Name) { bool Ret = true; Script.Replace("\r\n", "\n",true); // Initiate the lineno. m_CurLine = 1; m_CharPos = 1; // .. and name m_Name = Name; if (m_Tokens != null) { m_Tokens.Clear(); m_Tokens = null; } // Init... ktString Line = new ktString(); int Pos = 0; Script.Trim(); ktRegEx RE = new ktRegEx(ktToken.Separators); // ... the block-stack if (m_BlockStack != null) { m_BlockStack.Clear(); m_BlockStack = null; } m_BlockStack = new ktList(); // ... the token-list if (m_Tokens != null) { m_Tokens.Clear(); m_Tokens = null; } m_Tokens = new ktList(); m_Tokens.Node = new ktNode("ktTStatement", new ktToken(ktTokenType.Statement, "", 0, 0)); // ... the token-stack if (m_TokenStack != null) { m_TokenStack.Clear(); m_TokenStack = null; } m_TokenStack = new ktList(); // ... the lines (??) if (m_Lines != null) { m_Lines.Clear(); m_Lines = null; } m_Lines = new ktList(); m_Lines.Node = new ktNode(Name, m_CurToken = new ktToken(ktTokenType.Program, Name, 0, 0)); // ... the line-stack if (m_LineStack != null) { m_LineStack.Clear(); m_LineStack = null; } m_LineStack = new ktList(); if (m_MainBlock == null) { m_MainBlock = new ktBlock(new ktList()); } else { if (m_MainBlock.Lines != null) { m_MainBlock.Lines.Clear(); } m_MainBlock.ClearKTSymbols(); } m_MainBlock.SetMain(this); m_BlockStack.Add("ktTBlock", m_MainBlock); /* In the "original scanner" (C++), we took one line (terminated by \n) * at a time and worked on, now we just go through the line. * And We hope that it will be much "leaner"! */ // Go on until the there's nothing left... while (!Script.IsEmpty()) { // Get the position for the next separator Pos = RE.Find(Script); // If there was none... if (Pos < 0) { // Take it to the end... Pos = Script.Len(); } else if (Pos == 0) { Pos++; } // Get the next "token" Line = Script.SubStr(0, Pos); // If it's the start of a comment if ((Line == "/") && (Script.StartsWith("//") || Script.StartsWith("/*"))) { Line = Script.SubStr(0, 2); Pos++; } else if ((Line == "*") && (Script.StartsWith("*/"))) { Line = "*/"; Pos++; } ReactOnToken(Line, m_CurLine, ref m_CharPos); if (Line == "\n") { m_CurLine++; m_CharPos = 1; } else { m_CharPos += Line.Len(); } // Remove the "token", we just worked on... Script.Remove(0, Pos); } #if ParseDebug || DebugXML ktDebug.Log("XML111111:"); ktDebug.Log(ktXML.FromList(m_TokenStack).AsXML()); ktDebug.Log("=================="); ktDebug.Log(ktXML.FromList(m_Tokens).AsXML()); #endif if (!m_Tokens.IsEmpty()) { if (m_AllowMissingEOL) { ((ktToken)m_Tokens.Node.Value).Type = ktTokenType.Line; ((ktToken)m_Tokens.Node.Value).Name = m_Tokens.Node.Name = "ktTLine"; m_LineStack.AddList(m_Tokens); m_Tokens = null; } else { throw new ktError("Expected a ktTEOL at line " + m_CurLine.ToString() + " but didn't find one!", ktERR.MISSING); } } if (m_BlockStack.Count > 1) { throw new ktError("Expecting ktTEOB (}) at " + m_CharPos.ToString() + ", line " + m_CurLine.ToString() + ".", ktERR.MISSING); } //ktToken.OnlyExportValue = false; //ktDebug.Log( m_LineStack.Get_R( ) ); //ktToken.OnlyExportValue = false; #if ParseDebug || DebugXML ktDebug.Log( "XML:" ); ktDebug.Log( ktXML.FromList(m_LineStack).AsXML() ); ktDebug.Log( "==================" ); ktDebug.Log( ktXML.FromList(m_Lines).AsXML() ); #endif /* ktDebug.Log( "?+++++\n" + m_Tokens.Get_R( "\t", true ) ); ktDebug.Log( "?+++++\n" + m_CurToken.Export if (m_CurToken != null) { if (m_CurToken.Type == ktTokenType.List) { throw new ktError( "Expected a ktTEndPar at line " + m_CurLine.ToString() + " but didn't find one!", ktERR.MISSING ); } else if (m_CurToken.Type == ktTokenType.String) { throw new ktError( "Expected a ktTStringQuot at line " + m_CurLine.ToString() + " but didn't find one!", ktERR.MISSING ); } else if (m_CurToken.Type == ktTokenType.Block) { throw new ktError( "Expected a ktTEndOfBlock at line " + m_CurLine.ToString() + " but didn't find one!", ktERR.MISSING ); } } else if ((m_Tokens != null) && (!m_Tokens.IsEmpty())) { throw new ktError( "Expected a ktTEOL at line " + m_CurLine.ToString() + " but didn't find one!", ktERR.MISSING ); } */ // MakeATree( ); // MakeAOpTree( ); if ((m_BlockStack == null) || (m_BlockStack.IsEmpty())) { return Ret; } ktBlock Block = (ktBlock)(m_BlockStack.Pop().Node.Value); #if ParseDebug ktDebug.Log( "BLOCK1:" + ktXML.FromList(Block.Lines).AsXML() );r #endif MakeATree(); #if ParseDebug ktDebug.Log("BLOCK2:" + ktXML.FromList(m_Lines).AsXML()); #endif Block.Lines = MakeAOpTree(); m_LineStack.Clear(); m_LineStack = null; // Add Current "statement"/"post" to the block and theń switch them //Temp.AddList( m_Tokens ); //m_Tokens = Temp; #if ParseDebug ktDebug.Log( "BLOCK:" + ((Block == m_MainBlock) ? "MAIN":"NOT_MAIN") ); #endif /*ktList Temp = null; if (LastBlockLines == null) { throw new ktError( "No Last Block Lines!", ktERR.MISSING ); } LastBlockLines.Add( "ktTBlock", new ktToken( Block, m_CurToken.LineNo, m_CurToken.CharPos ) );*/ #if ParseDebug || DebugXML ktDebug.Log( "XML_After Tree:" + ktXML.FromList(Block.Lines).AsXML() ); ktDebug.Log( "XML_After Tree:" + Block.Lines.Get_R( "\t", true ) ); #endif //ktDebug.Log( m_Lines.Export() ); return Ret; }