Пример #1
0
        public static List <string> GetLabels(ParseTreeNode node)
        {
            var result = new List <string>();

            var labelsNode = node;

            while (labelsNode != null)
            {
                var idParseTreeNode = labelsNode.GetFirstChildWithGrammarName(GrammarNames.id);
                var label           = IdParseTreeNodeHelper.GetValue(idParseTreeNode);
                result.Add(label);

                labelsNode = labelsNode.GetFirstChildWithGrammarName(GrammarNames.labels);
            }

            return(result);
        }
Пример #2
0
        public static string GetValue(ParseTreeNode node)
        {
            var idParseTreeNode = node.GetFirstChildWithGrammarName(GrammarNames.id);

            if (idParseTreeNode != null)
            {
                return(IdParseTreeNodeHelper.GetValue(idParseTreeNode));
            }

            var name1ParseTreeNodes = node.GetAllChildsWithGrammarName(GrammarNames.name1);

            if (name1ParseTreeNodes != null)
            {
                return(string.Join(".", name1ParseTreeNodes.Select(n1 => GetValue(n1))));
            }

            throw new ArgumentException("Cannot get name1 value.");
        }
Пример #3
0
        public static string GetId(ParseTreeNode node)
        {
            var idParseTreeNode = node.GetFirstChildWithGrammarName(GrammarNames.id);

            return(IdParseTreeNodeHelper.GetValue(idParseTreeNode));
        }