| @@ 3449-3471 (lines=23) @@ | ||
| 3446 | return $this->match(self::$literalCache[$what], $m, $eatWhitespace); |
|
| 3447 | } |
|
| 3448 | ||
| 3449 | protected function genericList(&$out, $parseItem, $delim="", $flatten=true) { |
|
| 3450 | $s = $this->seek(); |
|
| 3451 | $items = array(); |
|
| 3452 | while ($this->$parseItem($value)) { |
|
| 3453 | $items[] = $value; |
|
| 3454 | if ($delim) { |
|
| 3455 | if (!$this->literal($delim)) break; |
|
| 3456 | } |
|
| 3457 | } |
|
| 3458 | ||
| 3459 | if (count($items) == 0) { |
|
| 3460 | $this->seek($s); |
|
| 3461 | return false; |
|
| 3462 | } |
|
| 3463 | ||
| 3464 | if ($flatten && count($items) == 1) { |
|
| 3465 | $out = $items[0]; |
|
| 3466 | } else { |
|
| 3467 | $out = array("list", $delim, $items); |
|
| 3468 | } |
|
| 3469 | ||
| 3470 | return true; |
|
| 3471 | } |
|
| 3472 | ||
| 3473 | ||
| 3474 | // advance counter to next occurrence of $what |
|
| @@ 3126-3148 (lines=23) @@ | ||
| 3123 | return $this->genericList($out, "expression"); |
|
| 3124 | } |
|
| 3125 | ||
| 3126 | protected function genericList(&$out, $parseItem, $delim="", $flatten=true) { |
|
| 3127 | $s = $this->seek(); |
|
| 3128 | $items = array(); |
|
| 3129 | while ($this->$parseItem($value)) { |
|
| 3130 | $items[] = $value; |
|
| 3131 | if ($delim) { |
|
| 3132 | if (!$this->literal($delim)) break; |
|
| 3133 | } |
|
| 3134 | } |
|
| 3135 | ||
| 3136 | if (count($items) == 0) { |
|
| 3137 | $this->seek($s); |
|
| 3138 | return false; |
|
| 3139 | } |
|
| 3140 | ||
| 3141 | if ($flatten && count($items) == 1) { |
|
| 3142 | $out = $items[0]; |
|
| 3143 | } else { |
|
| 3144 | $out = array("list", $delim, $items); |
|
| 3145 | } |
|
| 3146 | ||
| 3147 | return true; |
|
| 3148 | } |
|
| 3149 | ||
| 3150 | protected function expression(&$out) { |
|
| 3151 | $s = $this->seek(); |
|