public CreateTreeFile(TreeAS treeAS)//Tree treeSyntactic1,
 {
     //this.treeSyntactic = treeSyntactic1;
     this.treeAS = treeAS;
     createStringSave();
     //saveTree();
 }
示例#2
0
 private void analizeCode()
 {
     pile.Add("E");
     //treeSyntactic = new Tree("E");
     treeSyntactic      = new TreeAS("E");
     this.numberOfToken = 0;
     while (this.pile.Count > 0)
     {
         int    pileSize      = this.pile.Count();
         String lastInPile    = this.pile[pileSize - 1];
         token  tokenR        = this.pileTokens[numberOfToken];
         String tokenRequired = tokenR.getName();
         if (namesNoTerminal.Contains(lastInPile))
         {
             Boolean isError = true;
             foreach (RowSA row in this.tableSA)
             {
                 String nameNoTerminal = row.getRow();
                 String column         = row.getCol();
                 if (column == tokenRequired && nameNoTerminal == lastInPile)
                 {
                     //añadir a la pila el valor
                     pile.RemoveAt(pileSize - 1);
                     String values = row.getVal();
                     addDiferentsToPile(values);
                     //treeSyntactic.setValues(values);
                     if (this.numberErrors == 0)
                     {
                         treeSyntactic.setNoTerminal(nameNoTerminal, tokenR);
                     }
                     isError = false;
                     break;
                 }
             }
             if (isError == true)
             {
                 if (lastInPile != "Q'")
                 {
                     addError("Error sintactico", tokenR.getRow().ToString());
                 }
                 pile.RemoveAt(pileSize - 1);
             }
         }
         else
         {
             //el ultimo en la pila no es un no terminal
             if (lastInPile == "reduce")
             {
                 pile.RemoveAt(pileSize - 1);
             }
             else
             {
                 if (lastInPile == tokenRequired)
                 {
                     if (this.numberErrors == 0)
                     {
                         treeSyntactic.setNode(tokenR);
                     }
                     pile.RemoveAt(pileSize - 1);
                     this.numberOfToken++;
                 }
                 else
                 {
                     pile.RemoveAt(pileSize - 1);
                     addError("Se esperaba: " + lastInPile, tokenR.getRow().ToString());
                 }
             }
         }
     }
     this.form1.setTreeAS((object)this.treeSyntactic);
     if (this.numberErrors == 0)
     {
         setPrintAndReadInErrors();
     }
     //CreateTreeFile createtree = new CreateTreeFile(this.treeSyntactic);//this.treeSyntactic
     //TODO Crear arbol, crear grafico
 }
示例#3
0
 public void setTreeAS(object tree)
 {
     this.tree = (TreeAS)tree;
 }