| @@ 135-157 (lines=23) @@ | ||
| 132 | } |
|
| 133 | } |
|
| 134 | ||
| 135 | protected function get() {
|
|
| 136 | $c = $this->lookAhead; |
|
| 137 | $this->lookAhead = null; |
|
| 138 | ||
| 139 | if ($c === null) {
|
|
| 140 | if ($this->inputIndex < $this->inputLength) {
|
|
| 141 | $c = $this->input[$this->inputIndex]; |
|
| 142 | $this->inputIndex += 1; |
|
| 143 | } else {
|
|
| 144 | $c = null; |
|
| 145 | } |
|
| 146 | } |
|
| 147 | ||
| 148 | if ($c === "\r") {
|
|
| 149 | return "\n"; |
|
| 150 | } |
|
| 151 | ||
| 152 | if ($c === null || $c === "\n" || ord($c) >= self::ORD_SPACE) {
|
|
| 153 | return $c; |
|
| 154 | } |
|
| 155 | ||
| 156 | return ' '; |
|
| 157 | } |
|
| 158 | ||
| 159 | protected function isAlphaNum($c) {
|
|
| 160 | return ord($c) > 126 || $c === '\\' || preg_match('/^[\w\$]$/', $c) === 1;
|
|
| @@ 311-331 (lines=21) @@ | ||
| 308 | * |
|
| 309 | * @return string |
|
| 310 | */ |
|
| 311 | protected function get() |
|
| 312 | {
|
|
| 313 | $c = $this->lookAhead; |
|
| 314 | $this->lookAhead = null; |
|
| 315 | if ($c === null) {
|
|
| 316 | // getc(stdin) |
|
| 317 | if ($this->inputIndex < $this->inputLength) {
|
|
| 318 | $c = $this->input[$this->inputIndex]; |
|
| 319 | $this->inputIndex += 1; |
|
| 320 | } else {
|
|
| 321 | $c = null; |
|
| 322 | } |
|
| 323 | } |
|
| 324 | if (ord($c) >= self::ORD_SPACE || $c === "\n" || $c === null) {
|
|
| 325 | return $c; |
|
| 326 | } |
|
| 327 | if ($c === "\r") {
|
|
| 328 | return "\n"; |
|
| 329 | } |
|
| 330 | return ' '; |
|
| 331 | } |
|
| 332 | ||
| 333 | /** |
|
| 334 | * Does $a indicate end of input? |
|
| @@ 321-341 (lines=21) @@ | ||
| 318 | * |
|
| 319 | * @return string |
|
| 320 | */ |
|
| 321 | protected function get() |
|
| 322 | { |
|
| 323 | $c = $this->lookAhead; |
|
| 324 | $this->lookAhead = null; |
|
| 325 | if ($c === null) { |
|
| 326 | // getc(stdin) |
|
| 327 | if ($this->inputIndex < $this->inputLength) { |
|
| 328 | $c = $this->input[$this->inputIndex]; |
|
| 329 | $this->inputIndex += 1; |
|
| 330 | } else { |
|
| 331 | $c = null; |
|
| 332 | } |
|
| 333 | } |
|
| 334 | if (ord($c) >= self::ORD_SPACE || $c === "\n" || $c === null) { |
|
| 335 | return $c; |
|
| 336 | } |
|
| 337 | if ($c === "\r") { |
|
| 338 | return "\n"; |
|
| 339 | } |
|
| 340 | return ' '; |
|
| 341 | } |
|
| 342 | ||
| 343 | /** |
|
| 344 | * Does $a indicate end of input? |
|