Skip to content

@dice-roller/rpg-dice-roller / Parser

Class: Parser โ€‹

Defined in: src/parser/Parser.ts:19

Parses dice notation into the AST.

See โ€‹

https://dice-roller.github.io/documentation/guide/notation/

Constructors โ€‹

Constructor โ€‹

new Parser(options?): Parser

Defined in: src/parser/Parser.ts:24

Creates a parser with the supplied literal quantity limit.

Parameters โ€‹

options? โ€‹

ParserOptions = {}

Returns โ€‹

Parser

Properties โ€‹

maxQty โ€‹

readonly maxQty: number

Defined in: src/parser/Parser.ts:21

Maximum literal pool quantity accepted by the grammar.

Methods โ€‹

parse() โ€‹

parse(notation): ExpressionNode

Defined in: src/parser/Parser.ts:37

Parses a notation string into an expression tree without rolling any dice.

Literal pool quantities are checked against maxQty; evaluated quantities are checked separately by the evaluator's roll limits.

Parameters โ€‹

notation โ€‹

string

Returns โ€‹

ExpressionNode

Throws โ€‹

the notation is empty or not a string

Throws โ€‹

the notation is invalid, with its source location and syntax error cause

MIT Licensed ยท Credits