public bool AddFunction(ktString Name, ktBlock Block, ktList Arguments, ktValue Ret) { ktFunction Func = new ktFunction(Name, Arguments, Block, Ret); return AddFunction(Func); }
public bool AddFunction(ktString Name, ktBlock Block, ktList Arguments) { return AddFunction(Name, Block, Arguments, ktValue.Null); }
public ktBlock(ktBlock Block) : this() { //?? SetBlock( Block ); }
public static ktValue RunALine(ktList Line) { ktValue Ret = null; ktBlock Block = new ktBlock(); Ret = Block.RunLine(Line); return Ret; }
public ktToken(ktBlock _Block, int Line, int CharPos) : this(ktTokenType.Block, "", Line, CharPos, "ktTBlock") { m_Block = _Block; }
public bool SetParent(ktBlock Block) { m_Parent = Block; return true; }
public bool SetBlock(ktBlock Block) { if (m_Block != null) { m_Block = null; } if (Block == null) { return true; } /*if (Block->CopyingAllowed()) m_Block = new ktBlock( Block ); else*/ m_Block = Block; if (m_Block == null) return false; else return true; }
/// <summary> /// Main constructor for kacTalk, /// takes a parameter that decides if the default libraries/modules etc should be loaded /// </summary> public kacTalk(bool LoadDefs) : base("kactalk", 0) { m_Tokens = null; m_Lines = null; m_TokenStack = null; m_LineStack = null; m_CurLine = 0; m_MainBlock = null; if (LoadDefs) { LoadDefaults(); AddDefaultValues(); //ktDebug.Log( "===============\n"+ m_Modules.Get_R() ); } m_MainKT = this; }
/// <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; }
public ktFunction(ktString Name, ktList Arguments, ktBlock Block, ktValue Ret) : base("ktFunction", 0) { SetProperties(Name, Arguments, Block, Ret); }
/// <summary> /// Run the script... /// </summary> public ktValue Run(ktList Arguments) { ktValue Ret = ktValue.Null; if (m_MainBlock == null) { m_MainBlock = new ktBlock(m_Lines.First); } m_MainBlock.SetMain(this); //#if Debug ktDebug.Log("RUN:LINES:\n" + ktXML.FromList(m_MainBlock.Lines).AsXML()); //#endif Ret = m_MainBlock.Run(Arguments); return Ret; }
/// <summary> /// Add a function to the main block... /// </summary> public void AddFunction(ktFunction Func) { if (m_MainBlock == null) { m_MainBlock = new ktBlock(m_Lines.First); } m_MainBlock.AddFunction(Func); }
/// <summary> /// Parse the tokens and create a tree/* (mainly for operators)*/ /// </summary> protected ktList MakeATree() { if (m_Lines == null) { m_Lines = new ktList(); //m_Lines.Node = new ktNode( m_Name, new ktToken( ktTokenType.Program, m_Name, 0, 0 ) ); } ktList Tree = MakeATree(m_LineStack, true, false); #if ParseDebug ktDebug.Log( "MAT_TREE1:" + Tree.Get_R( " ", true ) ); #endif /* Tree = MakeATree( Tree, false, false ); ktDebug.Log( "MAT_TREE2:" + Tree.Get_R( "\t", true ) );*/ Tree = MakeATree(Tree, false, true); #if ParseDebug ktDebug.Log( "MAT_TREEEEEEEE:\n" + Tree.Get_R( " ", true ) ); #endif /**/ m_Lines = Tree;/*/ m_Lines.AddList( Tree );/**/ #if ParseDebug ktDebug.Log( "MAT_LINES:" + m_Lines.Get_R( " ", true ) ); #endif return m_Lines; } /// <summary> /// React on the "token" in Word /// </summary> protected bool ReactOnToken(ktString Word, int Line, ref int CharPos) { /* In the C++/"original" version of this method, it didn't do what * it's called (_React_ On Token), instead it just added the token to the list. * This method, hovever, does react properly to the given token * This also reduces the number of steps for scanning/parsering (creating the op. tree) * from three to two (we could probably just do it all in one step, but it would be messy * and a bit complex..) */ #if ParseDebug ktDebug.Log( "ReactOnToken(" + Word + ")" ); ktDebug.Log( "BS:" + ktXML.FromList(m_BlockStack).AsXML() ); #endif ktToken Token = new ktToken(Word, Line, CharPos); ktToken LastToken = null; ktToken LastAddedToken = null; ktToken.OnlyExportValue = true; if ((m_TokenStack != null) && (m_TokenStack.Last != null) && (m_TokenStack.Last.Node != null) && (m_TokenStack.Last.Node.Value != null)) { LastToken = (ktToken)m_TokenStack.Last.Node.Value; } if ((m_Tokens != null) && (m_Tokens.Last != null) && (m_Tokens.Last.Node != null) && (m_Tokens.Last.Node.Value != null)) { LastAddedToken = (ktToken)m_Tokens.Last.Node.Value; } if (m_CurToken != null) { // React differentely deppendig on "current token/'state'" switch (m_CurToken.Type) { // If it's an comment... case ktTokenType.MLComment: { // ... Check if the token is EOC? ... if (Token.Type == ktTokenType.EOC) { m_CurToken = (ktToken)(m_TokenStack.Pop().Node.Value); } // ... ignore... return true; } // If it's an comment... case ktTokenType.OLComment: { // ... Check if the token is EOC? ... if (Word == "\n") { m_CurToken = (ktToken)(m_TokenStack.Pop().Node.Value); } // ... ignore... return true; } // If it's a string... case ktTokenType.String: case ktTokenType.StringQuot: case ktTokenType.StartString: { // If we are at end of the string? if ((Token.Type == ktTokenType.StringQuot) && (m_CurToken.Value.Last() != '\\')) { ktList Temp = null; // Add string... m_Tokens.Add("ktTString", m_CurToken); // If we can, put back the previous token... if ((m_TokenStack != null) && ((Temp = m_TokenStack.Pop()) != null) && (Temp.Node != null)) { m_CurToken = (ktToken)Temp.Node.Value; } else { m_CurToken = null; } return true; } m_CurToken.Value += Word; return true; } } } #if ParseDebug2 /*Debug || */ // if (Line == 4) { ktDebug.Log( "Token:" + Token.Type.ToString() + " (" + Token.Value + ")" ); ktDebug.Log( "CurToken:" + m_CurToken.Type.ToString() ); ktDebug.Log( "BS:" + ktXML.FromList(m_BlockStack).AsXML() ); ktDebug.Log( "Ts:" + ((m_TokenStack == null) ? "null" : m_TokenStack.Get_R().ToString() )); ktDebug.Log( "LS:" + ((m_LineStack == null) ? "null" : m_LineStack.Get_R( "\t", true ).ToString() )); ktDebug.Log( "Ls:" + ((m_Lines == null) ? "null" : m_Lines.Get_R( "\t", true ).ToString() )); ktDebug.Log( "ts:" + ((m_Tokens == null) ? "null" : m_Tokens.Get_R().ToString() )); // } #endif // Check the token.. switch (Token.Type) { // Is it a whitespage?? case ktTokenType.WhiteSpace: { // ... ignore... return true; } // Is it an id (var/function)? case ktTokenType.Id: { AddToken(Token); return true; } // Is it a number? case ktTokenType.Number: { AddToken(Token); return true; } // Is it a boolean (true/false)? case ktTokenType.Boolean: { AddToken(Token); return true; } // Is it an separator (. or ::)? case ktTokenType.Separator: { if ((LastAddedToken != null) && (LastAddedToken.Value == ":") && (Token.Value == ":")) { LastAddedToken.Value = "::"; } else { AddToken(Token); } return true; } // Is it an operator????? case ktTokenType.Operator: case ktTokenType.AssignmentOperator: { // We should perhaps do some more here?? AddToken(Token); return true; } // Is it an const/hard????? case ktTokenType.Const: case ktTokenType.Hard: { AddToken(Token); return true; } // Create a new object? case ktTokenType.New: { AddToken(Token); return true; } // Null? case ktTokenType.Null: { AddToken(Token); return true; } // Is it a If-statement? case ktTokenType.If: { AddToken(Token); return true; } // Is it a quot (")? case ktTokenType.StringQuot: { // No Token stack?? if (m_TokenStack == null) { // Create it... m_TokenStack = new ktList(); } // Add the current token to the stack m_TokenStack.Add(m_CurToken); // And Replace it with this "string token" m_CurToken = new ktToken(ktTokenType.String, "", m_CurLine, m_CharPos); return true; } // Is it an start par. [(]? case ktTokenType.StartPar: { // No Token stack?? if (m_TokenStack == null) { // Create it... m_TokenStack = new ktList(); } // No Line Stack? if (m_LineStack == null) { // Create it... m_LineStack = new ktList(); } // Add the current token to the stack m_TokenStack.Add(m_CurToken); // And Replace it with this "list token" m_CurToken = new ktToken(ktTokenType.List, "ktList", m_CurLine, m_CharPos); // Put the current ""line"" onto the stack m_LineStack.AddList(m_Tokens); // Create a new list... m_Tokens = new ktList(); m_Tokens.Node = new ktNode("ktList", m_CurToken); // Put the current ""list"" onto the stack m_LineStack.AddList(m_Tokens); // Create a new list... m_Tokens = new ktList(); m_Tokens.Node = new ktNode("ktTStatement", new ktToken(ktTokenType.Statement, "", m_CurLine, m_CharPos)); return true; } // Is it an comma (,)? case ktTokenType.Comma: { if (m_CurToken.Type != ktTokenType.List) { throw new ktError("Unexpected " + ktToken.TokenToString(Token.Type) + " on line " + Line.ToString() + " by character " + CharPos.ToString() + ".", ktERR.UNEXP); } // get the last list ktList List = m_LineStack.Last; // Put the current ""statement"" onto the stack List.AddList(m_Tokens); // Create a new list... m_Tokens = new ktList(); m_Tokens.Node = new ktNode("ktStatement", new ktToken(ktTokenType.Statement, "", m_CurLine, m_CharPos)); return true; } // Is it an end par. [)]? case ktTokenType.EndPar: { if (m_CurToken.Type != ktTokenType.List) { throw new ktError("Unexpected " + ktToken.TokenToString(Token.Type) + " on line " + Line.ToString() + " by character " + CharPos.ToString() + ".", ktERR.UNEXP); } // Get the last "statement" ktList Temp = m_LineStack.Pop(); // Add Current "statement"/"post" to the list and then switch them Temp.AddList(m_Tokens); m_Tokens = Temp; // Get the "last statement" (where the list was "defined") Temp = m_LineStack.Pop(); Temp.AddList(m_Tokens); // "Switch" m_Tokens = Temp; // If we can, put back the previous token... if ((m_TokenStack != null) && ((Temp = m_TokenStack.Pop()) != null) && (Temp.Node != null)) { m_CurToken = (ktToken)Temp.Node.Value; } else { m_CurToken = null; } return true; } // Is it an End-of-line (semicolon). (;)? case ktTokenType.EOL: { // Should we use m_Lines instead??? if (m_LineStack == null) { m_LineStack = new ktList(); } // KacTalk special, runnable arguments! // If we are in a list and finds a semicolon, it means // that that "post" should be treated as "runnable" if (m_CurToken.Type == ktTokenType.List) { ktToken T = (ktToken)m_Tokens.Node.Value; // Mark as "runnable" T.Name = m_Tokens.Node.Name = "ktTRunStatement"; T.Type = ktTokenType.RunStatement; // NOTE: basically the same as for comma (,) (see above) // get the last list ktList List = m_LineStack.Last; // Put the current ""statement"" onto the stack List.AddList(m_Tokens); // Create a new list... m_Tokens = new ktList(); m_Tokens.Node = new ktNode("ktTStatement", new ktToken(ktTokenType.Statement, "", m_CurLine, m_CharPos)); return true; } ((ktToken)m_Tokens.Node.Value).Type = ktTokenType.Line; ((ktToken)m_Tokens.Node.Value).Name = m_Tokens.Node.Name = "ktTLine"; m_LineStack.AddList(m_Tokens); // Create a new list... m_Tokens = new ktList(); m_Tokens.Node = new ktNode("ktTStatement_", new ktToken(ktTokenType.Statement, "", m_CurLine, m_CharPos)); return true; } // Is it a block ({)!? case ktTokenType.Block: { // No Token stack?? if (m_TokenStack == null) { // Create it... m_TokenStack = new ktList(); } /*/ No Line Stack? if (m_LineStack == null) { // Create it... m_LineStack = new ktList(); } else { if (m_BlockStack == null) { m_BlockStack = new ktList(); } m_BlockStack.AddList( m_LineStack ); }*/ #if ParseDebug ktDebug.Log("BLOCK!!!"); #endif if (m_BlockStack == null) { #if ParseDebug ktDebug.Log( "NEW_BLOCK_STACK" ); #endif m_BlockStack = new ktList(); if (m_MainBlock == null) { m_MainBlock = new ktBlock(); m_MainBlock.SetMain(this); } m_BlockStack.Add(m_MainBlock); } // Put the current ""line"" onto the stack m_LineStack.AddList(m_Tokens); LastBlock.SetLines(m_LineStack); ktBlock Block = new ktBlock(new ktList()); Block.SetMain(this); m_BlockStack.Add("ktTBlock", Block); m_LineStack = new ktList(); // Add the current token to the stack m_TokenStack.Add(m_CurToken); // And Replace it with this "block token" m_CurToken = new ktToken(ktTokenType.Block, "ktTBlock", m_CurLine, m_CharPos); // Create a new list... m_Tokens = new ktList(); m_Tokens.Node = new ktNode("ktTStatement.", new ktToken(ktTokenType.Statement, "", m_CurLine, m_CharPos)); // Start a "new block" /*m_LineStack = new ktList(); // Put the current ""line"" onto the stack m_LineStack.AddList( m_Tokens ); // Create a new block... m_Tokens = new ktList(); m_Tokens.Node = new ktNode( "ktTBlock", m_CurToken ); // Put the current ""list"" onto the stack m_LineStack.AddList( m_Tokens ); // Create a new list... m_Tokens = new ktList(); m_Tokens.Node = new ktNode( "ktTLine", new ktToken( ktTokenType.Line, "", m_CurLine, m_CharPos ) );*/ return true; } // Is it an end of a block (})? case ktTokenType.EOB: case ktTokenType.End: { #if ParseDebug ktDebug.Log( "EOB;EOB;EOB;EOB;EOB;EOB;EOB;EOB;EOB;EOB;EOB;EOB;EOB;" ); ktDebug.Log("CurrToken:" + m_CurToken.ToString()); #endif if ((m_CurToken.Type != ktTokenType.Block) || (m_BlockStack == null) || (m_BlockStack.Last == null) || (m_BlockStack.Last.Node == null) || (m_BlockStack.Last.Node.Value == null)) { throw new ktError("Unexpected " + ktToken.TokenToString(Token.Type) + " on line " + Line.ToString() + " by character " + CharPos.ToString() + ".", ktERR.UNEXP); } #if ParseDebug2 ktDebug.Log( "ROT::B::BLS:" + ktXML.FromList(m_BlockStack).AsXML() ); #endif ktBlock Block = (ktBlock)(m_BlockStack.Pop().Node.Value); #if ParseDebug2 ktDebug.Log( "ROT::B::BLS2:" + ktXML.FromList(m_BlockStack).AsXML() ); ktDebug.Log( "ROT::B::Tokens:" + m_Tokens.Get_R() ); ktDebug.Log( "ROT::B::LineStack:" + m_LineStack.Get_R( "\t", true ) ); #endif MakeATree(); #if ParseDebug2 ktDebug.Log( "ROT::B::Lines:" + m_Lines.Get_R() ); #endif Block.Lines = MakeAOpTree(); #if ParseDebug2 ktDebug.Log( "ROT::Block:" + Block.ToString() ); ktDebug.Log( "ROT::Block:Lines:" + Block.Lines.Get_R() ); #endif m_LineStack.Clear(); m_LineStack = LastBlockLines; // m_Lines.Clear(); m_Lines = null; #if ParseDebug2 ktDebug.Log( "ROT::B::LineStack22:" + m_LineStack.Get_R( "\t", true ) ); #endif /*Block.Lines = MakeATree( MakeATree( m_LineStack, true, false ), false, true ); Block.Lines = MakeAOpTree( MakeAOpTree( MakeAOpTree( Block.Lines, 1 ), 2 ), 3 )*/ m_Tokens.Node.Name = "ktTBlock"; ((ktToken)m_Tokens.Node.Value).Name = "ktTBlock"; ((ktToken)m_Tokens.Node.Value).Type = ktTokenType.Block; // Add Current "statement"/"post" to the block and then switch them //Temp.AddList( m_Tokens ); //m_Tokens = Temp; 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)); // "Switch" //m_Tokens = Temp; #if ParseDebug2 ktDebug.Log( "ROT::B::LastBlockLines:" + LastBlockLines.Get_R( "\t", true ) ); #endif // If we can, put back the previous token... if ((m_TokenStack != null) && ((Temp = m_TokenStack.Pop()) != null) && (Temp.Node != null)) { m_CurToken = (ktToken)Temp.Node.Value; } else { m_CurToken = null; } return true; } // Comments... // One line comment?? // (bash only indicates comments if it's the first thing on the line...) case ktTokenType.Bash: { // If it's the first thing on the line!? if (m_CharPos <= 1) { // Indicate one line comment... // No Token stack?? if (m_TokenStack == null) { // Create it... m_TokenStack = new ktList(); } // Add the current token to the stack m_TokenStack.Add(m_CurToken); // And Replace it with this "commeent token" m_CurToken = new ktToken(ktTokenType.OLComment, "ktTOLComment", m_CurLine, m_CharPos); return true; // Not First at the line... } else { // What should we do?? // Exception, AddToken or somee magic for ids!??? // Unexpected... throw new ktError("Unexpeected " + ktToken.TokenToString(Token.Type) + " on line " + m_CurLine.ToString() + " by character " + m_CharPos.ToString(), ktERR.UNEXP); } } // One line comment case ktTokenType.OLComment: { // No Token stack?? if (m_TokenStack == null) { // Create it... m_TokenStack = new ktList(); } // Add the current token to the stack m_TokenStack.Add(m_CurToken); // And Replace it with this "commeent token" m_CurToken = new ktToken(ktTokenType.OLComment, "ktTOLComment", m_CurLine, m_CharPos); return true; } // Multi line comment case ktTokenType.MLComment: { // No Token stack?? if (m_TokenStack == null) { // Create it... m_TokenStack = new ktList(); } // Add the current token to the stack m_TokenStack.Add(m_CurToken); // And Replace it with this "Comment token" m_CurToken = new ktToken(ktTokenType.MLComment, "ktTMLComment", m_CurLine, m_CharPos); return true; } // If it's an End of comment case ktTokenType.EOC: { // Unexpected... throw new ktError("Unexpeected " + ktToken.TokenToString(Token.Type) + " on line " + m_CurLine.ToString() + " by character " + m_CharPos.ToString(), ktERR.UNEXP); } } // To see if we missed any tokens... ktToken.OnlyExportValue = false; ktDebug.Log("IGNmORED:" + Token.Export() + "\n"); return true; }
public bool AddFunction(ktString Name, ktBlock Block) { return AddFunction(Name, Block, null); }
public virtual bool SetProperties(ktString Name, ktList Arguments, ktBlock Block, ktValue Ret) { if (!SetName(Name)) return false; if (!SetArguments(Arguments)) return false; if (!SetBlock(Block)) return false; if (!SetReturn(Ret)) return false; return true; }
public ktRunStatement(ktList Statement, ktBlock Block) : base("ktRunStatement", 0) { m_Statement = Statement; m_Block = Block; }
/// <summary> /// Scans the text/code in 'Code' and returns it as a block (will not change the internaly stored block) /// </summary> public ktBlock ScanToBlock(ktString Code) { ktBlock Block = null; ktList Lines = m_Lines; m_Lines = null; try { Scan(Code); Block = new ktBlock(m_Lines.First); Block.SetMain(this); } catch (Exception Err) { m_Lines = Lines; throw Err; } m_Lines = Lines; return Block; }