Lr1::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 3
1
<?php
2
/**
3
 * This file is part of PHP-Yacc package.
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 */
8
declare(strict_types=1);
9
10
namespace PhpYacc\Lalr;
11
12
use PhpYacc\Grammar\Symbol;
13
14
/**
15
 * Class Lr1.
16
 */
17
class Lr1
18
{
19
    /**
20
     * @var Lr1|null
21
     */
22
    public $next;
23
24
    /**
25
     * @var Symbol|null
26
     */
27
    public $left;
28
29
    /**
30
     * @var Item
31
     */
32
    public $item;
33
34
    /**
35
     * @var BitSet
36
     */
37
    public $look;
38
39
    /**
40
     * Lr1 constructor.
41
     *
42
     * @param Symbol|null $left
43
     * @param BitSet      $look
44
     * @param Item        $item
45
     */
46
    public function __construct(Symbol $left = null, BitSet $look, Item $item)
47
    {
48
        $this->left = $left;
49
        $this->look = $look;
50
        $this->item = $item;
51
    }
52
53
    /**
54
     * @return bool
55
     */
56
    public function isTailItem(): bool
57
    {
58
        return $this->item->isTailItem();
59
    }
60
61
    /**
62
     * @return bool
63
     */
64
    public function isHeadItem(): bool
65
    {
66
        return $this->item->isHeadItem();
67
    }
68
69
    /**
70
     * @return string
71
     */
72
    public function dump(): string
73
    {
74
        $result = '';
75
        $lr1 = $this;
76
        while ($lr1 !== null) {
77
            $result .= $lr1->item."\n";
78
            $lr1 = $lr1->next;
79
        }
80
81
        return $result."\n";
82
    }
83
}
84