CS Parser

Class: Composite

Composite()

The base class which provides the implementation of the Composite design pattern. A composite object can form a tree-like structure, the nodes or leaves of which are also composites

Constructor

new Composite()

Source:
Composite.js, line 5

Members

readonlyancestors Array.<Composite>

The ancestor composites ordered by closest to furthest

Source:
Composite.js, line 43

readonlyhasChild boolean

Whether this has one or more child composites

Source:
Composite.js, line 25

readonlyhasParent boolean

Whether this has parent composite

Source:
Composite.js, line 16

readonlylength number

The number of child composites

Source:
Composite.js, line 69

readonlyparent Composite

The parent composite

Source:
Composite.js, line 34

readonlyroot Composite

The root of composition

Source:
Composite.js, line 58

Methods

addChild(Cp) → Composite

Adds a child composite

Parameters:
Name Type Description
Cp Composite

The composite to add as a child

Source:
Composite.js, line 89
Returns:

This

Type:
Composite

addChildren(Cps) → Composite

Adds multiple child composites

Parameters:
Name Type Description
Cps Array.<Composite>

The array of the composites to add

Source:
Composite.js, line 106
Returns:

This

Type:
Composite

traverse(Fn, Depth, Arg) → boolean

Performs tree traversal

Parameters:
Name Type Default Description
Fn function

The callback that receives every descendant composite as the 1st parameter. If false is returned, the traversal will be aborted. The returned value other than false will be passed to the next traversal call of Fn as the 2nd parameter

Depth number -1

The limit of traversal depth. Negative number means no-limit

Arg mixed null

Additinal argument to pass to Fn as the 2nd parameter.

Source:
Composite.js, line 125
Returns:

true if the traversal is successfully completed. false if the traversal is aborted

Type:
boolean

verifyChild(Cp) → booleanstring

Determines whether the specified composite can be added as a child

Parameters:
Name Type Description
Cp Composite

The composite which is about to be added

Source:
Composite.js, line 80
Returns:

true if Cp is valid. Any type other than true means invalid. If a string is returned, it is shown as an error message in the debug console

Type:
boolean | string

© 2018 Satoshi Soma

Licensed under the Apache License 2.0

Documentation generated by JSDoc 3.6.11 using Docolatte theme on Tue, 05 Sep 2023 18:54:56 GMT

    Hint: You don't need to click on the search box to input.

    Just start typing your words at any time to search for it.

    Classes

    • Composite
      • addChild
      • addChildren
      • traverse
      • verifyChild
    • Context
      • addChild
      • addChildren
      • cleanupChildren
      • clearBuffer
      • end
      • outline
      • parseChunk
      • populate
      • start
      • step
      • traverse
      • updateState
      • verifyChild
    • ContextManager
      • feed
    • Main
      • create
      • newRule
    • Parser
      • addRule
      • addRules
      • onComplete
      • onStart
      • parse
      • parseFile
    • ResultSet
      • add
      • traverse
    • Rule
      • addChild
      • addChildren
      • endsWith
      • express
      • fin
      • init
      • on
      • parse
      • startsWith
      • traverse
      • verifyChild