Class: Rep

page.EBNFP. Rep

Represents an iteration for EBNFP.


<private> new Rep(_node, _min, _max)

Creates a new representation of an iteration for EBNFP.

Parameters:
Name Type Description
_node epNode

body.

_min number

minimum number of occurences, 0 or 1.

_max number

maximum number of occurences, 1 or undefined.

Properties:
Name Type Description
node epNode

body.

min number

minimum number of occurences, 0 or 1.

max number

maximum number of occurences, 1 or undefined.

nt page.BNF.NT

corresponding non-terminal for BNF.

empty boolean

true if no input can be accepted.

first Map

terminals at front, maps ord to page.BNF.T.

follow Map

terminals following, maps ord to page.BNF.T.

Source:
Example
some: item +;
many: item *;
optional: item ?;

Methods


<private> toBNF(_grammar [, _nt])

Called once by page.EBNFP#init to recursively translate into BNF.

a+
a*
a?

where .min and .max are 1:undefined, 0:undefined, or 0:1, respectively, and are translated to

$#: a $## %prec error;  # .min == 1
$##: %prec error;
$##: $## a;
$##: $## error;

$#: $##  %prec error;   # if left-hand side is known
$##: %prec error;       # .min == 0
$##: $## a;
$##: $## error;

$#: %prec error;        # .min == 0, .max == 1
$#: a;

error depends on _grammar.recover and %prec error is inserted if the grammar specifies %right error.

Parameters:
Name Type Argument Description
_grammar page.EBNFP

object to which the construct belongs.

_nt page.EBNF.NT <optional>

left-hand side, if known; avoids the need for a fresh non-terminal.

Source:
Returns:

non-terminal representing the translated construct.

Type
page.BNF.NT