Esempio n. 1
0
		public  StateBody (Parser yyp, StateEvent  se ):base(((LSLSyntax
		                                                      )yyp)){ kids . Add ( se );
		}
Esempio n. 2
0
        /// <summary>
        /// Generates the code for a StateEvent node.
        /// </summary>
        /// <param name="se">The StateEvent node.</param>
        /// <param name="parentStateName">The name of the parent state.</param>
        /// <returns>String containing C# code for StateEvent se.</returns>
        private string GenerateStateEvent(StateEvent se, string parentStateName)
        {
            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 se.kids)
                if (kid is ArgumentDeclarationList)
                    argumentDeclarationListKids.Add(kid);
                else
                    remainingKids.Add(kid);

            // "state" (function) declaration
            retstr += GenerateIndented(String.Format("public IEnumerator {0}_event_{1}(", parentStateName, se.Name), se);

            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);

            return retstr.ToString();
        }
Esempio n. 3
0
		public  StateBody (Parser yyp, StateBody  sb , StateEvent  se ):base(((LSLSyntax
		                                                                      )yyp)){ while (0< sb . kids . Count ) kids . Add ( sb . kids . Pop ());
			kids . Add ( se );
		}
Esempio n. 4
0
        /// <summary>
        /// Generates the code for a StateEvent node.
        /// </summary>
        /// <param name="se">The StateEvent node.</param>
        /// <param name="parentStateName">The name of the parent state.</param>
        /// <returns>String containing C# code for StateEvent se.</returns>
        private string GenerateStateEvent(StateEvent se, string parentStateName)
        {
            StringBuilder retstr = new System.Text.StringBuilder();

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

            MethodVariables.Clear();
            VariablesToRename.Clear();
            
            foreach (SYMBOL kid in se.kids)
                if (kid is ArgumentDeclarationList)
                    argumentDeclarationListKids.Add(kid);
                else
                    remainingKids.Add(kid);

            // "state" (function) declaration
            retstr.Append(GenerateIndented(String.Format("public IEnumerator {0}_event_{1}(", parentStateName, se.Name), se));

            IsParentEnumerable = true;

            // 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));


            if (retstr[retstr.Length - 2] == '}')
                retstr.Insert(retstr.Length - 2,GenerateLine("    yield break;"));

            return retstr.ToString();
        }