本文整理汇总了C#中KacTalk.ktList.Pop方法的典型用法代码示例。如果您正苦于以下问题:C# ktList.Pop方法的具体用法?C# ktList.Pop怎么用?C# ktList.Pop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KacTalk.ktList
的用法示例。
在下文中一共展示了ktList.Pop方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Scan
//.........这里部分代码省略.........
}
#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;
}
示例2: 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;
}
示例3: 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());
//.........这里部分代码省略.........
示例4: 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;
}
示例5: MakeAOpTree
//.........这里部分代码省略.........
(PrevToken.Type == ktTokenType.Else) ||
(PrevToken.Type == ktTokenType.ElseIf)
))
{
/*ktDebug.Log("ISLINE:PREVIF!");
ktDebug.Log("TEMP: " + Temp.Get_R());*/
Prev.AddList(Temp);
}
else
{
Tree.AddList(Temp);
}
}
}
//ktDebug.Log("MAOT(" + RunNumb + "): TREE:\n" + Tree.Get_R());
// Should we return the tree we have created??
if (ReturnTree)
{
// Return the tree and be done with this part!
return Tree;
}
// Should we skip this one?
if (SkipNext)
{
SkipNext = false;
List.MoveNext();
}
continue;
// OLD CODE FOR REFERENCE:
if ((RunNumb == 1) && (Token.Type == ktTokenType.Block))
{
if (((PrevToken.Type == ktTokenType.If) ||
(PrevToken.Type == ktTokenType.Else) ||
(PrevToken.Type == ktTokenType.ElseIf)
) &&
(!PrevToken.HasBlock))
{
/*Tree.Last.AddList(new ktList(L));
((ktToken)Tree.Last.Node.Value).HasBlock = true;*/
Prev.AddList(new ktList(L));
PrevToken.HasBlock = true;
}
else
{
Tree.AddList(new ktList(L));
}
}
else 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;
if (L.GetCount() != 0)
{
Temp.AddList(MakeAOpTree(L, RunNumb));
}
Tree.AddList(Temp);
}
else if (Token.Type == ktTokenType.If)
{
//ktDebug.Log("IF-TOKEN!");
Tree.AddList(new ktList(L));
}
else if ((RunNumb == 1) && (PrevToken.Type == ktTokenType.If) && (!PrevToken.HasBlock) && (RunNumb == 1) &&
((Token.Type == ktTokenType.Statement) || (Token.Type == ktTokenType.List)) )
{
ktList ifL = Tree.Pop();
Temp = new ktList();
Temp.Node = ifL.Node;
((ktToken)Temp.Node.Value).RunnedStep = RunNumb;
Temp.AddList(MakeAOpTree(L, RunNumb));
#if ParseDebug
ktDebug.Log("MAOT(" + RunNumb + "): IF-statement: " + Temp.Get_R());
#endif
Tree.AddList(Temp);
#if ParseDebug
ktDebug.Log("MAOT(" + RunNumb + "): IF TREE: " + Tree.Get_R());
#endif
}
}
#if ParseDebug
ktDebug.Log( "MAOTREE(" + RunNumb + "):\n" + Tree.Get_R( "\t", true ) );
ktDebug.WrapLevel--;
if (this.m_enabledDebug && (this.m_enabledAt == ktDebug.WrapLevel)) { ktDebug.D.Disable(); }
#endif
return Tree;
}