时间:2016-12-1来源:本站原创作者:佚名
文街上书,大家可以继续学习啦~

============================

控制流:While循环

while循环也是使用分析程序作为函数进行实现和注册:

ParserFunction.AddFunction(Constants.WHILE,newWhileStatement(this));

只要分析while关键字,就会调用WhileStatement对象的Evaluate方法:

classWhileStatement:ParserFunction{protectedoverrideParser.ResultEvaluate(stringdata,refintfrom){stringparsing=data.Substring(from);m_interpreter.CurrentChar=from;m_interpreter.ProcessWhile();returnnewParser.Result();}privateInterpreterm_interpreter;}

所以,while循环的真正实现发生在Interpreter类中,如图6所示。

图6:实现While循环

internalvoidProcessWhile(){intstartWhileCondition=m_currentChar;//Aheuristiccheckagainstaninfiniteloop.intcycles=0;intSTART_CHECK_INF_LOOP=CHECK_AFTER_LOOPS/;Parser.ResultargCache1=null;Parser.ResultargCache=null;boolstillValid=true;while(stillValid){m_currentChar=startWhileCondition;Parser.Resultarg1=GetNextIfToken();string







































娌荤枟鐧界櫆椋庝笓绉戝尰闄?
閲嶅簡娌荤枟鐧界櫆椋庣殑鍖婚櫌

转载请注明原文网址:http://www.helimiaopu.com/cxtx/2399.html

------分隔线----------------------------