public void AddAttr(string type, ParserRuleContext ctx) { int start, end; ctx.GetBounds(out start, out end); AddAttrNode(type, null, start, end); }
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); }
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); }
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)); }
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); }