src/Parser.php
public function parseFor() {
        // consume required tokens
        $for_open_token = $this->pop('FOR_OPEN');
        $this->currLine++;

        // create output so far
        $output = '$for_index = 0; foreach(' . 
            $for_open_token[1][1] . ' as ' . 
            $for_open_token[1][0] . ') {' . "\n";

        while(true) {
            list($type, $value) = $this->peek();

            if($type == 'FOR_CLOSE') {
                // pop the element, and add the value
                $this->pop();
                $output .= '$for_index++; }' . "\n";
                $this->currLine++;
                break;
            } else {
                $output .= $this->parseExpression();
            }
        }

        return $output;
    }
public function parseFor() {
        // consume required tokens
        $for_open_token = $this->pop('FOR_OPEN');
        $this->currLine++;

        // create output so far
        $output = '$for_index = 0; foreach(' . 
            $for_open_token[1][1] . ' as ' . 
            $for_open_token[1][0] . ') {' . "\n";

        while(true) {
            list($type, $value) = $this->peek();

            if($type == 'FOR_CLOSE') {
                // pop the element, and add the value
                $this->pop();
                $output .= '$for_index++; }' . "\n";
                $this->currLine++;
                break;
            } else {
                $output .= $this->parseExpression();
            }
        }

        return $output;
    }
Parses a FOR expression