/** * Parse do-while loop * * do { ... } while(<expr>) * * @param CodeGenerator $codeGenerator * @throws EndOfFileException * @throws ParserError * @throws PrecedenceException */ public function parse_do(CodeGenerator $codeGenerator) { // 'do' eaten $token = $this->scanner->next(); $bodyCode = new CodeGenerator($codeGenerator->getIndent() + 1, $codeGenerator->getScope()); if ($token['code'] == T_LCURLY_PARENTHESIS) { $this->parse_body($bodyCode); $this->check(T_RCURLY_PARENTHESIS); } else { $this->scanner->back(); $this->parser_command($bodyCode); } $this->check(T_WHILE); $prec = new Precedence($this->scanner); $prec->run(); //$codeGenerator->addVariables($prec->getUsedVariables()); $ifExpr = new ExprGenerator($prec->getData(), $codeGenerator->getScope()); $codeGenerator->addDoWhile($ifExpr, $bodyCode); }