Search


Search something to see results

AstArenaNode

Object view of an arena node or token, returned by AstArena.toObject. The view does not copy the data: its properties are getters and setters that read and write the arena columns. A view only holds the arena and the node id (ARENAID).

  • the properties are the properties of the plain objects (PlainAstNode, PlainToken): typ, nam, sel, val, chi, tokens, unit, kin, l, r, op, ... and loc, state, errors, parent,
  • the nodes and tokens (children, value tokens, fields) are returned as new views in a frozen array. the arrays, the locations (loc) and the error lists (errors) cannot be modified (modifying them throws in strict mode): assign the property to modify the arena (node.chi = [...node.chi, rule]),
  • the values assigned can be node ids, views or plain objects. importing a view of the same arena is a noop: the node is used as is, the views of another arena are copied,
  • two views of the same node are different objects: compare their ARENAID,
  • JSON.stringify() and toJSON() return a deep plain copy (AstArena.toPlainObject).
function visitor(arena: AstArena, id: number) {

const node = arena.toObject(id);

if (node.nam == 'width') {

node.nam = 'height';
node.val = [{typ: EnumToken.LengthTokenType, val: 3, unit: 'px'}];
}
}

Index

Accessors

Constructors

Methods

Properties

  • get unit(): string | undefined

    unit of a dimension, calendar (cal) of a color, attribute (attr) of a match expression

    Returns string | undefined

  • set unit(unit: string | null | undefined): void

    Parameters

    • unit: string | null | undefined

    Returns void

Parameters

Returns AstArenaNode

deep plain copy of the node, see AstArena.toPlainObject

Returns PlainAstNode | PlainToken

"[ARENA]": AstArena

arena of the node

"[ARENAID]": number

node id in the arena