Methods
ast(id, …syntaxopt) → {AST}
A simple wrapper around AST#new. Creates a node from an id and zero-or-more syntax items.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
id |
string
|
the id of the new node |
|
syntax |
SyntaxArg
|
<optional> <repeatable> |
the id of the new node |
Type Definitions
ASTConf
A config object that an AST node may be constructed from
Properties:
Name | Type | Description |
---|---|---|
syntax |
Syntax
|
syntax objects. may be strings, AST nodes or arrays of these |
attrs |
object
|
attributes of this node, if any |
tags |
Tags
|
tags of this node, if any |
location |
object
|
location data |
Type:
-
Object
Nodes
An array of nodes, or a single node which may be null
Type:
QueryConf
A config object that a Query may be constructed from
Properties:
Name | Type | Description |
---|---|---|
id |
string
|
match against the id of the node |
tag |
string
|
Array.<string>
|
expect the node to have all the given tags |
leaf |
boolean
|
match only leaves |
stem |
boolean
|
match only stems |
root |
boolean
|
match only root |
- Source:
Type:
-
Object
QueryLit
A literal that a Query may be constructed from. Either a configuration object or a string representing a node id.
- Source:
Type:
-
string
|QueryConf
Syntax
An array of AST nodes, strings, and arrays of these
Type:
SyntaxArg
An AST node, string, or array of these
Type:
TraverseConf
A config object that a Traverse may be constructed from
Properties:
Name | Type | Description |
---|---|---|
id |
string
|
match against the id of the node |
tag |
string
|
Array.<string>
|
expect the node to have all the given tags |
leaf |
boolean
|
match only leaves |
stem |
boolean
|
match only stems |
root |
boolean
|
match only root |
depth |
number
|
limit depth of traversal. a negative number means no limit |
self |
boolean
|
include self in traversal |
first |
boolean
|
stop traversal on first match and return it, or null if no match |
last |
boolean
|
return only the last matched node, or null if no match |
up |
boolean
|
traverse upwards through this nodes ancestors |
- Source:
Type:
-
Object
TraverseLike
A Traverse object or TraverseLiteral
- Source:
Type:
TraverseLit
A literal that a Traverse may be constructed from. Either a configuration object or a string representing a node id.
- Source:
Type:
-
string
|TraverseConf
VisitorLike
A Visitor object or VisitorLit
- Source:
Type:
VisitorLit
A literal that a Visitor may be constructed from.
- Source: