示例#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
            });
        }
        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);
		}