예제 #1
0
 private void AddStatement(Statement s)
 {
     if (s.kids.Top is IfStatement || s.kids.Top is WhileStatement || s.kids.Top is DoWhileStatement || s.kids.Top is ForLoop) kids.Add(s.kids.Pop());
     else kids.Add(s);
 }
예제 #2
0
 public WhileStatement(Parser yyp, SYMBOL s, Statement st)
     : base(((LSLSyntax
         )yyp))
 {
     kids.Add(s);
     if (0 < st.kids.Count && st.kids.Top is CompoundStatement) kids.Add(st.kids.Pop());
     else kids.Add(st);
 }
예제 #3
0
 public StatementList(Parser yyp, Statement s)
     : base(((LSLSyntax
         )yyp))
 {
     AddStatement(s);
 }
예제 #4
0
 public StatementList(Parser yyp, StatementList sl, Statement s)
     : base(((LSLSyntax
         )yyp))
 {
     while (0 < sl.kids.Count) kids.Add(sl.kids.Pop());
     AddStatement(s);
 }
예제 #5
0
 private void AddStatement(Statement s)
 {
     if (0 < s.kids.Count && s.kids.Top is CompoundStatement) kids.Add(s.kids.Pop());
     else kids.Add(s);
 }
예제 #6
0
 public IfStatement(Parser yyp, SYMBOL s, Statement ifs, Statement es)
     : base(((LSLSyntax
         )yyp))
 {
     kids.Add(s);
     AddStatement(ifs);
     if (0 < es.kids.Count && es.kids.Top is IfStatement) kids.Add(es.kids.Pop());
     else AddStatement(es);
 }
예제 #7
0
 public IfStatement(Parser yyp, SYMBOL s, Statement ifs)
     : base(((LSLSyntax
         )yyp))
 {
     kids.Add(s);
     AddStatement(ifs);
 }
예제 #8
0
 public ForLoop(Parser yyp, ForLoopStatement flsa, Expression e, ForLoopStatement flsb, Statement s)
     : base(((LSLSyntax
         )yyp))
 {
     kids.Add(flsa);
     kids.Add(e);
     kids.Add(flsb);
     if (0 < s.kids.Count && s.kids.Top is CompoundStatement) kids.Add(s.kids.Pop());
     else kids.Add(s);
 }
예제 #9
0
        /// <summary>
        /// Generates the code for a Statement node.
        /// </summary>
        /// <param name="s">The Statement node.</param>
        /// <returns>String containing C# code for Statement s.</returns>
        private string GenerateStatement(Statement s)
        {
            string retstr = String.Empty;
            bool printSemicolon = true;

            retstr += Indent();

            if (0 < s.kids.Count)
            {
                // Jump label prints its own colon, we don't need a semicolon.
                printSemicolon = !(s.kids.Top is JumpLabel);

                foreach (SYMBOL kid in s.kids)
                    retstr += GenerateNode(kid);
            }

            if (printSemicolon)
                retstr += GenerateLine(";");

            return retstr;
        }