CreateCommaToken() 공개 정적인 메소드

public static CreateCommaToken ( ) : Node
리턴 Node
예제 #1
0
        public override Node ExitFunctionConstructorCallOrVariableDeclaration(Production node)
        {
            Token identifier = (Token)GrammaticaNodeUtils.FindChildOf(node, new string[2] {
                "Type", "IDENTIFIER"
            });

            if (identifier == null)
            {
                return(node);
            }

            replaceIntrinsicFunc(identifier);

            // mul(term, term) => term * term
            if (identifier.GetImage().Equals("mul"))
            {
                identifier.AddValue("");

                Node virgula = GrammaticaNodeUtils.FindChildOf(node, new string[2] {
                    "PartOf_Constructor_Call", "COMMA"
                });
                virgula.AddValue(" * ");
            }

            // cross(T,N) => cross(N,T).
            if (identifier.GetImage().Equals("cross"))
            {
                Production listOfParam = (Production)GrammaticaNodeUtils.FindChildOf(node, "PartOf_Constructor_Call");

                Node exp1 = GrammaticaNodeUtils.FindChildOf(listOfParam, "Expression", 1);
                Node exp2 = GrammaticaNodeUtils.FindChildOf(listOfParam, "Expression", 2);

                GrammaticaNodeUtils.SwapChildrenPosition(listOfParam, exp1, exp2);
            }

            // saturate(x) => clamp(x,0.0,1.0).
            if (identifier.GetImage().Equals("saturate"))
            {
                identifier.AddValue("clamp");

                var listOfParam = (Production)GrammaticaNodeUtils.FindChildOf(node, "PartOf_Constructor_Call");
                var children    = GrammaticaNodeUtils.GetChildren(listOfParam);
                children.Insert(2, GrammaticaNodeUtils.CreateCommaToken());
                children.Insert(3, GrammaticaNodeUtils.CreateNumberToken(0.0f));
                children.Insert(4, GrammaticaNodeUtils.CreateCommaToken());
                children.Insert(5, GrammaticaNodeUtils.CreateNumberToken(1.0f));
            }

            // add dependent function
            Node n = GrammaticaNodeUtils.FindChildOf(node, "PartOf_Constructor_Call");

            if (n != null && identifier != null && functionScope != null)
            {
                // function call or constructor call.

                dependencyGraph.SearchDependant(identifier.GetImage()).AddCallsBy(functionScope);
            }

            // Adds only globalVars.

            if (!scopeVars.Contains(identifier.GetImage()))
            {
                dependencyGraph.SearchDependant(identifier.GetImage()).AddCallsBy(functionScope);
            }


            return(node);
        }