Exemplo n.º 1
0
        public void setNoTerminal(String noTerminal, token nextToken)
        {
            String  tokenRequired = nextToken.getName();
            String  nameLastNode  = nodesWaited[nodesWaited.Count - 1].getName();
            Boolean isError       = true;

            foreach (RowSA row in this.tableSA)
            {
                String nameNoTerminal = row.getRow();
                String column         = row.getCol();
                if (column == tokenRequired && nameNoTerminal == noTerminal && nameNoTerminal == nameLastNode)
                {
                    NodeTree nodeToUse         = new NodeTree(codeUsing.ToString(), nameNoTerminal);
                    NodeTree nodeParentFromUse = nodesWaited[nodesWaited.Count - 1].getParent();
                    nodeParentFromUse.setNewChild(nodeToUse);
                    nodeToUse.setNodeParent(nodeParentFromUse);
                    this.nodeUsing = nodeToUse;
                    String values = row.getVal();
                    setTokensToWait(values);
                    this.codeUsing++;
                    isError = false;
                    break;
                }
            }
            if (isError == true && nameLastNode.Equals("Q'"))
            {
                nodesWaited.RemoveAt(nodesWaited.Count - 1);
                setNoTerminal(noTerminal, nextToken);
            }
        }
Exemplo n.º 2
0
        public void addNodeTree(token tokenSet, NodeWaited nodeInsert)
        {
            codeUsing++;
            NodeTree parent = nodeInsert.getParent();
            String   name   = nodeInsert.getName();

            if (this.nodeWaitValue.Contains(nodeInsert.getName()))
            {
                String newName = tokenSet.getVal();
                name = newName;
            }
            NodeTree newNode = new NodeTree("node" + codeUsing.ToString(), name);

            newNode.setNodeParent(parent);
            parent.setNewChild(newNode);
            nodesWaited.RemoveAt(nodesWaited.Count - 1);
        }
Exemplo n.º 3
0
        public void setValues(String values)
        {
            String[]        valuesToInsert  = values.Split('.');
            List <NodeTree> childsNodeUsing = nodeUsing.getChilds();

            foreach (String item in valuesToInsert)
            {
                if (valuesToInsert[valuesToInsert.Length - 1].Equals("reduce") == false)
                {
                    codeUsing++;

                    NodeTree nodeInsert = new NodeTree("node" + codeUsing.ToString(), item);
                    nodeInsert.setNodeParent(this.nodeUsing);
                    childsNodeUsing.Add(nodeInsert);
                }
            }
            this.nodeUsing.setChilds(childsNodeUsing);
            setNewNodeUsing();
        }