Пример #1
0
        public void AddAttr(string type, ParserRuleContext ctx)
        {
            int start, end;

            ctx.GetBounds(out start, out end);
            AddAttrNode(type, null, start, end);
        }
Пример #2
0
        ParserNode HandleContext(ParserRuleContext context, string type)
        {
            ParserNode node = null;

            if (type != null)
            {
                int start, end;
                context.GetBounds(out start, out end);
                if (type == TEXT)
                {
                    while ((start < end) && (char.IsWhiteSpace(input[start])))
                    {
                        ++start;
                    }
                    while ((end > start) && (char.IsWhiteSpace(input[end - 1])))
                    {
                        --end;
                    }
                }
                if (start != end)
                {
                    node = new ParserNode {
                        Type = type, Parent = Parent, Start = start, End = end
                    };
                    stack.Push(node);
                }
            }

            VisitChildren(context);
            if (node != null)
            {
                stack.Pop();
            }
            return(node);
        }
Пример #3
0
        public void AddAttr(string type, string input, ParserRuleContext ctx)
        {
            var text = ctx.GetText(input);
            int start, end;

            ctx.GetBounds(out start, out end);
            AddAttrNode(type, text, start, end);
        }
Пример #4
0
        ParserNode GetNode(ParserRuleContext context, string type, ParserNode.ParserNavigationTypeEnum parserNavigationType)
        {
            int start, end;

            context.GetBounds(out start, out end);
            return(new ParserNode {
                Type = type, Start = start, End = end, ParserNavigationType = parserNavigationType
            });
        }
Пример #5
0
        public static string GetText(this ParserRuleContext ctx, string input)
        {
            if (input == null)
            {
                return(null);
            }
            int start, end;

            ctx.GetBounds(out start, out end);
            return(input.Substring(start, end - start));
        }
Пример #6
0
        ParserNode GetNode(ParserRuleContext context, string type, IEnumerable <ParserRuleContext> children = null)
        {
            int start, end;

            context.GetBounds(out start, out end);
            if (type == STRING)
            {
                ++start;
                --end;
            }

            var node = new ParserNode {
                Type = type, Start = start, End = end
            };

            if (children != null)
            {
                foreach (var child in children)
                {
                    Visit(child).Parent = node;
                }
            }
            return(node);
        }
Пример #7
0
		public void AddAttr(string type, string input, ParserRuleContext ctx)
		{
			var text = ctx.GetText(input);
			int start, end;
			ctx.GetBounds(out start, out end);
			AddAttrNode(type, text, start, end);
		}
Пример #8
0
		public void AddAttr(string type, ParserRuleContext ctx)
		{
			int start, end;
			ctx.GetBounds(out start, out end);
			AddAttrNode(type, null, start, end);
		}