Skip to main content
Module

x/ohm_js/index.d.ts>Node

A library and language for building parsers, interpreters, compilers, etc.
Go to Latest
interface Node
import { type Node } from "https://deno.land/x/ohm_js@v17.0.3/index.d.ts";

A node in the parse tree, passed to Action functions.

Index Signatures

[index: string]: any

Properties

children: Node[]

An array containing the node's children.

ctorName: string

The name of grammar rule that created the node.

source: Interval

Captures the portion of the input that was consumed by the node.

sourceString: string

Returns the contents of the input stream consumed by this node.

numChildren: number

The number of child nodes that the node has.

Methods

child(idx: number): Node

Returns the child at index idx.

isTerminal(): boolean

true if the node is a terminal node, otherwise false.

isIteration(): boolean

true if the node is an iteration node, which corresponds to a +, *, or ? expression in the grammar.

isOptional(): boolean

True if Node is ? option

asIteration(): IterationNode

A built-in operation which can convert certain NonterminalNodes into IterationNodes. This operation is defined for the built-in list rules (ListOf, EmptyListOf, NonemptyListOf, listOf, ...), and can also be defined for user-defined rules.