Esempio n. 1
0
        public override object VisitStringExpr(StringExprContext context)
        {
            var text = "";

            if (context.stringTemplate().Length == 0)
            {
                foreach (var v in context.stringContent())
                {
                    text += Visit(v);
                }
                return((new System.Text.StringBuilder().Append("\"").Append(text).Append("\"")).to_str());
            }
            else
            {
                text = "(new System.Text.StringBuilder()";
                foreach (var i in range(1, context.ChildCount - 2, 1, true, true))
                {
                    var v = context.GetChild(i);
                    var r = (string)(Visit(context.GetChild(i)));
                    if (v.@is <StringContentContext>())
                    {
                        text += (new System.Text.StringBuilder().Append(".Append(").Append("\"").Append(r).Append("\"").Append(")")).to_str();
                    }
                    else
                    {
                        text += r;
                    }
                }
                text += ").to_str()";
                return(text);
            }
        }
Esempio n. 2
0
        public override object VisitStringExpr(StringExprContext context)
        {
            var text = "";

            if (context.stringTemplate().Length == 0)
            {
                foreach (var v in context.stringContent())
                {
                    text += Visit(v);
                }
                return((new System.Text.StringBuilder().Append("\"").Append(text).Append("\"")).To_Str());
            }
            else
            {
                text = "(new System.Text.StringBuilder()";
                foreach (var i in 1.Up_until(context.ChildCount - 1))
                {
                    var v = context.GetChild(i);
                    var r = ((string)Visit(context.GetChild(i)));
                    if ((v is StringContentContext))
                    {
                        text += (new System.Text.StringBuilder().Append(".Append(").Append("\"").Append(r).Append("\"").Append(")")).To_Str();
                    }
                    else
                    {
                        text += r;
                    }
                }
                text += ").To_Str()";
                return(text);
            }
        }