ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
ILIAS\Refinery\Parser\ABNF\Intermediate Class Reference
+ Collaboration diagram for ILIAS\Refinery\Parser\ABNF\Intermediate:

Public Member Functions

 __construct (string $todo, array $accepted=[])
 
 value ()
 
 accept ()
 
 push (array $values)
 
 reject ()
 
 accepted ()
 
 done ()
 
 onlyTodo ()
 
 transform (Closure $transform)
 Calls the given closure with all accepted values. More...
 

Private Attributes

string $todo
 
array $accepted
 

Detailed Description

Definition at line 28 of file Intermediate.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Refinery\Parser\ABNF\Intermediate::__construct ( string  $todo,
array  $accepted = [] 
)

Member Function Documentation

◆ accept()

ILIAS\Refinery\Parser\ABNF\Intermediate::accept ( )

Definition at line 44 of file Intermediate.php.

References ILIAS\Refinery\Parser\ABNF\Intermediate\accepted(), and ILIAS\Refinery\Parser\ABNF\Intermediate\push().

Referenced by ILIAS\Refinery\Parser\ABNF\Primitives\eq(), ILIAS\Refinery\Parser\ABNF\Brick\range(), ILIAS\Tests\Refinery\Parser\ABNF\TransformTest\testAs(), ILIAS\Tests\Refinery\Parser\ABNF\TransformTest\testFailedToTransform(), and ILIAS\Tests\Refinery\Parser\ABNF\TransformTest\testTo().

44  : Result
45  {
46  return new Ok((new self(
47  substr($this->todo, 1),
48  $this->accepted()
49  ))->push([new Character(substr($this->todo, 0, 1))]));
50  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ accepted()

◆ done()

ILIAS\Refinery\Parser\ABNF\Intermediate::done ( )

Definition at line 70 of file Intermediate.php.

References ILIAS\Refinery\Parser\ABNF\Intermediate\$todo.

Referenced by ILIAS\Refinery\Parser\ABNF\Brick\consume().

70  : bool
71  {
72  return '' === $this->todo;
73  }
+ Here is the caller graph for this function:

◆ onlyTodo()

ILIAS\Refinery\Parser\ABNF\Intermediate::onlyTodo ( )

Definition at line 75 of file Intermediate.php.

References ILIAS\Refinery\Parser\ABNF\Intermediate\$todo.

Referenced by ILIAS\Refinery\Parser\ABNF\Transform\combine(), and ILIAS\Refinery\Parser\ABNF\Transform\from().

75  : self
76  {
77  return new self($this->todo);
78  }
+ Here is the caller graph for this function:

◆ push()

ILIAS\Refinery\Parser\ABNF\Intermediate::push ( array  $values)

Definition at line 52 of file Intermediate.php.

References ILIAS\Refinery\Parser\ABNF\Intermediate\$todo, and ILIAS\Refinery\Parser\ABNF\Intermediate\accepted().

Referenced by ILIAS\Refinery\Parser\ABNF\Intermediate\accept().

52  : self
53  {
54  return new self(
56  array_merge($this->accepted, $values)
57  );
58  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ reject()

ILIAS\Refinery\Parser\ABNF\Intermediate::reject ( )

Definition at line 60 of file Intermediate.php.

Referenced by ILIAS\Refinery\Parser\ABNF\Primitives\eq(), ILIAS\Refinery\Parser\ABNF\Brick\range(), and ILIAS\Tests\Refinery\Parser\ABNF\TransformTest\testFailedToParse().

60  : Result
61  {
62  return new Error('Rejected.');
63  }
+ Here is the caller graph for this function:

◆ transform()

ILIAS\Refinery\Parser\ABNF\Intermediate::transform ( Closure  $transform)

Calls the given closure with all accepted values.

For convenience the $accepted values are transformed to a string when they are a Character[]. Unprocessed characters are wrapped with the Character class to prevent the need for a conversion from a character list (e.g. ['a', 'b'] ) to a string ("ab"), because it's not nice to operate on single length string lists instead of strings.

A

Parameters
Closure(string|A[])Result $transform
Returns
Result

Definition at line 89 of file Intermediate.php.

References $data, and ILIAS\Refinery\Parser\ABNF\Intermediate\accepted().

Referenced by ILIAS\Refinery\Parser\ABNF\Brick\apply(), and ILIAS\Refinery\Parser\ABNF\Transform\from().

89  : Result
90  {
91  $string = '';
92  foreach ($this->accepted as $data) {
93  if (!$data instanceof Character) {
94  return $transform($this->accepted);
95  }
96  $string .= $data->value();
97  }
98 
99  return $transform($string);
100  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ value()

ILIAS\Refinery\Parser\ABNF\Intermediate::value ( )

Definition at line 39 of file Intermediate.php.

Referenced by ILIAS\Refinery\Parser\ABNF\Primitives\eq(), and ILIAS\Refinery\Parser\ABNF\Brick\range().

39  : int
40  {
41  return ord($this->todo);
42  }
+ Here is the caller graph for this function:

Field Documentation

◆ $accepted

array ILIAS\Refinery\Parser\ABNF\Intermediate::$accepted
private

◆ $todo


The documentation for this class was generated from the following file: