private void CreateDocument() { object[] obj = stack.ToArray(); for (int i = 0; i < obj.Length; i++) { System.Xml.XmlElement element = (System.Xml.XmlElement)obj[i]; if (!"".Equals(element.GetAttribute("RTF"))) { WinWordControlEx.AddRtf(element.GetAttribute("RTF")); WinWordControlEx.InsertTitle(element.GetAttribute("TITLE"), element.GetAttribute("INDEX")); } else if (!"".Equals(element.GetAttribute("DOC"))) { WinWordControlEx.AddDoc(element.GetAttribute("DOC")); WinWordControlEx.InsertTitle(element.GetAttribute("TITLE"), element.GetAttribute("INDEX")); } else if ("0".Equals(element.GetAttribute("LEVEL"))) { WinWordControlEx.InsertTitle(element.GetAttribute("TITLE"), element.GetAttribute("INDEX")); } //element.("aaa.xml"); progressBar.Value = (int)(i * 100 / obj.Length);//根据添加的内容的多少,进度条显示操作的执行进度 } }
public virtual void ExtractAllImage(string output_path, string data_path) { var pb = _getPropertyByLink(data_path); var name = (string)pb[0]; var prop = (wzproperty)pb[1]; this.pod(name, prop, data_path); var imgs = images.ToArray(); var length = images.Count; for (var i = 0; i < length; ++i) { var pair = (object[])imgs[i]; var path = (string)pair[0]; var canvas = (wzcanvas)pair[1]; canvas.image.Save(path, System.Drawing.Imaging.ImageFormat.Png); if (this.worker != null) { this.worker.ReportProgress((int)((i + 1) * 100 / (float)length)); } } }
public bool SyntaxError(lr_parser parser, Symbol curToken) { TypeCobolProgramParser tcpParser = parser as TypeCobolProgramParser; if (tcpParser.IsTrial) { return(true); } List <string> expected = ExpectedSymbols(parser, curToken); string symName = CodeElementTokenizer.CupTokenToString(curToken.sym); string text = (curToken.value as CodeElement).Text; string msg = string.Format("extraneous input '{0}' expecting {{{1}}}", text, string.Join(", ", expected)); System.Diagnostics.Debug.WriteLine(msg); CupParserDiagnostic diagnostic = new CupParserDiagnostic(msg, curToken, null); AddDiagnostic(diagnostic); //Try to add the last encountered statement in the stack if it is not already entered. System.Collections.Stack stack = tcpParser.getParserStack(); object[] items = stack.ToArray(); foreach (var item in items) { Symbol symbol = item as Symbol; if (symbol.value is StatementElement) { lr_parser stmtParser = CloneParser(parser, (int)TypeCobolProgramSymbols.StatementEntryPoint, symbol.value as CodeElement, true); stmtParser.parse(); break; } } return(true); }
protected bool IsElseMode() { for (int i = 0; i < _nodeStack.Count; ++i) { if (_nodeStack.ToArray()[i] is ElseNode) { return(true); } } return(false); }
static void Main(string[] args) { System.Collections.Stack stack = new System.Collections.Stack(); stack.Push(1); stack.Push(2); stack.Push(3); Console.WriteLine("1 in stack:{0}", stack.Contains(1)); Console.WriteLine("Remove 1:{0}", stack.Pop()); Console.WriteLine("Peek1:{0}", stack.Peek()); object[] numArray = stack.ToArray(); Console.WriteLine(string.Join(", ", numArray)); }
public static System.Collections.Stack SortStack(System.Collections.Stack pila, Boolean Order) { object[] vectorA = pila.ToArray(); int aux1; if (Order) { for (int i = 0; i < vectorA.Length - 1; i++) { for (int j = i + 1; j < vectorA.Length; j++) { if ((int)vectorA[i] < (int)vectorA[j]) { aux1 = (int)vectorA[i]; vectorA[i] = vectorA[j]; vectorA[j] = aux1; } } } } else { for (int i = 0; i < vectorA.Length - 1; i++) { for (int j = i + 1; j < vectorA.Length; j++) { if ((int)vectorA[i] > (int)vectorA[j]) { aux1 = (int)vectorA[i]; vectorA[i] = vectorA[j]; vectorA[j] = aux1; } } } } System.Collections.Stack pila1 = new System.Collections.Stack(); for (int i = 0; i < vectorA.Length - 1; i++) { pila1.Push((int)vectorA[i]); } return(pila1); }
private bool EvaluatePostfix() { operandStack.Clear(); Operand num; System.Array postfix = postfixStack.ToArray(); System.Array.Reverse(postfix); foreach (var token in postfix) { if (token.GetType() == typeof(Operator)) { num = new Operand(); switch (((Operator)token).type) { case OperatorType.BINARY: if (operandStack.Count < 2) { lastError = "Evaluation error, a binary operator needs 2 operands"; return(false); } operandStack.Push(((Operator)token).semantic(ref num, ((Operand)operandStack.Pop()), ((Operand)operandStack.Pop()))); break; case OperatorType.UNARY: if (operandStack.Count < 1) { lastError = "Evaluation error, an unary operator needs 1 operand"; return(false); } operandStack.Push(((Operator)token).semantic(ref num, ((Operand)operandStack.Pop()))); break; } } else if (token.GetType() == typeof(Operand)) { operandStack.Push(token); } else if (token.GetType() == typeof(FunctionCall)) { num = new Operand(); argumentList.Clear(); for (int i = 0; i < ((FunctionCall)token).args; i++) { if (operandStack.Count != 0) { argumentList.Add(operandStack.Pop()); } else { lastError = "Evaluation error, wrong argument count"; return(false); } } operandStack.Push(((FunctionCall)token).definition(ref num, (Operand[])argumentList.ToArray(typeof(Operand)))); } } if (operandStack.Count != 1) { lastError = "Evaluation error, unstacked operands"; return(false); } lastResult = ((Operand)operandStack.Peek()); varTable.Remove("ans"); varTable.Add("ans", lastResult); return(true); }
public FAMIX.BehaviouralEntity CurrentMethod() { return((FAMIX.BehaviouralEntity)stack.ToArray().First(m => m is FAMIX.BehaviouralEntity)); }
/* Returns the root node of the AST. It only makes sense to call * this after a successful parse. */ internal virtual INode rootNode() { return((INode)(nodes.ToArray())[nodes.Count - (0 + 1)]); }