コード例 #1
0
ファイル: lsl.parser.cs プロジェクト: WordfromtheWise/Aurora
		public  GlobalDefinitions (Parser yyp, GlobalDefinitions  gd , GlobalFunctionDefinition  gfd ):base(((LSLSyntax
		                                                                                                     )yyp)){ while (0< gd . kids . Count ) kids . Add ( gd . kids . Pop ());
			kids . Add ( gfd );
		}
コード例 #2
0
ファイル: lsl.parser.cs プロジェクト: WordfromtheWise/Aurora
		public  GlobalDefinitions (Parser yyp, GlobalFunctionDefinition  gfd ):base(((LSLSyntax
		                                                                             )yyp)){ kids . Add ( gfd );
		}
コード例 #3
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)
        {
            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();
        }
コード例 #4
0
ファイル: CSCodeGenerator.cs プロジェクト: rknop/Aurora-Sim
        /// <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();
        }
コード例 #5
0
ファイル: CSCodeGenerator.cs プロジェクト: kow/Aurora-Sim
        /// <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();
        }
コード例 #6
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)
        {
            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();
        }