예제 #1
0
        private static void assignVariablesHelper(TreeElementType ruleTreeElement, TreeElementType apply, List <Tuple <string, TreeElementType> > variablesDestination, ITreeManipulationFacade <TreeElementType> treeManipulationFacade)
        {
            if (treeManipulationFacade.getType(ruleTreeElement) == ITreeManipulationFacade <TreeElementType> .EnumTreeElementType.VARIABLE)
            {
                variablesDestination.Add(new Tuple <string, TreeElementType>(treeManipulationFacade.getVariableName(ruleTreeElement), apply));
            }
            else
            {
                int childrenCount = treeManipulationFacade.getNumberOfChildren(ruleTreeElement);
                Debug.Assert(treeManipulationFacade.getNumberOfChildren(ruleTreeElement) == treeManipulationFacade.getNumberOfChildren(apply));

                for (int i = 0; i < childrenCount; i++)
                {
                    assignVariablesHelper(treeManipulationFacade.getChildren(ruleTreeElement, i), treeManipulationFacade.getChildren(apply, i), variablesDestination, treeManipulationFacade);
                }
            }
        }
예제 #2
0
 private static TreeElementType rewrite(TreeElementType apply, List <Tuple <string, TreeElementType> > variables, ITreeManipulationFacade <TreeElementType> treeManipulationFacade)
 {
     if (treeManipulationFacade.getType(apply) == ITreeManipulationFacade <TreeElementType> .EnumTreeElementType.VARIABLE)
     {
         TreeElementType variableValue = (TreeElementType)getVariableByName(variables, treeManipulationFacade.getVariableName(apply)).Clone();
         treeManipulationFacade.setType(variableValue, ITreeManipulationFacade <TreeElementType> .EnumTreeElementType.VALUE);
         return(variableValue);
     }
     else
     {
         for (int i = 0; i < treeManipulationFacade.getNumberOfChildren(apply); i++)
         {
             TreeElementType iterationApplyChildren = treeManipulationFacade.getChildren(apply, i);
             TreeElementType rewritten = rewrite(iterationApplyChildren, variables, treeManipulationFacade);
             treeManipulationFacade.setChildren(apply, i, rewritten);
         }
         return(apply);
     }
 }