Exemplo n.º 1
0
        public override object VisitDictionary([NotNull] DictionaryContext context)
        {
            var key    = Any;
            var value  = Any;
            var result = new Result();

            for (int i = 0; i < context.dictionaryElement().Length; i++)
            {
                var r = (DicEle)Visit(context.dictionaryElement(i));
                if (i == 0)
                {
                    key          = r.key;
                    value        = r.value;
                    result.text += r.text;
                }
                else
                {
                    if (key != r.key)
                    {
                        key = Any;
                    }
                    if (value != r.value)
                    {
                        value = Any;
                    }
                    result.text += "," + r.text;
                }
            }
            var type = key + "," + value;

            result.data = $"{dic}<{type}>";
            result.text = $"(new {result.data}(){{ {result.text} }})";
            return(result);
        }
Exemplo n.º 2
0
        public override object VisitDictionary(DictionaryContext context)
        {
            var key    = Any;
            var value  = Any;
            var result = (new Result());

            foreach (var i in range(0, context.dictionaryElement().Length - 1, 1, true, true))
            {
                var r = (DicEle)(Visit(context.dictionaryElement(i)));
                if (i == 0)
                {
                    key          = r.key;
                    value        = r.value;
                    result.text += r.text;
                }
                else
                {
                    if (key != r.key)
                    {
                        key = Any;
                    }
                    if (value != r.value)
                    {
                        value = Any;
                    }
                    result.text += "," + r.text;
                }
            }
            var type = (new System.Text.StringBuilder().Append(key).Append(", ").Append(value)).to_str();

            result.data = (new System.Text.StringBuilder().Append(Dic).Append("<").Append(type).Append(">")).to_str();
            result.text = (new System.Text.StringBuilder().Append("(new ").Append(result.data).Append("(){ ").Append(result.text).Append(" })")).to_str();
            return(result);
        }