Exemple #1
0
		public  GlobalDefinitions (Parser yyp, GlobalDefinitions  gd , GlobalFunctionDefinition  gfd ):base(((LSLSyntax
		                                                                                                     )yyp)){ while (0< gd . kids . Count ) kids . Add ( gd . kids . Pop ());
			kids . Add ( gfd );
		}
Exemple #2
0
		public  GlobalDefinitions (Parser yyp, GlobalFunctionDefinition  gfd ):base(((LSLSyntax
		                                                                             )yyp)){ kids . Add ( gfd );
		}
        /// <summary>
        /// Generates the code for a GlobalFunctionDefinition node.
        /// </summary>
        /// <param name="gf">The GlobalFunctionDefinition node.</param>
        /// <returns>String containing C# code for GlobalFunctionDefinition gf.</returns>
        private string GenerateGlobalFunctionDefinition(GlobalFunctionDefinition gf)
        {
            string retstr = "";

            // we need to separate the argument declaration list from other kids
            List<SYMBOL> argumentDeclarationListKids = new List<SYMBOL>();
            List<SYMBOL> remainingKids = new List<SYMBOL>();

            foreach (SYMBOL kid in gf.kids)
                if (kid is ArgumentDeclarationList)
                    argumentDeclarationListKids.Add(kid);
                else
                    remainingKids.Add(kid);
            /*
                        if (gf.ReturnType != "void")
                        {
                            retstr.Append(GenerateIndented(String.Format("{0} {1}(", gf.ReturnType, CheckName(gf.Name)), gf));
                            IsParentEnumerable = false;
                        }
                        else
                        {
                            retstr.Append(GenerateIndented(String.Format("{0} {1}(", "IEnumerator", CheckName(gf.Name)), gf));
                            IsParentEnumerable = true;
                        }
             */


            retstr += GenerateIndented(String.Format("public IEnumerator {0}(", CheckName(gf.Name)), gf);

//            LocalMethods.Add(CheckName(gf.Name), gf.ReturnType);
            IsParentEnumerable = true;

            // print the state arguments, if any
            foreach (SYMBOL kid in argumentDeclarationListKids)
                retstr += GenerateArgumentDeclarationList((ArgumentDeclarationList)kid);

            retstr += GenerateLine(")");
            foreach (SYMBOL kid in remainingKids)
                retstr += GenerateNode(kid);
            IsParentEnumerable = false;
            return retstr.ToString();
        }
Exemple #4
0
        /// <summary>
        /// Generates the code for a GlobalFunctionDefinition node.
        /// </summary>
        /// <param name="gf">The GlobalFunctionDefinition node.</param>
        /// <returns>String containing C# code for GlobalFunctionDefinition gf.</returns>
        private string GenerateGlobalFunctionDefinition(GlobalFunctionDefinition gf)
        {
            MethodVariables.Clear();
            VariablesToRename.Clear();
            StringBuilder retstr = new StringBuilder();

            // we need to separate the argument declaration list from other kids
            List<SYMBOL> argumentDeclarationListKids = new List<SYMBOL>();
            List<SYMBOL> remainingKids = new List<SYMBOL>();


            foreach (SYMBOL kid in gf.kids)
                if (kid is ArgumentDeclarationList)
                    argumentDeclarationListKids.Add(kid);
                else
                    remainingKids.Add(kid);

            retstr.Append(GenerateIndented(String.Format("public IEnumerator {0}(", CheckName(gf.Name)), gf));

            IsParentEnumerable = true;

            // print the state arguments, if any
            foreach (SYMBOL kid in argumentDeclarationListKids)
            {
                ArgumentDeclarationList ADL = (ArgumentDeclarationList)kid;
                retstr.Append(GenerateArgumentDeclarationList(ADL));
            }

            retstr.Append(GenerateLine(")"));

          

            foreach (SYMBOL kid in remainingKids)
                retstr.Append(GenerateNode(kid));

            if (gf.ReturnType == "void")
            {
                int i;
                for (i = 1; i < 5; i++)
                {
                    if (retstr[retstr.Length - i] == '}')
                    {
                        retstr.Insert(retstr.Length - i, GenerateLine(" yield break;"));
                        break;
                    }
                }
            }

            IsParentEnumerable = false;
            return retstr.ToString();
        }
Exemple #5
0
        /// <summary>
        /// Generates the code for a GlobalFunctionDefinition node.
        /// </summary>
        /// <param name="gf">The GlobalFunctionDefinition node.</param>
        /// <returns>String containing C# code for GlobalFunctionDefinition gf.</returns>
        private string GenerateGlobalFunctionDefinition(GlobalFunctionDefinition gf)
        {
            MethodVariables.Clear();
            VariablesToRename.Clear();
            StringBuilder retstr = new StringBuilder();

            // we need to separate the argument declaration list from other kids
            List<SYMBOL> argumentDeclarationListKids = new List<SYMBOL>();
            List<SYMBOL> remainingKids = new List<SYMBOL>();


            foreach (SYMBOL kid in gf.kids)
                if (kid is ArgumentDeclarationList)
                    argumentDeclarationListKids.Add(kid);
                else
                    remainingKids.Add(kid);

            retstr.Append(GenerateIndented(String.Format("public {1} {0}(", CheckName(gf.Name), gf.ReturnType), gf));

            // print the state arguments, if any
            foreach (SYMBOL kid in argumentDeclarationListKids)
            {
                ArgumentDeclarationList ADL = (ArgumentDeclarationList)kid;
                retstr.Append(GenerateArgumentDeclarationList(ADL));
            }

            retstr.Append(GenerateLine(")"));

            retstr.Append(GenerateLine("{"));
            retstr.Append(GenerateLine("CheckSleep();"));

            foreach (SYMBOL kid in remainingKids)
                retstr.Append(GenerateNode(kid));

            retstr.Append(GenerateLine("}"));

            return retstr.ToString();
        }
        /// <summary>
        /// Generates the code for a GlobalFunctionDefinition node.
        /// </summary>
        /// <param name="gf">The GlobalFunctionDefinition node.</param>
        /// <returns>String containing C# code for GlobalFunctionDefinition gf.</returns>
        private string GenerateGlobalFunctionDefinition(GlobalFunctionDefinition gf)
        {
            StringBuilder retstr = new StringBuilder();

            // we need to separate the argument declaration list from other kids
            List<SYMBOL> argumentDeclarationListKids = new List<SYMBOL>();
            List<SYMBOL> remainingKids = new List<SYMBOL>();

            foreach (SYMBOL kid in gf.kids)
                if (kid is ArgumentDeclarationList)
                    argumentDeclarationListKids.Add(kid);
                else
                    remainingKids.Add(kid);

            retstr.Append(GenerateIndented(String.Format("{0} {1}(", gf.ReturnType, CheckName(gf.Name)), gf));

            // print the state arguments, if any
            foreach (SYMBOL kid in argumentDeclarationListKids)
                retstr.Append(GenerateArgumentDeclarationList((ArgumentDeclarationList) kid));

            retstr.Append(GenerateLine(")"));
            foreach (SYMBOL kid in remainingKids)
                retstr.Append(GenerateNode(kid));

            return retstr.ToString();
        }