本文整理汇总了C#中KacTalk.ktList.Reset方法的典型用法代码示例。如果您正苦于以下问题:C# ktList.Reset方法的具体用法?C# ktList.Reset怎么用?C# ktList.Reset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KacTalk.ktList
的用法示例。
在下文中一共展示了ktList.Reset方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ktXML
public ktXML(ktList List)
: this()
{
if (List == null)
{
return;
}
if (List.Node != null)
{
m_Node = new ktXMLNode(List.Node);
}
else
{
m_Node = new ktXMLNode("post");
}
//ktDebug.Log( "POST:" + List.Get_R( "\t", true ) + "=###=#==#=#==##==#=#=#=");
List.Reset();
foreach (ktList L in List)
{
if (L != null)
{
AddList(new ktXML(L));
}
}
}
示例2: HandleCompAssignment
protected ktValue HandleCompAssignment(ktList Target, ktValue Value)
{
bool Constant = false, Hard = false;
ktString Name = new ktString(), ClassName = null;
ktToken Token = null;
ktClass Class = null;
#if Debug
ktDebug.Log( "HCAHCAHCAHCAHCAHCAHCAHCAHCAHCAHCAHCAHCAHCA" );
#endif
ktDebug.Log("HCA: V:" + Value.Export() + "\n" + Target.Get_R());
Target.Reset();
foreach (ktList L in Target)
{
if ((L.Node == null) || (L.Node.Value == null))
{
continue;
}
Token = (ktToken)L.Node.Value;
#if Debug
ktDebug.Log( "HCA:" + Token.ToString() );
#endif
switch (Token.Type)
{
case ktTokenType.Const:
{
if (Constant)
{
throw new ktError("Unexpected " + Token.ToString() + " on line " +
Token.LineNo.ToString() + " by character " +
Token.CharPos.ToString() + "!",
ktERR.UNEXP);
}
Constant = true;
break;
}
case ktTokenType.Hard:
{
if (Hard)
{
throw new ktError("Unexpected " + Token.ToString() + " on line " +
Token.LineNo.ToString() + " by character " +
Token.CharPos.ToString() + "!",
ktERR.UNEXP);
}
Hard = true;
break;
}
case ktTokenType.Id:
{
if (!Name.IsEmpty())
{
try
{
Class = GetClass(Name);
ClassName = Name;
Hard = true;
} catch (Exception) {
throw new ktError("Unexpected " + Token.ToString() + " (" +
Token.Value + ") on line " +
Token.LineNo.ToString() + " by character " +
Token.CharPos.ToString() + "!",
ktERR.UNEXP);
}
}
Name = Token.Value;
break;
}
}
}
Value.Constant = Constant;
Value.HardType = Hard;
if (!Value.IsNull())
{
((ktClass)Value.Value).HardType = Hard;
((ktClass)Value.Value).IsConstant = Constant;
}
if (Class != null)
{
ktList Arg = new ktList();
ktClass Obj = Class.CreateObject();
Obj.HardType = Hard;
Obj.IsConstant = Constant;
if (!Value.IsNull())
{
Arg.Add(Value);
Obj.RunMethod("Assign", Arg);
}
Value = new ktValue(Name, ClassName, Obj, Hard, Constant);
}
SetVariable(Name, true, Value, true, true);
//.........这里部分代码省略.........
示例3: 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);
//.........这里部分代码省略.........
示例4: RunLine
public ktValue RunLine(ktList Line)
{
ktValue Ret = ktValue.Null;
ktToken Token = null;
ktToken LToken = null;
if (Line == null)
{
throw new ktError("ktBlock::RunLine() : Didn't get a line to run!", ktERR.NOTSET);
}
//#if Debug
ktDebug.Log( "RL:" + Line.Get_R( " ", true ) );
//#endif
/*if (Token.LineNo == 3)
{
//ktDebug.Log("L3T: ");
ktDebug.Log("L3: " + Line.Get_R(" ", true));
}*/
try
{
Token = (ktToken)Line.Node.Value;
if (Line.GetCount() == 0)
{
if (Line.Node != null)
{
if (Token.Type == ktTokenType.String)
{
Ret = new ktValue(":ktString", "ktString", MakeObjectOf("ktString", Token.Value),
true, true);
}
else if (Token.Type == ktTokenType.Number)
{
Ret = new ktValue(":ktInt", "ktInt", MakeObjectOf("ktInt", Token.Value),
true, true);
}
else if (Token.Type == ktTokenType.Float)
{
Ret = new ktValue(":ktFloat", "ktFloat", MakeObjectOf("ktFloat", Token.Value),
true, true);
}
else if (Token.Type == ktTokenType.Id)
{
Ret = GetVariable(Token.Value);
}
}
else
{
//throw new ktError( "ktBlock::RunLine() : Didn't get a line to run!", ktERR.NOTSET );
return Ret;
}
}
switch (Token.Type)
{
case ktTokenType.If:
{
bool r = CheckLogicStatement(Line.First,Token, ref Ret);
if (r)
{
// m_skipNextLine = true;
ktList Next = Line.First.Next;
ktToken IfToken = (ktToken)Next.Node.Value;
switch (IfToken.Type)
{
case ktTokenType.Block:
{
IfToken.Block.SetParent(this);
Ret = IfToken.Block.Run();
break;
}
default:
{
Ret = RunLine(Next);
break;
}
};
}
return Ret;
}
case ktTokenType.For:
{
break;
}
case ktTokenType.Foreach:
{
break;
}
case ktTokenType.While:
{
break;
}
}
Line.Reset();
foreach (ktList TL in Line)
{
if ((TL.Node == null) || (TL.Node.Value == null))
{
//.........这里部分代码省略.........
示例5: ktList
public ktList(ktList List)
: this()
{
if (List == null)
{
return;
}
if (List.Node != null)
{
m_Node = new ktNode(List.Node);
}
else
{
m_Node = null;
}
List.Reset();
foreach (ktList L in List)
{
AddList(new ktList(L));
}
}
示例6: Replace
public static ktList Replace(ktList Replacements, ktString Haystack)
{
ktList Results = new ktList();
ktString Pattern = new ktString();
ktString Replacement = new ktString();
ktRE_MatchEvaluator Ev = null;
ktNode Node;
ktString Result = "";
object First = null, Second = null;
Replacements.Reset();
foreach (ktList Post in Replacements)
{
if (Post.IsEmpty())
{
if ((Post.Node != null) && (Post.Node.Value != null))
{
Pattern = Post.Node.Name;
if ((Post.Node.Value.GetType() == typeof(ktString)) ||
(Post.Node.Value.GetType() == typeof(string)))
{
Replacement = Post.Node.Value.ToString();
Results.Add(Replace(Pattern, Haystack, Replacement));
}
else if (Post.Node.Value.GetType() == typeof(ktRE_MatchEvaluator))
{
Ev = (ktRE_MatchEvaluator)Post.Node.Value;
Results.Add(Replace(Pattern, Haystack, Ev));
}
else if (Post.Node.Value.GetType() == typeof(ktRegEx))
{
//ktRegEx RE = (ktRegEx)Post.Node.Value;
if (Pattern.IsEmpty())
{
//Results.Add( RE.Replace( Haystack, Ev ) );
}
else
{
//Results.Add( Replace( Pattern, Haystack, Ev ) );
}
}
}
}
else if (Post.Count == 2)
{
if ((Node = Post.GetNode(0)) != null)
{
First = Node.Value;
if ((Node = Post.GetNode(1)) != null)
{
Second = Node.Value;
}
}
if (Second != null)
{
if (First.GetType() == typeof(ktRegEx))
{
Result = HandleRegExFirst((ktRegEx)First, Second, Haystack);
Results.Add(Result);
}
else if (First.GetType() == typeof(ktString[]))
{
ktString[] Patterns = (ktString[])First;
foreach (ktString P in Patterns)
{
Result = HandleStringFirst(P, Second, Haystack);
Results.Add(Result);
}
}
else if (First.GetType() == typeof(ktList))
{
ktList Patterns = (ktList)First;
foreach (ktList P in Patterns)
{
if ((P.Node != null) && (P.Node.Value != null))
{
Pattern = P.Node.Value.ToString();
Result = HandleStringFirst(Pattern, Second, Haystack);
Results.Add(Result);
}
}
}
else /*if ((First.GetType() == typeof( ktString )) ||
(First.GetType() == typeof( string )))*/
{
Result = HandleStringFirst(First.ToString(), Second, Haystack);
Results.Add(Result);
}
}
}
}
return Results;
}
示例7: 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());
//.........这里部分代码省略.........
示例8: MakeAOpTree
/// <summary>
/// Parse the tokens and create a optree
/// </summary>
protected ktList MakeAOpTree(ktList List, int RunNumb)
{
ktList Tree = new ktList(), Prev = null, Temp = null;
ktToken Token = null, PrevToken = null;
bool result = false, SkipNext = false, ReturnTree = false;
// ktDebug.Log("MAOT!! [" + RunNumb + "]\n" + List.Get_R("\t") );
// null is null..
if (List == null)
{
return null;
}
ktDebug.WrapLevel++;
// Same, same, same...
Tree.Node = List.Node;
if ((Tree.Node == null) || (Tree.Node.Value == null) ||
(Tree.Node.Value.GetType() != typeof(ktToken)))
{
if (Tree.Node == null)
{
Tree.Node = new ktNode("ktBlock");
}
Tree.Node.Value = new ktToken(ktTokenType.Block, "ktBlock", 0, 0);
}
((ktToken)Tree.Node.Value).RunnedStep = RunNumb;
//#if ParseDebug
ktDebug.Log("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\nMAOT(" + RunNumb + "):" + List.Get_R());
//#endif
List.Reset();
foreach (ktList L in List)
{
SkipNext = false;
// Check so we don't try to work on nothing!
if ((L.Node != null) && (L.Node.Value != null))
{
// Get Token and previous...
Token = (ktToken)L.Node.Value;
Prev = Tree.Last;
// Get previous token if possible
if ((Prev != null) && (Prev.Node != null) && (Prev.Node.Value != null))
{
PrevToken = (ktToken)Prev.Node.Value;
}
else
{
PrevToken = new ktToken(ktTokenType.NULLTOKEN, ":null", 0, 0);
}
// Nothing here??
}
// Nothing there? ...
else
{
// ... Lets continue!
continue;
}
//ktDebug.Log("LLLLLLLLLL:::\n" + L.Get_R());
//ktDebug.Log("LiLiLiLiLiLiLiLiLiLi:::\n" + List.Get_R());
//#if ParseDebug3
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;
//.........这里部分代码省略.........