本文整理汇总了C#中KacTalk.ktList.Clear方法的典型用法代码示例。如果您正苦于以下问题:C# ktList.Clear方法的具体用法?C# ktList.Clear怎么用?C# ktList.Clear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KacTalk.ktList
的用法示例。
在下文中一共展示了ktList.Clear方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Scan
/// <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++;
//.........这里部分代码省略.........
示例2: MakeATree
//.........这里部分代码省略.........
#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))