| @@ 89-110 (lines=22) @@ | ||
| 86 | /** |
|
| 87 | * @return Ast\Term|Ast\Disjunction |
|
| 88 | */ |
|
| 89 | private function disjunction() |
|
| 90 | { |
|
| 91 | /** @var Ast\Term[] $terms */ |
|
| 92 | $terms = []; |
|
| 93 | $terms[] = $this->conjunction(); |
|
| 94 | ||
| 95 | if ($this->lexer->isNextToken(Tokens::T_SP)) { |
|
| 96 | $nextToken = $this->lexer->glimpse(); |
|
| 97 | if ($nextToken && $nextToken->is(Tokens::T_OR)) { |
|
| 98 | $this->match(Tokens::T_SP); |
|
| 99 | $this->match(Tokens::T_OR); |
|
| 100 | $this->match(Tokens::T_SP); |
|
| 101 | $terms[] = $this->conjunction(); |
|
| 102 | } |
|
| 103 | } |
|
| 104 | ||
| 105 | if (count($terms) == 1) { |
|
| 106 | return $terms[0]; |
|
| 107 | } |
|
| 108 | ||
| 109 | return new Ast\Disjunction($terms); |
|
| 110 | } |
|
| 111 | ||
| 112 | /** |
|
| 113 | * @return Ast\Conjunction|Ast\Factor |
|
| @@ 115-135 (lines=21) @@ | ||
| 112 | /** |
|
| 113 | * @return Ast\Conjunction|Ast\Factor |
|
| 114 | */ |
|
| 115 | private function conjunction() |
|
| 116 | { |
|
| 117 | $factors = []; |
|
| 118 | $factors[] = $this->factor(); |
|
| 119 | ||
| 120 | if ($this->lexer->isNextToken(Tokens::T_SP)) { |
|
| 121 | $nextToken = $this->lexer->glimpse(); |
|
| 122 | if ($nextToken && $nextToken->is(Tokens::T_AND)) { |
|
| 123 | $this->match(Tokens::T_SP); |
|
| 124 | $this->match(Tokens::T_AND); |
|
| 125 | $this->match(Tokens::T_SP); |
|
| 126 | $factors[] = $this->factor(); |
|
| 127 | } |
|
| 128 | } |
|
| 129 | ||
| 130 | if (count($factors) == 1) { |
|
| 131 | return $factors[0]; |
|
| 132 | } |
|
| 133 | ||
| 134 | return new Ast\Conjunction($factors); |
|
| 135 | } |
|
| 136 | ||
| 137 | /** |
|
| 138 | * @return Ast\Filter |
|