Parser

Parser

Context sensitive parser

Constructor

new Parser(Rl)

Source:
Parameters:
Name Type Default Description
Rl object | Rule null

The root rule

Methods

addRule(Rl) → {Rule}

Adds a new rule

Source:
Parameters:
Name Type Description
Rl object | Rule

The rule to add

Returns:
Type:
Rule

The Rule object which has peen added

addRules(Rls) → {Array.<Rule>}

Adds multiple new rules

Source:
Parameters:
Name Type Description
Rls Array.<object> | Array.<Rule>

An array of the rules to add

Returns:
Type:
Array.<Rule>

An array of Rule objects which have been added

(protected) onComplete(Cx)

Source:
Parameters:
Name Type Description
Cx Context

The finished context

(protected) onStart(Cx)

Source:
Parameters:
Name Type Description
Cx Context

The root context

parse(Data) → {Context}

Parses the data specified as a string or Buffer. After the parsing completed, returns the root context which contains all the generated sub-contexts through the entire parsing

Source:
Parameters:
Name Type Description
Data string | Buffer

The data to be parsed

Returns:
Type:
Context

The root context

parseFile(Url, Opt) → {Promise}

Parses a file asynchronously

Source:
See:
Parameters:
Name Type Default Description
Url string

The file URL

Opt object null

Streaming options

Returns:
Type:
Promise

A Promise that will resolve when the parsing completes. You can get the root context as the 1st parameter of a callback which you can pass to .then()