/** * Parse while loop * * while(<expr>) { ... } * * @param CodeGenerator $codeGenerator * @throws EndOfFileException * @throws ParserError * @throws PrecedenceException */ public function parse_while(CodeGenerator $codeGenerator) { // 'while' eaten $prec = new Precedence($this->scanner); $prec->run(); //$codeGenerator->addVariables($prec->getUsedVariables()); $ifExpr = new ExprGenerator($prec->getData(), $codeGenerator->getScope()); $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); } $codeGenerator->addWhile($ifExpr, $bodyCode); }