Global

Methods

ast(id, …syntaxopt) → {AST}

Description:
  • 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:

The created node

Type
AST

Type Definitions

ASTConf

Description:
  • A config object that an AST node may be constructed from

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

A config object that an AST node may be constructed from

Type:
  • Object

Nodes

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

Source:

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

Type:

QueryConf

Description:
  • A config object that a Query may be constructed from

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

A config object that a Query may be constructed from

Type:
  • Object

QueryLike

Description:
  • A Query object or QueryLiteral

Source:

A Query object or QueryLiteral

Type:

QueryLit

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

Source:

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

Type:

Syntax

Description:
  • An array of AST nodes, strings, and arrays of these

Source:

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

Type:

SyntaxArg

Description:
  • An AST node, string, or array of these

Source:

An AST node, string, or array of these

Type:

Tags

Description:
  • An array of strings or arrays of strings

Source:

An array of strings or arrays of strings

Type:
  • string | Array.<Tags>

TraverseConf

Description:
  • A config object that a Traverse may be constructed from

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

A config object that a Traverse may be constructed from

Type:
  • Object

TraverseLike

Description:
  • A Traverse object or TraverseLiteral

Source:

A Traverse object or TraverseLiteral

Type:

TraverseLit

Description:
  • A literal that a Traverse may be constructed from. Either a configuration object or a string representing a node id.

Source:

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

Type:

VisitorLike

Description:
  • A Visitor object or VisitorLit

Source:

A Visitor object or VisitorLit

Type:

VisitorLit

Description:
  • A literal that a Visitor may be constructed from.

Source:

A literal that a Visitor may be constructed from.

Type:

eachNode(node)

Description:
  • Called with each returned node.

Source:
Parameters:
Name Type Description
node AST