Global

Methods

ast(id, …syntaxopt) → {AST}

A simple wrapper around AST#new. Creates a node from an id and zero-or-more syntax items.

Source:
Parameters:
Name Type Attributes Description
id string

the id of the new node

syntax SyntaxArg <optional>
<repeatable>

the id of the new node

Returns:
Type:
AST

The created 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

Source:
Type:
  • Object

eachNode(node)

Called with each returned node.

Source:
Parameters:
Name Type Description
node AST

Nodes

An array of nodes, or a single node which may be null

Source:
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

QueryLike

A Query object or QueryLiteral

Source:
Type:

QueryLit

A literal that a Query may be constructed from. Either a configuration object or a string representing a node id.

Source:
Type:

Syntax

An array of AST nodes, strings, and arrays of these

Source:
Type:

SyntaxArg

An AST node, string, or array of these

Source:
Type:

Tags

An array of strings or arrays of strings

Source:
Type:
  • string | Array.<(string|Tags)>

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:

VisitorLike

A Visitor object or VisitorLit

Source:
Type:

VisitorLit

A literal that a Visitor may be constructed from.

Source:
Type: