コード例 #1
0
ファイル: PrettyPrintVisitor.cs プロジェクト: shranjan/pinac
 public override void VisitVectorElement(VectorVariableDeclaration element)
 {
     Console.Write("Vector<" + element.getType()+">[");
     VisitElement(element.getRange());
     Console.Write("] ");
     VisitElement(element.getText());
     Console.Write(" = [");
     List<Element> elem = new List<Element>();
     elem = element.getList();
     for (int i = 0; i < elem.Count; i++)
     {
         VisitElement(elem[i]);
         if (elem.Count > 1 && i != (elem.Count - 1))
         {
             Console.Write(",");
         }
     }
     Console.Write("];\n");
 }
コード例 #2
0
ファイル: Visitor.cs プロジェクト: zuzhu/pinac
 public abstract void VisitVectorElement(VectorVariableDeclaration element);
コード例 #3
0
ファイル: InterpreterVisitor_.cs プロジェクト: rkpandya/pinac
 public override void VisitVectorElement(VectorVariableDeclaration element)
 {
     //throw new NotImplementedException();
     string variable_name = ((VariableElement)element.getText()).getText();
     string type = element.getType();
     if (mVariableMap.Count == 0)
         mVariableMap.Add(variable_name, element);
     else
     {
         if (mVariableMap.Contains(variable_name))
         {
             Console.Write(" \nSemantic Error.. ");
             sendres(112, "\nSemantic Error...\n");
             Console.Write("\n The vector name you entered is already existing.. try again..");
             sendres(112, "\n The vector name you entered is already existing.. try again..");
             return;
         }
         else
         {
             mVariableMap.Add(variable_name, element);
         }
     }
 }
コード例 #4
0
ファイル: InterpreterVisitor_.cs プロジェクト: rkpandya/pinac
        private void CreateData()
        {
            int curElement = 0;
            
            StringReader readStr = new StringReader(matStr.ToString());
            XmlTextReader xf = new XmlTextReader(readStr);
            MatrixVariableDeclaration mat=null;
            VectorVariableDeclaration vec = null;
            string matElem="";
            int currRow = 0;
            int index = 0;
            string type="";
            int totalRows = 0;
            int totalCols = 0;
            int currCol = -1;
            int[,] elems = new int[10, 10]; ;
            while (xf.Read())
            {
                switch (xf.NodeType)
                {
                    case XmlNodeType.Element:
                        {
                            if (xf.Name == "Matrix")
                            {
                                curElement = 1;
                                mat = new MatrixVariableDeclaration();
                                currRow = 0; currCol = -1;
                            }
                            if (xf.Name == "Vector")
                            {
                                curElement = 2;
                                vec = new VectorVariableDeclaration();
                            }
                            if (curElement == 2)
                            {
                                if (xf.Name == "name")
                                    matElem = "name";
                               
                            }
                            if (curElement == 1)
                            {
                                if (xf.Name == "name")
                                    matElem = "name";
                                if (xf.Name == "row")
                                    matElem = "row";
                                if (xf.Name == "col")
                                    matElem = "column";
                                if (xf.Name == "type")
                                    matElem = "type";
                                if (xf.Name == "Elements")
                                {
                                    elems = new int[totalRows, totalCols];
                                }
                                if (xf.Name == "Element")
                                {
                                    matElem = "elem";
                                    if (currCol == totalCols - 1 && currRow < totalRows - 1)
                                    {
                                        currRow += 1;
                                        currCol = 0;
                                    }
                                    else currCol += 1;
                                }
                            }

                            break;
                        }
                    case XmlNodeType.Text:
                        {
                            if (curElement == 1)
                            {
                                if (matElem == "row")
                                {
                                    IntegerElement row = new IntegerElement();
                                    totalRows = int.Parse(xf.Value.ToString());
                                    row.setText(xf.Value);
                                    mat.setRow(row);
                                }
                                if (matElem == "column")
                                {
                                    IntegerElement col = new IntegerElement();
                                    totalCols = int.Parse(xf.Value.ToString());
                                    col.setText(xf.Value);
                                    mat.setColumn(col);
                                }
                                if (matElem == "name")
                                {
                                    VariableElement val = new VariableElement();
                                    val.setText(xf.Value);
                                    mat.setVar(val);
                                }
                                if (matElem == "type")
                                    {
                                        type = xf.Value;
                                        mat.setType(type);
                                    }
                                if (matElem == "elem")
                                {
                                    if (type == "int")
                                    {
                                        elems[currRow, currCol] = int.Parse(xf.Value.ToString());
                                    }
                                    else if (type == "double")
                                        mat.setdoubleValueat(currRow, currCol, double.Parse(xf.Value.ToString()));
                                }
                            }
                            break;
                        }
                    case XmlNodeType.EndElement:
                        {
                            if (xf.Name == "Elements" && curElement==1)
                            {
                                mat.setIntMatrix(elems);
                                parallelMap.Add(mat.getVar().getText(), mat);
                            }
                            Console.Write("End:" + xf.Name);
                            break;
                        }
                    default:
                        {
                            Console.Write("\n");
                            break;
                        }
                }
            }
        }
コード例 #5
0
 public override void VisitVectorElement(VectorVariableDeclaration element)
 {
     //throw new NotImplementedException();
 }