private bool ParseChild() { if (Current.Type != TokenType.String) { return(false); } var name = Current.Value; int index = -1; if (name == "*") { return(false); } if (LA.Type == TokenType.LBracket) { var _ = MoveNext() && MoveNext() && ParseIndex(out index) && Require(TokenType.RBracket); } _result = _result.Element(name, index); return(true); }
// attr = '@' name private bool ParseAttribute() { if (Require(TokenType.String)) { _result = _result.Attribute(Current.Value); return(true); } return(false); }
private bool ParseDescendant() { if (Current.Type != TokenType.Asterisk) { return(false); } DomPath path = _result; return(MoveNext() && ParseHasAttribute()); }
internal bool Parse(out DomPath result) { _result = DomPath.Root; while (MoveNext() && ParseAxis()) { } result = _result; if (Current.Type == TokenType.EOF) { return(true); } return(Current.Type == TokenType.EOF); }
private bool ParseHasAttribute() { DomName name = null; var success = Require(TokenType.LBracket) && MoveNext() && Require(TokenType.AtSign) && MoveNext() && ParseName(out name); if (success && Current.Type == TokenType.EqualSign) { MoveNext(); _result = _result.DescendantHasAttributeValue(name, Current.Value); return(MoveNext()); } _result = _result.DescendantHasAttribute(name); return(success); }
public DomPathLeaf(DomPath parent, DomPathExpression expression) { _parent = parent; _expression = expression; }
public static bool TryParse(string text, out DomPath result) { var parser = new DomPathParser(text); return(parser.Parse(out result)); }