| @@ 119-145 (lines=27) @@ | ||
| 116 | $this->emit(Token::T_STRING, $string); |
|
| 117 | } |
|
| 118 | ||
| 119 | private function integerPart() |
|
| 120 | { |
|
| 121 | $number = $this->scanner->next(); |
|
| 122 | if ($number === '-') { |
|
| 123 | if ($this->scanner->eof()) { |
|
| 124 | throw $this->getError('Expected a digit but instead reached end'); |
|
| 125 | } |
|
| 126 | $next = $this->scanner->peek(); |
|
| 127 | if (ctype_digit($next) === false) { |
|
| 128 | throw $this->getError("Expected a digit but instead found \"{$next}\""); |
|
| 129 | } |
|
| 130 | } |
|
| 131 | ||
| 132 | $next = $this->scanner->peek(); |
|
| 133 | if ($next === '0') { |
|
| 134 | $number .= $this->scanner->next(); |
|
| 135 | return $number; |
|
| 136 | } |
|
| 137 | ||
| 138 | $next = $this->scanner->peek(); |
|
| 139 | while ($this->scanner->eof() === false && ctype_digit($next)) { |
|
| 140 | $number .= $this->scanner->next(); |
|
| 141 | $next = $this->scanner->peek(); |
|
| 142 | } |
|
| 143 | ||
| 144 | return $number; |
|
| 145 | } |
|
| 146 | ||
| 147 | private function fractionalPart() |
|
| 148 | { |
|
| @@ 169-194 (lines=26) @@ | ||
| 166 | return $part; |
|
| 167 | } |
|
| 168 | ||
| 169 | private function exponentPart() |
|
| 170 | { |
|
| 171 | $part = $this->scanner->next(); |
|
| 172 | ||
| 173 | if ($this->scanner->eof()) { |
|
| 174 | throw $this->getError('Expected a digit but instead reached end'); |
|
| 175 | } |
|
| 176 | ||
| 177 | $next = $this->scanner->peek(); |
|
| 178 | if ($next === '+' || $next === '-') { |
|
| 179 | $part .= $this->scanner->next(); |
|
| 180 | } |
|
| 181 | ||
| 182 | $next = $this->scanner->peek(); |
|
| 183 | if (ctype_digit($next) === false) { |
|
| 184 | throw $this->getError("Expected a digit but instead found \"{$next}\""); |
|
| 185 | } |
|
| 186 | ||
| 187 | $next = $this->scanner->peek(); |
|
| 188 | while ($this->scanner->eof() === false && ctype_digit($next)) { |
|
| 189 | $part .= $this->scanner->next(); |
|
| 190 | $next = $this->scanner->peek(); |
|
| 191 | } |
|
| 192 | ||
| 193 | return $part; |
|
| 194 | } |
|
| 195 | ||
| 196 | private function number() |
|
| 197 | { |
|