コード例 #1
0
ファイル: Expander.cs プロジェクト: vamboda/botbuilder-dotnet
        private List <List <string> > VisitStructureValue(LGFileParser.KeyValueStructureLineContext context)
        {
            var values = context.keyValueStructureValue();

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

            foreach (var item in values)
            {
                if (item.IsPureExpression(out var text))
                {
                    result.Add(EvalExpression(text, context));
                }
                else
                {
                    var itemStringResult = new List <string>()
                    {
                        string.Empty
                    };
                    foreach (ITerminalNode node in item.children)
                    {
                        switch (node.Symbol.Type)
                        {
                        case LGFileParser.ESCAPE_CHARACTER_IN_STRUCTURE_BODY:
                            itemStringResult = StringListConcat(itemStringResult, new List <string>()
                            {
                                node.GetText().Escape()
                            });
                            break;

                        case LGFileParser.EXPRESSION_IN_STRUCTURE_BODY:
                            var errorPrefix = "Property '" + context.STRUCTURE_IDENTIFIER().GetText() + "':";
                            itemStringResult = StringListConcat(itemStringResult, EvalExpression(node.GetText(), item, errorPrefix));
                            break;

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

                    result.Add(itemStringResult);
                }
            }

            return(result);
        }
コード例 #2
0
        private object VisitStructureValue(LGFileParser.KeyValueStructureLineContext context)
        {
            var values = context.keyValueStructureValue();

            var result = new List <object>();

            foreach (var item in values)
            {
                if (item.IsPureExpression(out var text))
                {
                    result.Add(EvalExpression(text, context));
                }
                else
                {
                    var itemStringResult = new StringBuilder();
                    foreach (ITerminalNode node in item.children)
                    {
                        switch (node.Symbol.Type)
                        {
                        case LGFileParser.ESCAPE_CHARACTER_IN_STRUCTURE_BODY:
                            itemStringResult.Append(node.GetText().Escape());
                            break;

                        case LGFileParser.EXPRESSION_IN_STRUCTURE_BODY:
                            var errorPrefix = "Property '" + context.STRUCTURE_IDENTIFIER().GetText() + "':";
                            itemStringResult.Append(EvalExpression(node.GetText(), context, errorPrefix));
                            break;

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

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

            return(result.Count == 1 ? result[0] : result);
        }
コード例 #3
0
        private AnalyzerResult VisitStructureValue(LGFileParser.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);
        }