getText() public method

public getText ( ) : String
return String
Beispiel #1
0
 public override void VisitVariableElement(VariableElement element){
   if(mVariableMap.ContainsKey(element.getText())){
     int element_value = (int) mVariableMap[element.getText()];
     mStack.Push(element_value);
   } else {
     //lets assume that the syntax has been checked for this example because I don't like the exception
     //propegation that will happen if I throw here
     //throw new Exception("Variable " + element.getText() + " not defined.");
   }
 }
Beispiel #2
0
 public override void VisitVariableElement(VariableElement element){
   if(mVariableMap.ContainsKey(element.getText())){
      List<int> list = new List<int>();
       //list.Add(mVariableMap[element.getText()]);
       list = (List<int>)mVariableMap[element.getText()];
       for (int i = 0; i < list.Count; i++)
       {
           mStack.Push(list[i]);
       }
   } else {
     //lets assume that the syntax has been checked for this example because I don't like the exception
     //propegation that will happen if I throw here
     //throw new Exception("Variable " + element.getText() + " not defined.");
   }
 }
Beispiel #3
0
 static void Main(String[] args)
 {
     Console.WriteLine("\nTesting the LessThanEqualTo class");
     Console.WriteLine("\n==========================================\n");
     LessThanEqualToElement elem = new LessThanEqualToElement();
     VariableElement var_elem0 = new VariableElement();
     var_elem0.setText("a");
     elem.setLessThanEqualToLhs(var_elem0);
     VariableElement var_elem1 = new VariableElement();
     var_elem1.setText("b");
     elem.setLessThanEqualToRhs(var_elem1);
     VariableElement var_elem2 = new VariableElement();
     var_elem2 = (VariableElement)elem.getLessThanEqualToLhs();
     VariableElement var_elem3 = new VariableElement();
     var_elem3 = (VariableElement)elem.getLessThanEqualToRhs();
     Console.Write("LessThanEqualTo element is "+ var_elem2.getText().ToString()+" <= "+ var_elem3.getText().ToString()+"\n\n");
 }
    //-----------<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 VisitVariableElement(VariableElement element)
 {
     Console.Write("var:" + element.getText() + " ");
 }
Beispiel #6
0
 public override void VisitVariableElement(VariableElement element)
 {
     if (inParallelFor == 1)
     {
         if (parallelVars.Contains(element.getText()))
         {
         }
         else
         {
             varData(element.getText());
         }
         parallelString.Append(element.getText());                
     }
     else if (map_contains_matrix(element.getText()))
     {
         mat_stack.Push(mVariableMap[element.getText()]);
     }
 }
Beispiel #7
0
 public override void VisitVariableElement(VariableElement element)
 {
     if (map_contains_matrix(element.getText()))
     {
         mat_stack.Push(mVariableMap[element.getText()]);
     }
 }
Beispiel #8
0
 public override void VisitVariableElement(VariableElement element)
 {
     Console.Write("Value:");
     int a = 0;
     if (interp.getMap().ContainsKey(element.getText()))
         a = GetTypeOfElement((Element)(element));
     try
     {
         if (a == 1)
             VisitIntegerElement((IntegerElement)(interp.getMap()[element.getText()]));
         else if (a == 2)
             VisitDoubleElement((DoubleElement)(interp.getMap()[element.getText()]));
         else if (a == 3)
             VisitMatrixElement((MatrixVariableDeclaration)(interp.getMap()[element.getText()]));
         else if (a == 4)
             VisitStructObject((StructObjectDeclaration)(interp.getMap()[element.getText()]));
         else if (a == 7)
             VisitStringElement((StringElement)(interp.getMap()[element.getText()]));
     }
     catch (Exception e)
     {
         e = new Exception();
         String s = e.Message;
     }
 }
Beispiel #9
0
 //----< set the value of an index >------------------------------
 private bool setIndexValue(VariableElement var, VariableElement indexVar, int givenValue, ref int value)
 {
     if (var.getText() != indexVar.getText())
       {
       return false;
       }
       else
       {
       value = givenValue;
       }
       return true;
 }
Beispiel #10
0
     static void Main(String[] args)
 {
     Console.WriteLine("\nTesting the IfStatementElement class");
     Console.WriteLine("\n==========================================\n");
     EqualityOperationElement elem = new EqualityOperationElement();
     VariableElement var_elem = new VariableElement();
     var_elem.setText("a");
     elem.setequalityLhs(var_elem);
     IntegerElement int_elem = new IntegerElement();
     int_elem.setText("1");
     elem.setequalityRhs(int_elem);
     VariableElement elem2 = new VariableElement();
     elem2.setText("b");
     IfStatementElement if_elem = new IfStatementElement();
     if_elem.CONDITION= elem;
     ScalarVariableDeclaration scalar_elem = new ScalarVariableDeclaration();
     scalar_elem.setType("int");
     scalar_elem.setVar(var_elem);
     List<Element> Iflist = new List<Element>();
     Iflist.Add(scalar_elem);
     if_elem.IFCODE = Iflist;
     List<Element> ElseList = new List<Element>();
     ElseList.Add(int_elem);
     if_elem.ELSECODE = ElseList;
     ReturnElement elem_ret = new ReturnElement();
     VariableElement var_elem2 = new VariableElement();
     var_elem.setText("a");
     elem_ret.setreturnvariable(var_elem2);
     VariableElement var_elem1 = new VariableElement();
     var_elem1 = (VariableElement)elem_ret.getreturnvariable();
     Console.Write("IfStatement element " + var_elem1.GetType().ToString()+" "+ var_elem1.getText().ToString() + "\n");
     EqualityOperationElement eq_elem = new EqualityOperationElement();
     eq_elem = (EqualityOperationElement)if_elem.CONDITION;
     Console.Write("The condition has : "+eq_elem.ToString()+"->"+eq_elem.getequalityLhs()+" == "+eq_elem.getequalityRhs()+"\n");
     List<Element> elem_list = new List<Element>();
     elem_list = if_elem.IFCODE;
     for (int i = 0; i < elem_list.Count; i++)
     {
         Console.Write("The if loop list has " + elem_list[i].ToString() + "\n");
     }
     elem_list = if_elem.ELSECODE;
     for (int i = 0; i < elem_list.Count; i++)
     {
         Console.Write("The Else loop list has " + elem_list[i].ToString() + "\n");
     }
 }