Parser

Handwritten parser to parse UnicodeSet patterns as an abstract syntax tree. Friendly error messages throughout

Constructor

new Parser()

Methods

(async) composed() → {Promise.<Node>}

A composition of set operations combining various other sets

Returns:
Type: 
Promise.<Node>

(async) enumerated() → {Promise.<Node>}

An enumeration of characters and strings

Returns:
Type: 
Promise.<Node>

(async) parse(pattern) → {Promise.<Node>}

Parse a UnicodeSet pattern into an abstract syntax tree (AST)

Parameters:
NameTypeDescription
patternstring

the pattern to parse

Returns:
Type: 
Promise.<Node>

peek_nonws() → (nullable) {string}

Peek the first non-whitespace character

Returns:
Type: 
string

(async) perlProperty() → {Promise.<Node>}

Extract node for Perl-style property

Returns:
Type: 
Promise.<Node>

pop_nonws() → (nullable) {string}

Pop the first non-whitespace character

Returns:
Type: 
string

(async) pop_nonws_quoted() → {Promise.<{char: string, quoted: boolean, length: number}>}

Pop non-whitespace, resolving quoted character(s) if needed

Returns:
Type: 
Promise.<{char: string, quoted: boolean, length: number}>

(async) posixProperty() → {Promise.<Node>}

Extract node for Posix-style property

Returns:
Type: 
Promise.<Node>

(async) property(invert, stop_char) → {Promise.<Node>}

Extract generic node for Perl/Posix property

Parameters:
NameTypeDescription
invertboolean

starting inverted state

stop_charstring

single character signaling end of property name-value definition

Returns:
Type: 
Promise.<Node>

(async) quoted() → {Promise.<{char: string, length: number}>}

Extract quoted character(s)

Returns:
Type: 
Promise.<{char: string, length: number}>

quotedCodepoint(length, list) → {Object}

Fetch a hex codepoint, optionally a list of such codepoints

Parameters:
NameTypeDescription
lengthnumber

how many hex chars are allowed for non lists

listboolean

whether a list of codepoints is allowed

Returns:
Type: 
Object

(async) quotedName() → {Promise.<{char: string, length: number}>}

Fetch name via unicode character name

Returns:
Type: 
Promise.<{char: string, length: number}>

root() → {Promise.<Node>}

Root set, enclosing all others

Returns:
Type: 
Promise.<Node>

(async) sequence() → {Promise.<Node>}

A sequence is surrounded by brackets, and contains either an enumerated or composed set

Returns:
Type: 
Promise.<Node>

(async) string() → {Promise.<{char: string, is_char: false, length: number}>}

Extract a string

Returns:
Type: 
Promise.<{char: string, is_char: false, length: number}>