Example #1
0
        private DataExpression GenerateExpression(ParseTreeNode node)
        {
            switch (node.Term.Name)
            {
            case "AndOp":
                return(new AndOp(GenerateExpression(node.ChildNodes[0]), GenerateExpression(node.ChildNodes[1])));

            case "OrOp":
                return(new OrOp(GenerateExpression(node.ChildNodes[0]), GenerateExpression(node.ChildNodes[1])));

            case "EqOp":
                return(new EqOp(GenerateExpression(node.ChildNodes[0]), GenerateExpression(node.ChildNodes[1])));

            case "GtOp":
                return(new GtOp(GenerateExpression(node.ChildNodes[0]), GenerateExpression(node.ChildNodes[1])));

            case "PlusOp":
                return(new PlusOp(GenerateExpression(node.ChildNodes[0]), GenerateExpression(node.ChildNodes[1])));

            case "MinOp":
                return(new MinOp(GenerateExpression(node.ChildNodes[0]), GenerateExpression(node.ChildNodes[1])));

            case "TimesOp":
                return(new TimesOp(GenerateExpression(node.ChildNodes[0]), GenerateExpression(node.ChildNodes[1])));

            case "DivOp":
                return(new DivOp(GenerateExpression(node.ChildNodes[0]), GenerateExpression(node.ChildNodes[1])));

            case "Const":
                return(GenerateConst(node.ChildNodes[0]));

            case "identifier":
                return(new Unit());

            case "DPathValue":
                return(new ValueOf(GenerateExpression(node.ChildNodes[0])));

            case "DPathIncluded":
                return(new IsIncluded(GenerateExpression(node.ChildNodes[0])));

            case "DPathExecuted":
                return(new IsExecuted(GenerateExpression(node.ChildNodes[0])));

            case "DPathPending":
                return(new IsPending(GenerateExpression(node.ChildNodes[0])));

            case "DPath":
                return(new Path(GeneratePath(node.ChildNodes[0])));

            case "NegOp":
                return(new NegOp(GenerateExpression(node.ChildNodes[0])));

            case "Function0Args":
                return(new Function(node.ChildNodes[0].Token.Text));

            case "Function1Args":
                var arg1 = GenerateExpression(node.ChildNodes[1]);
                var func = new Function(node.ChildNodes[0].Token.Text);
                func.AddArgument(arg1);
                return(func);

            default:
                throw new NotImplementedException(node.ToString());
            }
        }