Пример #1
0
        private List <List <object> > VisitStructureValue(LGTemplateParser.KeyValueStructureLineContext context)
        {
            var values = context.keyValueStructureValue();

            var result = new List <List <object> >();

            foreach (var item in values)
            {
                if (item.IsPureExpression())
                {
                    result.Add(EvalExpression(item.expressionInStructure(0).GetText(), context.GetText()));
                }
                else
                {
                    var itemStringResult = new List <string>()
                    {
                        string.Empty
                    };
                    foreach (var child in item.children)
                    {
                        if (child is LGTemplateParser.ExpressionInStructureContext expression)
                        {
                            var errorPrefix = "Property '" + context.STRUCTURE_IDENTIFIER().GetText() + "':";
                            itemStringResult = StringListConcat(itemStringResult, EvalExpression(expression.GetText(), context.GetText(), errorPrefix));
                        }
                        else
                        {
                            var node = child as ITerminalNode;
                            switch (node.Symbol.Type)
                            {
                            case LGTemplateParser.ESCAPE_CHARACTER_IN_STRUCTURE_BODY:
                                itemStringResult = StringListConcat(itemStringResult, new List <string>()
                                {
                                    node.GetText().Replace(@"\|", "|").Escape()
                                });
                                break;

                            default:
                                itemStringResult = StringListConcat(itemStringResult, new List <string>()
                                {
                                    node.GetText()
                                });
                                break;
                            }
                        }
                    }

                    result.Add(itemStringResult.Cast <object>().ToList());
                }
            }

            return(result.Select(x => x.Select(y => y as object).ToList()).ToList());
        }
Пример #2
0
        private object VisitStructureValue(LGTemplateParser.KeyValueStructureLineContext context)
        {
            var values = context.keyValueStructureValue();

            var result = new List <object>();

            foreach (var item in values)
            {
                if (item.IsPureExpression())
                {
                    result.Add(EvalExpression(item.expressionInStructure(0).GetText(), context.GetText()));
                }
                else
                {
                    var itemStringResult = new StringBuilder();
                    foreach (var child in item.children)
                    {
                        if (child is LGTemplateParser.ExpressionInStructureContext expression)
                        {
                            var errorPrefix = "Property '" + context.STRUCTURE_IDENTIFIER().GetText() + "':";
                            itemStringResult.Append(EvalExpression(expression.GetText(), context.GetText(), errorPrefix));
                        }
                        else
                        {
                            var node = child as ITerminalNode;
                            switch (node.Symbol.Type)
                            {
                            case LGTemplateParser.ESCAPE_CHARACTER_IN_STRUCTURE_BODY:
                                itemStringResult.Append(node.GetText().Replace(@"\|", "|").Escape());
                                break;

                            default:
                                itemStringResult.Append(node.GetText());
                                break;
                            }
                        }
                    }

                    result.Add(itemStringResult.ToString().Trim());
                }
            }

            return(result.Count == 1 ? result[0] : result);
        }
Пример #3
0
        private AnalyzerResult VisitStructureValue(LGTemplateParser.KeyValueStructureLineContext context)
        {
            var values = context.keyValueStructureValue();

            var result = new AnalyzerResult();
            foreach (var item in values)
            {
                if (item.IsPureExpression(out var text))
                {
                    result.Union(AnalyzeExpression(text));
                }
                else
                {
                    var expressions = item.EXPRESSION_IN_STRUCTURE_BODY();
                    foreach (var expression in expressions)
                    {
                        result.Union(AnalyzeExpression(expression.GetText()));
                    }
                }
            }

            return result;
        }
Пример #4
0
        private AnalyzerResult VisitStructureValue(LGTemplateParser.KeyValueStructureLineContext context)
        {
            var values = context.keyValueStructureValue();

            var result = new AnalyzerResult();

            foreach (var item in values)
            {
                if (item.IsPureExpression())
                {
                    result.Union(AnalyzeExpression(item.expressionInStructure(0).GetText()));
                }
                else
                {
                    var expressions = item.expressionInStructure();
                    foreach (var expression in expressions)
                    {
                        result.Union(AnalyzeExpression(expression.GetText()));
                    }
                }
            }

            return(result);
        }