Пример #1
0
 /// <summary>
 /// Generates the node structure required to generate a default
 /// initialization.
 /// </summary>
 /// <param name="p">
 /// Tools.Parser instance to use when instantiating nodes.
 /// </param>
 /// <param name="constantType">String describing the datatype.</param>
 /// <returns>
 /// A SYMBOL node conaining the appropriate structure for intializing a
 /// constantType.
 /// </returns>
 private SYMBOL GetZeroConstant(Parser p, string constantType)
 {
     switch (constantType)
     {
     case "integer":
         return new Constant(p, constantType, "0");
     case "float":
         return new Constant(p, constantType, "0.0");
     case "string":
     case "key":
         return new Constant(p, constantType, "");
     case "list":
         ArgumentList al = new ArgumentList(p);
         return new ListConstant(p, al);
     case "vector":
         Constant vca = new Constant(p, "float", "0.0");
         Constant vcb = new Constant(p, "float", "0.0");
         Constant vcc = new Constant(p, "float", "0.0");
         ConstantExpression vcea = new ConstantExpression(p, vca);
         ConstantExpression vceb = new ConstantExpression(p, vcb);
         ConstantExpression vcec = new ConstantExpression(p, vcc);
         return new VectorConstant(p, vcea, vceb, vcec);
     case "rotation":
         Constant rca = new Constant(p, "float", "0.0");
         Constant rcb = new Constant(p, "float", "0.0");
         Constant rcc = new Constant(p, "float", "0.0");
         Constant rcd = new Constant(p, "float", "0.0");
         ConstantExpression rcea = new ConstantExpression(p, rca);
         ConstantExpression rceb = new ConstantExpression(p, rcb);
         ConstantExpression rcec = new ConstantExpression(p, rcc);
         ConstantExpression rced = new ConstantExpression(p, rcd);
         return new RotationConstant(p, rcea, rceb, rcec, rced);
     default:
         return null; // this will probably break stuff
     }
 }
Пример #2
0
		public  ListConstant (Parser yyp, ArgumentList  al ):base(((LSLSyntax
		                                                           )yyp),"list", null ){ kids . Add ( al );
		}
Пример #3
0
		public  ArgumentList (Parser yyp, ArgumentList  al , Argument  a ):base(((LSLSyntax
		                                                                         )yyp)){ while (0< al . kids . Count ) kids . Add ( al . kids . Pop ());
			AddArgument ( a );
		}
Пример #4
0
		public  FunctionCall (Parser yyp, string  id , ArgumentList  al ):base(((LSLSyntax
		                                                                        )yyp)){ m_id = id ;
			kids . Add ( al );
		}
Пример #5
0
        /// <summary>
        /// Generates the code for an ArgumentList node.
        /// </summary>
        /// <param name="al">The ArgumentList node.</param>
        /// <returns>String containing C# code for ArgumentList al.</returns>
        private string GenerateArgumentList(ArgumentList al)
        {
            string retstr = "";

            int comma = al.kids.Count - 1;  // tells us whether to print a comma

            foreach (SYMBOL s in al.kids)
            {
                retstr += GenerateNode(s);
                if (0 < comma--)
                    retstr += Generate(", ");
            }

            return retstr.ToString();
        }
Пример #6
0
        /// <summary>
        /// Generates the code for an ArgumentList node.
        /// </summary>
        /// <param name="al">The ArgumentList node.</param>
        /// <returns>String containing C# code for ArgumentList al.</returns>
        private string GenerateArgumentList(ArgumentList al)
        {
            StringBuilder retstr = new StringBuilder();

            int comma = al.kids.Count - 1;  // tells us whether to print a comma

            foreach (SYMBOL s in al.kids)
            {
                retstr.Append(GenerateNode(s));
                if (0 < comma--)
                    retstr.Append(Generate(", "));
            }

            return retstr.ToString();
        }