Exemple #1
0
        public override string GenerateScript(LanguageOption options, int indentationlevel = 0)
        {
            if (!options.HasOption(LanguageOption.UOSLTriggers))
            {  // Native
                return(string.Format("{0}{1} {2}{3}\n{4}\n", Keyword.Trigger.Value,
                                     ChanceNode == null ? string.Empty : string.Format(" {0}", ((ScopedNode)ChanceNode).GenerateScript(options)),
                                     Name.Text,
                                     EventParameter == null ? string.Empty : string.Format("{0}{1}{2}", Punct.LPara.Value, ((ScopedNode)EventParameter).GenerateScript(options), Punct.RPara.Value),
                                     Body.GenerateScript(options)));
            }

            string functparams;

            if (Parameters == null)
            {
                string[] s = Events.GetEventParameters(Name.Text);
                functparams = string.Format("{1}{0}{2}", s == null ? string.Empty : string.Join(Punct.Comma.Value, s), Punct.LPara.Value, Punct.RPara.Value);
            }
            else
            {
                functparams = Parameters.GenerateScript(options);
            }

            return(string.Format("{0}{1} {2}{3}{4}\n{5}\n", Keyword.Trigger.Value,
                                 ChanceNode == null ? string.Empty : string.Format("{0}{1}{2}", Punct.LChev.Value, ((ScopedNode)ChanceNode).GenerateScript(options), Punct.RChev.Value),
                                 Name.Text,
                                 EventParameter == null ? string.Empty : string.Format("{0}{1}{2}", Punct.LChev.Value, ((ScopedNode)EventParameter).GenerateScript(options), Punct.RChev.Value),
                                 functparams, Body.GenerateScript(options)));
        }
Exemple #2
0
        public override string GenerateScript(LanguageOption options, int indentationlevel = 0)
        {
            StringBuilder sb = new StringBuilder(string.Format("{0}{1}{2}{3}{4}\n", Indenter(indentationlevel), Keyword.If.Value, Punct.LPara.Value, Expression.GenerateScript(options), Punct.RPara.Value));

            if (!options.HasOption(LanguageOption.UnBracedLoopsIfs) && !(Statement is BlockNode))
            {
                sb.Append(BlockNode.GenerateBlock(Statement == null ? null : new IStatement[] { (IStatement)Statement }, options, indentationlevel));
            }
            else
            {
                sb.Append(Statement.GenerateScript(options, indentationlevel));
            }
            if (StatementElse != null)
            {
                sb.Append('\n');
                sb.Append(Indenter(indentationlevel));
                sb.Append(Keyword.Else.Value);
                sb.Append('\n');
                if (!options.HasOption(LanguageOption.UnBracedLoopsIfs) && !(StatementElse is BlockNode))
                {
                    sb.Append(BlockNode.GenerateBlock(StatementElse == null ? null : new IStatement[] { (IStatement)StatementElse }, options, indentationlevel));
                }
                else
                {
                    sb.Append(StatementElse.GenerateScript(options, indentationlevel));
                }
            }
            return(sb.ToString());
        }
 public override string GenerateScript(LanguageOption options, int indentationlevel = 0)
 {
     return(string.Format("{0} {1} {2}{3}\n{4}\n", DeclKeyword.Value, UoTypeToken.Value, Name.Text, Parameters.GenerateScript(options), Body.GenerateScript(options)));
 }