//-----------<Test Stub>-------- static void main(string[] args) { Console.WriteLine("\nTesting the AssignmentOperationElement class"); Console.WriteLine("\n==========================================\n"); AssignmentOperationElement elem_assign = new AssignmentOperationElement(); IntegerElement int_elem = new IntegerElement(); VariableElement var_elem = new VariableElement(); string lhsval = "a"; string rhsval = "3"; VariableElement lhs = var_elem; Element rhs = int_elem; int_elem.setText(rhsval); var_elem.setText(lhsval); elem_assign.setLhs(lhs); elem_assign.setRhs(rhs); var_elem=elem_assign.getLhs(); int_elem = (IntegerElement)elem_assign.getRhs(); Console.WriteLine("{0} The element at Lhs is:", int_elem.getText()); Console.WriteLine("{0} The element at the rhs is:", var_elem.getText()); }
public override void VisitForStatementElement(ForStatementElement element) { //throw new NotImplementedException(); if (inParallelFor == 1) { parallelString.Append("for(" + element.RANGEVARIABLE.getText() + "->"); parallelString.Append(element.STARTINGRANGE.getText() + " to " + element.ENDINGRANGE.getText() + ")"); parallelString.Append("\n{"); for (int i = 0; element.CODELIST.Count != 0 && i < element.CODELIST.Count; i++) { VisitElement(element.CODELIST[i]); } parallelString.Append("\n}"); CreateForData(element); } else { try { int start = 0; int end = 0; if (element.RANGEVARIABLE.getText() != null && element.STARTINGRANGE.getText() != null && element.ENDINGRANGE.getText() != null) { try { start = int.Parse(element.STARTINGRANGE.getText()); end = int.Parse(element.ENDINGRANGE.getText()); } catch(Exception err) { sendres(113, "The range for the for loop is not set"); err.GetType(); } if (end != 0) { if (start <= end) { if (!map_contains_matrix(element.RANGEVARIABLE.getText())) { //local++; //Hashtable localTable = new Hashtable(); //scope.Push(localTable); ScalarVariableDeclaration scalar_elem = new ScalarVariableDeclaration(); scalar_elem.setType("int"); scalar_elem.setVar(element.RANGEVARIABLE); VisitElement(scalar_elem); for (int i = start; i <= end; i++) { AssignmentOperationElement elem = new AssignmentOperationElement(); elem.setLhs(element.RANGEVARIABLE); IntegerElement int_elem = new IntegerElement(); int_elem.setText(i.ToString()); elem.setRhs(int_elem); VisitElement(elem); List<Element> codeList = new List<Element>(); codeList = element.CODELIST; for (int j = 0; j < codeList.Count; j++) { VisitElement(codeList[j]); } } //scope.Pop(); //local--; } else sendres(112, "The range variable in the for loop has already been used in the program. Please use a different variable."); } else sendres(112, "The starting index should be less than the ending index"); } } else sendres(112, "The ending index of the for loop cannot be zero"); } catch(Exception err) { sendres(113, "For loop cannot be executed. Please check for semantic errors"); err.GetType(); } } }