当前位置: 首页>>代码示例>>C#>>正文


C# ktList.AddList方法代码示例

本文整理汇总了C#中KacTalk.ktList.AddList方法的典型用法代码示例。如果您正苦于以下问题:C# ktList.AddList方法的具体用法?C# ktList.AddList怎么用?C# ktList.AddList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在KacTalk.ktList的用法示例。


在下文中一共展示了ktList.AddList方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: HandleOperator


//.........这里部分代码省略.........
                                }
                                break;
                            }
                    }

                    foreach (string Meth in MethNames)
                    {
                        try
                        {
                            Value = Class.RunMethod(Meth, Args);
#if Debug
ktDebug.Log( "AFTREOP:" + Value.Export() + ";" );
#endif
                            return Value;
                        }
                        catch (ktError Err)
                        {
//                            ktDebug.Log("ASSMETHERR:" + Err.ToString());
                            if ((Err.ErrorNumber != ktERR._404) &&
                                (!Err.Message.StartsWith("Couldn't find the method ")))
                            {
                                throw Err;
                            }
                        }
                    }
                    throw new ktError("-", ktERR._404);
                }
                catch (ktError Err)
                {
#if Debug
ktDebug.Log( "##############" + Err.ToString() + "\n" + Err.StackTrace ); //ktDebug.Log
#endif
                    if (Err.ErrorNumber != ktERR._404)
                    {
                        throw Err;
                    }
                    else if (Class == null)
                    {
                        throw new ktError("The variable '" + Value.Value + "' is not set", ktERR.NOTSET);
                    }
                    else if (Class.Name == "ktList")
                    {
                        ktList L = new ktList();
                        L.Node = OpTree.Node;
                        ktDebug.Log("HANDLELIST:::" + ((ktList)(Class.GetProperty("_FirstObject").Value)).Get_R() + " ==");
                        L.AddList((ktList)(Class.GetProperty("_FirstObject").Value));
                        L.AddList(OpTree.Last);

                        return HandleOperator(L);
                    }
                    else
                    {
                        throw new ktError("The operator '" + Op.Value + "' isn't handled by the class " +
                                            Class.Name, ktERR.NOTIMP);
                    }
                }

                //	ktDebug.Log( "111:" + Value.Value.Export( ) + "!!!!222:" + SecondValue.Value.Export() + "#####" );
                //break;
            }
            else if (Op.Type == ktTokenType.AssignmentOperator)
            {
                Value = TokenToValue(Last, OpTree.Last);
                if ((First.Type == ktTokenType.Id) || (First.Type == ktTokenType.CompStatement))
                {
                    Value.Constant = false;
#if Debug
ktDebug.Log( "HO:AO: " + First.Value + ";" );
#endif
                    Value = HandleAssignment(Op, OpTree.First, First, Value);
                    //						SetVariable( First.Value, Value, true, true );
                }
                else if (First.Type == ktTokenType.VarStatement)
                {
                    if (Op.Value != "=")
                    {
                        throw new ktError("Expected a simple assignment operator (=) on line " + Op.LineNo.ToString() +
                                          " by character " + Op.CharPos.ToString() + ", but found " +
                                          Op.Value + "!", ktERR.UNEXP);
                    }
                    Value = HandleCompAssignment(OpTree.First, Value);
                }
                else
                {
                    throw new ktError("Can't assign a value to an " + First.Name + " (" + First.Value + ") on line " + Op.LineNo.ToString() +
                                        ", character " + Op.CharPos.ToString() + "!", ktERR.UNKNOWN);
                }

                //break;
            }
            else
            {
                throw new ktError("Unrecognized operator (" + Op.Value + ") on line " + Op.LineNo.ToString() +
                                    ", character " + Op.CharPos.ToString() + "!", ktERR.UNKNOWN);
            }
#if Debug
	ktDebug.Log( "END OF HO!!!" );
#endif
            return Value;
        }
开发者ID:ChrisHinde,项目名称:KacTalk_NET,代码行数:101,代码来源:ktBlock.cs

示例2: GetArguments

        public ktList GetArguments(ktList Arguments)
        {
            ktList Args = null;
            ktToken Token = null;

#if Debug
	ktDebug.Log( "GAGAGAGAGAGA:" + Arguments.Get_R( "\t", true ) );
#endif
            if (Arguments == null)
            {
                return null;
            }
            else if ((Arguments.Node != null) && (Arguments.Node.Value != null) &&
                      ((Token = (ktToken)(Arguments.Node.Value)).Type == ktTokenType.CompStatement))
            {
                Args = new ktList();

                Args.Add(HandleCompound(Arguments).CopyValue());

                return Args;
            }
            else if (((Arguments.First != null) && (Arguments.First.Node != null) &&
                       (Arguments.First.Node.Value != null) &&
                       ((Token = (ktToken)(Arguments.First.Node.Value)).Type == ktTokenType.CompStatement)
                      ) || ((Arguments.Node != null) && (Arguments.Node.Value != null) &&
                       ((Token = (ktToken)(Arguments.Node.Value)).Type == ktTokenType.CompStatement)
                      )
                    )
            {
#if Debug
	ktDebug.Log( "GACSGACSGACSGACSGACSGACS:" + Arguments.Get_R() );
#endif
                ktList Stat = new ktList();
                Stat.Node = new ktNode("ktStatement", new ktToken(ktTokenType.Statement, "ktStatement",
                                            Token.LineNo, Token.CharPos));

                Args = new ktList();
                Args.Node = new ktNode("ktList", new ktToken(ktTokenType.List, "ktList", Token.LineNo,
                                            Token.CharPos));
                Args.AddList(Stat);
                Stat.AddList(Arguments);

                return GetArguments(Args);
            }
#if Debug
	ktDebug.Log( "gQAGAGAGAGAGAGAGGAgA::::" + Arguments.Get_R( "\t", true )  );
#endif

            if (Arguments.GetCount() == 0)
            {
                if (Arguments.Node == null)
                {
                    return null;
                }

                Token = (ktToken)Arguments.Node.Value;
                //ktDebug.Log( "GAGA111:" + Token.Name );
                Args = new ktList();

                if (Token.Type == ktTokenType.RunStatement)
                {
                    Args.Add(TokenToValue(Token, null));
                }
                else
                {
                    Args.Add(TokenToValue(Token, null).CopyValue());
                }

            }
            else
            {
                ktValue Value = null;

                Arguments.Reset();
                foreach (ktList L in Arguments)
                {
                    if ((L.Node == null) || (L.Node.Value == null))
                    {
                        continue;
                    }

                    if (Args == null)
                    {
                        Args = new ktList();
                    }

                    Token = (ktToken)L.Node.Value;

                    if (Token.Type == ktTokenType.RunStatement)
                    {
                        Value = TokenToValue(Token, L);
                    }
                    else
                    {
                        Value = TokenToValue(Token, L).CopyValue();
                    }

                    if (Value != null)
                    {
                        Args.Add(Value);
//.........这里部分代码省略.........
开发者ID:ChrisHinde,项目名称:KacTalk_NET,代码行数:101,代码来源:ktBlock.cs

示例3: Scan


//.........这里部分代码省略.........
                {
                    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) {
开发者ID:ChrisHinde,项目名称:KacTalk_NET,代码行数:67,代码来源:kt.cs

示例4: RunLine


//.........这里部分代码省略.........
                        {
                            break;
                        }
                    case ktTokenType.While:
                        {
                            break;
                        }
                }

                Line.Reset();
                foreach (ktList TL in Line)
                {
                    if ((TL.Node == null) || (TL.Node.Value == null))
                    {
                        continue;
                    }
                    LToken = Token;
                    Token = (ktToken)TL.Node.Value;

                    switch (Token.Type)
                    {
                        case ktTokenType.CompStatement:
                            {
                                Ret = HandleCompound(TL);
                                break;
                            }
                        case ktTokenType.AssignmentOperator:
                            {
                                Ret = HandleOperator(TL);
                                break;
                            }
                        case ktTokenType.Operator: {
                                Ret = HandleOperator(TL);
                                break;
                            }
                        /*case ktTokenType.If: {
                            break;
                        }*/
                        case ktTokenType.Number:
                        case ktTokenType.String:
                        case ktTokenType.Id:
                            {
                                ktList L = new ktList();
                                L.AddList(TL);
                                Ret = HandleStatement(L);
                                break;
                            }
                        default:
                            {
                                throw new ktError("ktBlock::RunLine(): Unexpected " + Token.Name +
                                                " on line " + Token.LineNo.ToString() +
                                                " (by character " + Token.CharPos.ToString() + ")",
                                                ktERR.UNEXP);
                            }
                    }
#if Debug
	ktDebug.Log( "New Line!!!!!!!!!!!!" );
#endif
                }
            }
            catch (ktError Err)
            {
                //ktDebug.Log("SL:SC:" + Err.ToString() + ";" + Line.Get_R());
                if (Token == null)
                {
                    if (LToken != null)
                    {
                        Token = LToken;
                    }
                    else if (Line.Node != null)
                    {
                        Token = (ktToken)Line.Node.Value;
                    }
                    else if (Line.FirstNode != null)
                    {
                        Token = (ktToken)Line.FirstNode.Value;
                    }
                    else if (Line.LastNode != null)
                    {
                        Token = (ktToken)Line.LastNode.Value;
                    }
                }
                if (Token != null)
                {
                    Err.SetLine(Token.LineNo);
                    Err.SetChar(Token.CharPos);
                    ktDebug.Log(Err.ToString());
                }
                else ktDebug.Log("NOOOOOOOO!!");
                throw Err;
            }
#if Debug
	ktDebug.Log( "EORL" );
#endif

            /*			if (Ret == null) {
				Ret = Value;
			}*/
            return Ret;
        }
开发者ID:ChrisHinde,项目名称:KacTalk_NET,代码行数:101,代码来源:ktBlock.cs

示例5: HandleOperator

        /// <summary>
        /// Handle a operator in the tree
        /// </summary>
        private bool HandleOperator(ktToken PrevToken, ktList Prev, ktToken Token, ktList L, ref ktList Tree,
                                        int RunNumb, out bool SkipNext, bool OneSided = false )
        {
            ktList Next = null;
            ktList Temp = null;

            SkipNext = false;

            // Create a new "subtree"(/operator) and assign appropriate data
            Temp = new ktList();
            Temp.Node = L.Node;
            ((ktToken)Temp.Node.Value).RunnedStep = RunNumb;

            // If the left part of the "operator tree" hasn't been parsed on this level ...
            if (PrevToken.RunnedStep < RunNumb)
            {
                // ... parse it!
                Prev = MakeAOpTree(Prev, RunNumb);
            }
            else
            {
                Prev = new ktList(Prev);
            }

            // Add the first part to the op tree
            Temp.AddList(Prev);

            // Is it a operator with two "sides"
            if (!OneSided)
            {
                // Parse the right part of the "operator tree"
                Next = MakeAOpTree(L.Next, RunNumb);
                // And add it to the op tree
                Temp.AddList(Next);

                SkipNext = true;
            }

            /*ktDebug.Log("HO: Temp:\n" + Temp.Get_R());
            ktDebug.Log("HO: Tree:\n" + Tree.Get_R());*/

            // Remove the last leaf(/item) in the tree (it will now become a leaf under this operator)
            Tree.Pop(false); // .Pop() is more efficient than .Remove() and 'false' as an argument means that it will "fail" gracefully in the event of an empty list!

            //ktDebug.Log("HO: TreeP:\n" + Tree.Get_R());

            // Add the new subtree/operator to the main tree
            Tree.AddList(Temp);

            //ktDebug.Log("HO: TreeA:\n" + Tree.Get_R());

            // Hey! That went well!
            return true;
        }
开发者ID:ChrisHinde,项目名称:KacTalk_NET,代码行数:57,代码来源:kt.cs

示例6: GetTheRest

        /// <summary>
        /// Get the rest of the line/statement...
        /// </summary>
        public ktList GetTheRest(ktList List)
        {
            ktList Rest = new ktList(), Curr = null, Next = null;
            ktToken Token = null;

            if (List == null)
            {
                return null;
            }
            if ((List.Node != null) && (List.Node.Value != null))
            {
                Token = (ktToken)List.Node.Value;
                Token = new ktToken(ktTokenType.Statement, "", Token.LineNo, Token.CharPos);
            }
            else
            {
                Token = new ktToken(ktTokenType.Statement, "", m_CurLine, m_CharPos);
            }
            Rest.Node = new ktNode("ktTStatement", Token);

            Curr = List.CurrentNode;

            while (Curr != null)
            {
                Next = Curr.Next;

                Rest.AddList(Curr);

                Curr = Next;
            }

            return Rest;
        }
开发者ID:ChrisHinde,项目名称:KacTalk_NET,代码行数:36,代码来源:kt.cs

示例7: HandleCompStatement

        /// <summary>
        /// Handle a "compound satement"
        /// </summary>
        /// <param name="Token"></param>
        /// <param name="L"></param>
        /// <param name="Tree"></param>
        /// <param name="List"></param>
        /// <param name="SkipNext"></param>
        /// <param name="ReturnTree"></param>
        /// <returns></returns>
        private bool HandleCompStatement(ktToken Token, ktList L, ref ktList Tree, ref ktList List, out bool SkipNext, out bool ReturnTree, int RunNumb = 1)
        {
            ktList First = null, Second = null, SecondChild = null, Temp = null;
            ktToken FirstToken = null, SecondToken = null, SecondChildToken = null;

            SkipNext = false;
            ReturnTree = false;

            ktDebug.Log("HandleComp:\n" + L.Get_R());

            First = L.First;
            Second = L.First.Next;
            SecondChild = Second.First;
            FirstToken = (ktToken)First.Node.Value;
            SecondToken = (ktToken)Second.Node.Value;

            if (FirstToken.Type != ktTokenType.Id)
            {
                First = MakeAOpTree(First, RunNumb);
            }

            if (SecondChild != null)
            {
                SecondChildToken = (ktToken)SecondChild.Node.Value;
                if (SecondChildToken.Type == ktTokenType.List)
                {
                    SecondChild = MakeAOpTree(SecondChild, RunNumb);

                    Second.Clear();
                    Second.AddList(SecondChild);
                }
            }
            else if (SecondToken.Type != ktTokenType.Id)
            {
                Second = MakeAOpTree(Second, RunNumb);
            }

            Temp = new ktList();
            Temp.Node = L.Node;
            ((ktToken)Temp.Node.Value).RunnedStep = RunNumb;

            Temp.AddList(First);
            Temp.AddList(Second);

            Tree.AddList(Temp);

            /*ktDebug.Log("HandleComp__:\n" + Temp.Get_R());
            ktDebug.Log("HandleComp Tree:\n" + Tree.Get_R());*/

            return true;
        }
开发者ID:ChrisHinde,项目名称:KacTalk_NET,代码行数:61,代码来源:kt.cs

示例8: HandleAssignmentOperator

        private bool HandleAssignmentOperator(ktToken PrevToken, ktList Prev, ktToken Token, ktList L, ref ktList Tree, ref ktList List, out bool SkipNext, out bool ReturnTree)
        {
            ktList Next = null;
            ktList Temp = null;

            SkipNext = false;
            ReturnTree = false;

            /*ktDebug.Log("Tree::\n" + Tree.Get_R());
            ktDebug.Log("Prev: T:\n" + Prev.Node.Value.ToString());
            ktDebug.Log("Prev::\n" + Prev.Get_R());*/

            // Remove the last leaf(/item) in the tree (it will now become a leaf under this operator)
            Tree.Pop(false); // .Pop() is more efficient than .Remove() and 'false' as an argument means that it will "fail" gracefully in the event of an empty list!

            // Take a step forward
            List.MoveNext();

            // If the previous token has childs
            if (Prev.Count > 0) {
                if ( (((ktToken)Prev.First.Node.Value).Type == ktTokenType.Id) &&
                     (Prev.First.Next != null) &&
                     (((ktToken)Prev.First.Next.Node.Value).Type == ktTokenType.Id)
                    )
                {
                    Prev.Node = new ktNode("ktTVarStatement", new ktToken(ktTokenType.VarStatement, "", ((ktToken)Prev.Node.Value).LineNo, ((ktToken)Prev.Node.Value).CharPos)); ;
                }
                else
                {
                    // Parse the left part of the op tree
                    Prev = MakeAOpTree(Prev, 1);
                }
            }

            // Get the right part of the op tree
            Next = GetTheRest(List);

            // Parse the right part of the tree
            Next = MakeAOpTree(Next, 1);

            // Create a new "subtree"(/operator) and assign appropriate data
            Temp = new ktList();
            Temp.Node = L.Node;
            ((ktToken)Temp.Node.Value).RunnedStep = 1;

            // Add the parts of op tree
            Temp.AddList(Prev);
            Temp.AddList(Next);

            // Add the operator to the tree
            Tree.AddList(Temp);

               // ktDebug.Log("Tree::\n" + Tree.Get_R());

            ktDebug.WrapLevel--;

            ReturnTree = true;

            // Hey! That went well!
            return true;
        }
开发者ID:ChrisHinde,项目名称:KacTalk_NET,代码行数:61,代码来源:kt.cs

示例9: MakeATree

        /// <summary>
        /// Parse the tokens and create a tree /*(mainly for operators)**/
        /// </summary>
        protected ktList MakeATree(ktList List, bool FirstRun, bool ThirdRun)
        {
            //ktDebug.Log( "MAT!" + List.Get_R( "\t", true ));
            ktList Tree = new ktList(), Prev = null, Next = null, Temp = null, Temp2 = null;
            ktToken Token = null, PrevToken = null;

            /*/ 	If the list are the "root"
            if (List == m_LineStack) {
                Tree.Node = new ktNode( "ktTBlock",  new ktToken( ktTokenType.Block, "", 0, 0 )  );
            } else/**/
            {
                Tree.Node = List.Node;
            }

            List.Reset();
            foreach (ktList L in List)
            {
                //ktDebug.Log( "\nLLL: "+ List.Get_R() /*+ " :" +L.Export() */);
                if ((L.Node != null) && (L.Node.Value != null))
                {
                    Token = (ktToken)L.Node.Value;
                    Prev = Tree.Last;
                    if ((Prev != null) && (Prev.Node != null) && (Prev.Node.Value != null))
                    {
                        PrevToken = (ktToken)Prev.Node.Value;
                    }
                    else
                    {
                        PrevToken = new ktToken(ktTokenType.NULLTOKEN, ":null", 0, 0);
                    }
                }
                else
                {
                    continue;
                }
            //#if ParseDebug
            ktDebug.Log( "TT:" + Token.Type.ToString() + "(" + Token.Value + ")" );
            ktDebug.Log( "PTT:" + PrevToken.Type.ToString() + "(" + PrevToken.Value + ")" );
            //#endif
                if ((FirstRun) && (
                        ((PrevToken.Type == ktTokenType.Const) || (PrevToken.Type == ktTokenType.Hard)) ||
                        ((Token.Type == ktTokenType.Const) ||  (Token.Type == ktTokenType.Hard)) ||
                        ((PrevToken.Type == ktTokenType.VarStatement) && (
                            (Token.Type != ktTokenType.AssignmentOperator)/* ||
                            (Token.Type != ktTokenType.)*/
                         )
                        )))
                {
                    //ktDebug.Log( "CONSTCONSTCONSTCONSTCONSTCONSTCONSTCONSTCONST" );
                    if (PrevToken.Type == ktTokenType.VarStatement)
                    {
                        if ((Token.Type != ktTokenType.Id) && (Token.Type != ktTokenType.Hard) &&
                            (Token.Type != ktTokenType.Const))
                        {
                            throw new ktError("Unexpected " + Token.Name + " on line " + Token.LineNo.ToString() +
                                              " by character " + Token.CharPos.ToString() + "!", ktERR.UNEXP);
                        }
                        Prev.Add(Token);
                    }
                    else
                    {
                        Temp = new ktList();
                        Temp.Node = new ktNode("ktTVarStatement", new ktToken(ktTokenType.VarStatement, "", Token.LineNo, Token.CharPos));

                        Temp.Add(Token);
                        //						Temp.AddList( MakeATree( L, FirstRun ) );

                        Tree.AddList(Temp);
                    }
                }
                else if (
                   (
                      ((PrevToken.Type == ktTokenType.Id) && (ThirdRun)) ||
                      ((/*!*/FirstRun) && (
                          (PrevToken.Type == ktTokenType.CompStatement) &&
                              (
                                  (PrevToken.Value == ".") ||
                                  (PrevToken.Value == "::")
                              )
                      )
                   )) && (
                      (Token.Type == ktTokenType.List) ||
                      (Token.Type == ktTokenType.Statement) ||
                    //				    	(Token.Type == ktTokenType.CompStatement) ||
                      (Token.Type == ktTokenType.Const) ||
                      (Token.Type == ktTokenType.Hard) ||
                      (Token.Type == ktTokenType.String) ||
                      (Token.Type == ktTokenType.Boolean) ||
                      (Token.Type == ktTokenType.Number) ||
                      (Token.Type == ktTokenType.Float) ||
                      (Token.Type == ktTokenType.Null) ||
                      (Token.Type == ktTokenType.Id) // ?? Not shure on how this actually will work!?
                   ))
                {
                    ktDebug.Log("Tree:" + Tree.Get_R());
                    Tree.Pop(false);
             /*   ktDebug.Log("TToxen:" + Token.ToString());
//.........这里部分代码省略.........
开发者ID:ChrisHinde,项目名称:KacTalk_NET,代码行数:101,代码来源:kt.cs

示例10: MakeAOpTree


//.........这里部分代码省略.........
                ktDebug.Log("opTT:" + Token.Type.ToString() + "(" + Token.Value + ")");
                ktDebug.Log("opPTT:" + PrevToken.Type.ToString() + "(" + PrevToken.Value + ")");
            //#endif
                // On run/pass 1
                if (RunNumb == 1)
                {
                    // Handle run 1
                    result = MakeAOpTree_Run1(PrevToken, Prev, Token, L, ref Tree, ref List, out SkipNext, out ReturnTree);
                }
                // On run/pass 2
                else if (RunNumb == 2)
                {
                    result = MakeAOpTree_Run2(PrevToken, Prev, Token, L, ref Tree, ref List, out SkipNext, out ReturnTree);
                }
                // On run/pass 3
                else if (RunNumb == 3)
                {
                    result = MakeAOpTree_Run3(PrevToken, Prev, Token, L, ref Tree, ref List, out SkipNext, out ReturnTree);
                }

                // If nothing was done ...
                if (!result)
                {
                    if ((Token.Type == ktTokenType.Id) || (Token.Type == ktTokenType.Null) ||
                         (Token.Type == ktTokenType.Number) || (Token.Type == ktTokenType.Float) ||
                         (Token.Type == ktTokenType.Boolean) ||
                         (Token.Type == ktTokenType.String)/* ||
                          (Token.Type == ktTokenType.If)*/ )
                    {
                        //ktDebug.Log("Constant etc!!(" + Token.Value + ")");
                        Temp = new ktList();
                        Temp.Node = L.Node;
                        ((ktToken)Temp.Node.Value).RunnedStep = RunNumb;
                        Tree.AddList(Temp);
                    }
                    else if (Token.Type == ktTokenType.If)
                    {
                        //ktDebug.Log("IF-TOKEN!");
                        Tree.AddList(new ktList(L));
                    }
                    else
                    {
                        if ((Token.Type == ktTokenType.Statement) && (L.Count == 0))
                        {
                            //ktDebug.Log("MAOT(" + RunNumb + "): SKIP(Statement)");
                            continue;
                        }

                        Temp = MakeAOpTree(L, RunNumb);
                        ktDebug.Log("MAOT(" + RunNumb + "): TEMP:\n" + Temp.Get_R());

                        if ((Token.Type == ktTokenType.Statement) && (((ktToken)Temp.FirstNode.Value).Type == ktTokenType.If))
                        {
                            Temp = Temp.First;
                        }

                        if ((Token.Type == ktTokenType.Line) &&
                            (!PrevToken.HasBlock) &&
                            ((PrevToken.Type == ktTokenType.If) ||
                              (PrevToken.Type == ktTokenType.Else) ||
                              (PrevToken.Type == ktTokenType.ElseIf)
                            ))
                        {
                            /*ktDebug.Log("ISLINE:PREVIF!");
                            ktDebug.Log("TEMP: " + Temp.Get_R());*/
                            Prev.AddList(Temp);
开发者ID:ChrisHinde,项目名称:KacTalk_NET,代码行数:67,代码来源:kt.cs

示例11: AddToken

        /// <summary>
        /// Add a token to the tokenlist
        /// </summary>
        protected bool AddToken(ktToken Token)
        {
            /**/
            if (m_Tokens == null)
            {
                m_Tokens = new ktList();
            }

            return m_Tokens.Add(Token.Name, Token);
            /*/
            if (LastBlockLines == null) {
                if (LastBlock == null) {
                    throw new ktError( "No Last Block!", ktERR.MISSING );
                }
                LastBlock.SetLines( new ktList() );
            }

            return LastBlockLines.Add( Token.Name, Token );/**/
        }

        /// <summary>
        /// Handle "separators"
        /// </summary>
        protected void HandleSep(ktList First, ktList Second, ref ktList Tree, ktToken Token)
        {
            ktDebug.Log("HASEP: T:" + Token.ToString() + "; F:" + First.ToString());
            if ((First == null) || (First.Node == null) || (First.Node.Value == null) ||
                (Second == null) || (Second.Node == null) || (Second.Node.Value == null))
            {
                throw new ktError("Unexpected ktTSeparator (" + Token.Value +
                                    ") on line " + Token.LineNo.ToString() +
                                    " by character " + Token.CharPos.ToString() + ".",
                                    ktERR.UNEXP);
            }
            ktList Temp = null;
            ktList Last = Tree.Last;
            ktToken FirstToken = (ktToken)First.Node.Value;
            ktToken SecondToken = (ktToken)Second.Node.Value;
            ktToken LastToken = null;
            ktDebug.Log( "HASEP:" + SecondToken.ToString() );/*
                        if ((Token.Value == ":") && (SecondToken.Value == ":") ) {
                            //T
                        } else */
            //ktDebug.Log( "HASEP:: FT:" + FirstToken.ToString() + "; ST:" + SecondToken.ToString() );
            if ( (FirstToken.Type == ktTokenType.Id) &&
                    ( SecondToken.Type == ktTokenType.AssignmentOperator ) &&
                    ( Token.Value == ":" ) ) {
                LastToken = new ktToken(ktTokenType.AssignmentOperator, ":=", FirstToken.LineNo, FirstToken.CharPos, ktToken.TokenToString(ktTokenType.AssignmentOperator));

                Tree.Remove((uint)(Tree.Count - 1));
                Tree.AddList(Temp);
            ktDebug.Log("TREE:" + Tree.Get_R("\t", true));
                return;
            } else if ((FirstToken.Type != ktTokenType.Id) && (FirstToken.Type != ktTokenType.List) &&
                (FirstToken.Type != ktTokenType.CompStatement) && (FirstToken.Type != ktTokenType.Boolean) &&
                (FirstToken.Type != ktTokenType.Float) && (FirstToken.Type != ktTokenType.Number) &&
                (FirstToken.Type != ktTokenType.String) ||
                (
                 (SecondToken.Type != ktTokenType.Id) &&
                 (SecondToken.Type != ktTokenType.CompStatement) &&
                 (SecondToken.Type != ktTokenType.Number)
                ))
            {
                throw new ktError("Unexpected ktTSeparator (" + Token.Value +
                                    ") on line " + Token.LineNo.ToString() +
                                    " by character " + Token.CharPos.ToString() + ".",
                                    ktERR.UNEXP);
            }
            #if DeepDebug
            #if ControlDebug
            Console.ReadLine();
            #endif
            #endif

            if ((Last != null) && (Last.Node != null) && (Last.Node.Value != null) &&
                    (Last.Node.Value.GetType() == typeof(ktToken)))
            {
                LastToken = (ktToken)Last.Node.Value;
            }

            //#if ParseDebug2
            ktDebug.Log( "FIRST(" + FirstToken.ToString() + "):\n" + First.Get_R( "\t", true ) + "\nSECOND(" + SecondToken.ToString() + "):\n" + Second.Get_R( "\t", true ) );
            ktDebug.Log( "TREE:\n" + Tree.Get_R( "\t", true ) );
            if (LastToken != null) {
            ktDebug.Log( "LAST(" + LastToken.ToString() + "):\n" + Last.Get_R( "\t", true ) );
              }
            //#endif
            if ((FirstToken.Type == ktTokenType.Number) && (SecondToken.Type == ktTokenType.Number))
            {
                //((ktToken)Tree.Last.Node.Value).Value += "." + SecondToken.Value;
                Tree.Remove((uint)(Tree.Count - 1));

                FirstToken.Value += "." + SecondToken.Value;
                FirstToken.Type = ktTokenType.Float;
                FirstToken.Name = "ktTFloat";
                Tree.Add(FirstToken);
            }
//.........这里部分代码省略.........
开发者ID:ChrisHinde,项目名称:KacTalk_NET,代码行数:101,代码来源:kt.cs


注:本文中的KacTalk.ktList.AddList方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。