0.1.4 • Published 4 years ago
@astql/parser v0.1.4
@astq;/parser is a library using peggy(or pegjs) for parsing a string for patterns of syntax similar to a CSS style selector system
and returns an abstract syntax tree of the query selector.
The following selectors are supported:
- AST node type:
ForStatement - wildcard:
* - attribute existence:
[attr] - attribute value:
[attr="foo"]or[attr=123] - attribute regex:
[attr=/foo.*/]or (with flags)[attr=/foo.*/is] - attribute conditions:
[attr!="foo"],[attr>2],[attr<3],[attr>=2], or[attr<=3] - nested attribute:
[attr.level2="foo"] - field:
FunctionDeclaration > Identifier.id - First or last child:
:first-childor:last-child - nth-child (no ax+b support):
:nth-child(2) - nth-last-child (no ax+b support):
:nth-last-child(1) - descendant:
ancestor descendant - child:
parent > child - following sibling:
node ~ sibling - adjacent sibling:
node + adjacent - negation:
:not(ForStatement) - has:
:has(ForStatement) - matches-any:
:matches([attr] > :first-child, :last-child) - subject indicator:
!IfStatement > [name="foo"] - class of AST node:
:statement,:expression,:declaration,:function, or:pattern
