-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEpsilonParser.php
More file actions
52 lines (46 loc) · 902 Bytes
/
Copy pathEpsilonParser.php
File metadata and controls
52 lines (46 loc) · 902 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
namespace petitparser;
/**
* A parser that consumes nothing and succeeds.
*/
class EpsilonParser extends Parser
{
/**
* @var mixed
*/
protected $_result;
/**
* @param mixed $result
*/
public function __construct($result)
{
$this->_result = $result;
}
/**
* @param Context $context
*
* @return Result
*/
public function parseOn(Context $context)
{
return $context->success($this->_result);
}
/**
* @inheritdoc
*/
public function copy()
{
return new EpsilonParser($this->_result);
}
/**
* @param Parser $other
*
* @return bool
*/
public function hasEqualProperties(Parser $other)
{
return parent::hasEqualProperties($other)
&& $other instanceof self
&& $this->_result == $other->_result;
}
}