' expr", "expr : expr T_IS_GREATER_OR_EQUAL expr", "expr : expr T_INSTANCEOF class_name_reference", "expr : '(' expr ')'", "expr : expr '?' expr ':' expr", "expr : expr '?' ':' expr", "expr : T_ISSET '(' variables_list ')'", "expr : T_EMPTY '(' variable ')'", "expr : T_INCLUDE expr", "expr : T_INCLUDE_ONCE expr", "expr : T_EVAL '(' expr ')'", "expr : T_REQUIRE expr", "expr : T_REQUIRE_ONCE expr", "expr : T_INT_CAST expr", "expr : T_DOUBLE_CAST expr", "expr : T_STRING_CAST expr", "expr : T_ARRAY_CAST expr", "expr : T_OBJECT_CAST expr", "expr : T_BOOL_CAST expr", "expr : T_UNSET_CAST expr", "expr : T_EXIT exit_expr", "expr : '@' expr", "expr : scalar", "expr : T_ARRAY '(' array_pair_list ')'", "expr : '`' backticks_expr '`'", "expr : T_PRINT expr", "expr : T_FUNCTION optional_ref '(' parameter_list ')' lexical_vars '{' inner_statement_list '}'", "lexical_vars : /* empty */", "lexical_vars : T_USE '(' lexical_var_list ')'", "lexical_var_list : lexical_var_list ',' optional_ref T_VARIABLE", "lexical_var_list : optional_ref T_VARIABLE", "function_call : name '(' function_call_argument_list ')'", "function_call : class_name T_PAAMAYIM_NEKUDOTAYIM T_STRING '(' function_call_argument_list ')'", "function_call : reference_variable T_PAAMAYIM_NEKUDOTAYIM T_STRING '(' function_call_argument_list ')'", "function_call : static_property_with_arrays '(' function_call_argument_list ')'", "function_call : variable_without_objects '(' function_call_argument_list ')'", "class_name : T_STATIC", "class_name : name", "name : namespace_name", "name : T_NAMESPACE T_NS_SEPARATOR namespace_name", "name : T_NS_SEPARATOR namespace_name", "class_name_reference : class_name", "class_name_reference : dynamic_class_name_reference", "dynamic_class_name_reference : object_access_for_dcnr", "dynamic_class_name_reference : base_variable", "object_access_for_dcnr : /* empty */", "object_access_for_dcnr : base_variable T_OBJECT_OPERATOR object_property", "object_access_for_dcnr : object_access_for_dcnr T_OBJECT_OPERATOR object_property", "object_access_for_dcnr : object_access_for_dcnr '[' dim_offset ']'", "object_access_for_dcnr : object_access_for_dcnr '{' expr '}'", "exit_expr : /* empty */", "exit_expr : '(' ')'", "exit_expr : '(' expr ')'", "backticks_expr : /* empty */", "backticks_expr : T_ENCAPSED_AND_WHITESPACE", "backticks_expr : encaps_list", "ctor_arguments : /* empty */", "ctor_arguments : '(' function_call_argument_list ')'", "common_scalar : T_LNUMBER", "common_scalar : T_DNUMBER", "common_scalar : T_CONSTANT_ENCAPSED_STRING", "common_scalar : T_LINE", "common_scalar : T_FILE", "common_scalar : T_DIR", "common_scalar : T_CLASS_C", "common_scalar : T_METHOD_C", "common_scalar : T_FUNC_C", "common_scalar : T_NS_C", "common_scalar : T_START_HEREDOC T_ENCAPSED_AND_WHITESPACE T_END_HEREDOC", "common_scalar : T_START_HEREDOC T_END_HEREDOC", "static_scalar : common_scalar", "static_scalar : name", "static_scalar : '+' static_scalar", "static_scalar : '-' static_scalar", "static_scalar : T_ARRAY '(' static_array_pair_list ')'", "static_scalar : class_name T_PAAMAYIM_NEKUDOTAYIM T_STRING", "scalar : T_STRING_VARNAME", "scalar : class_constant", "scalar : name", "scalar : common_scalar", "scalar : '\"' encaps_list '\"'", "scalar : T_START_HEREDOC encaps_list T_END_HEREDOC", "static_array_pair_list : /* empty */", "static_array_pair_list : non_empty_static_array_pair_list optional_comma", "optional_comma : /* empty */", "optional_comma : ','", "non_empty_static_array_pair_list : non_empty_static_array_pair_list ',' static_array_pair", "non_empty_static_array_pair_list : static_array_pair", "static_array_pair : static_scalar T_DOUBLE_ARROW static_scalar", "static_array_pair : static_scalar", "variable : object_access", "variable : base_variable", "variable : function_call", "object_access : object_access_arrayable", "object_access : object_access_arrayable '(' function_call_argument_list ')'", "object_access : variable T_OBJECT_OPERATOR object_property '(' function_call_argument_list ')'", "object_access_arrayable : variable T_OBJECT_OPERATOR object_property", "object_access_arrayable : object_access_arrayable '[' dim_offset ']'", "object_access_arrayable : object_access_arrayable '{' expr '}'", "variable_without_objects : reference_variable", "variable_without_objects : '$' reference_variable", "base_variable : variable_without_objects", "base_variable : class_name T_PAAMAYIM_NEKUDOTAYIM '$' reference_variable", "base_variable : reference_variable T_PAAMAYIM_NEKUDOTAYIM '$' reference_variable", "base_variable : static_property_with_arrays", "static_property_with_arrays : class_name T_PAAMAYIM_NEKUDOTAYIM T_VARIABLE", "static_property_with_arrays : reference_variable T_PAAMAYIM_NEKUDOTAYIM T_VARIABLE", "static_property_with_arrays : class_name T_PAAMAYIM_NEKUDOTAYIM '$' '{' expr '}'", "static_property_with_arrays : reference_variable T_PAAMAYIM_NEKUDOTAYIM '$' '{' expr '}'", "static_property_with_arrays : static_property_with_arrays '[' dim_offset ']'", "static_property_with_arrays : static_property_with_arrays '{' expr '}'", "reference_variable : reference_variable '[' dim_offset ']'", "reference_variable : reference_variable '{' expr '}'", "reference_variable : T_VARIABLE", "reference_variable : '$' '{' expr '}'", "dim_offset : /* empty */", "dim_offset : expr", "object_property : T_STRING", "object_property : '{' expr '}'", "object_property : variable_without_objects", "assignment_list : assignment_list ',' assignment_list_element", "assignment_list : assignment_list_element", "assignment_list_element : variable", "assignment_list_element : T_LIST '(' assignment_list ')'", "assignment_list_element : /* empty */", "array_pair_list : /* empty */", "array_pair_list : non_empty_array_pair_list optional_comma", "non_empty_array_pair_list : non_empty_array_pair_list ',' array_pair", "non_empty_array_pair_list : array_pair", "array_pair : expr T_DOUBLE_ARROW expr", "array_pair : expr", "array_pair : expr T_DOUBLE_ARROW '&' variable", "array_pair : '&' variable", "encaps_list : encaps_list encaps_var", "encaps_list : encaps_list T_ENCAPSED_AND_WHITESPACE", "encaps_list : encaps_var", "encaps_list : T_ENCAPSED_AND_WHITESPACE encaps_var", "encaps_var : T_VARIABLE", "encaps_var : T_VARIABLE '[' encaps_var_offset ']'", "encaps_var : T_VARIABLE T_OBJECT_OPERATOR T_STRING", "encaps_var : T_DOLLAR_OPEN_CURLY_BRACES expr '}'", "encaps_var : T_DOLLAR_OPEN_CURLY_BRACES T_STRING_VARNAME '[' expr ']' '}'", "encaps_var : T_CURLY_OPEN variable '}'", "encaps_var_offset : T_STRING", "encaps_var_offset : T_NUM_STRING", "encaps_var_offset : T_VARIABLE", "class_constant : class_name T_PAAMAYIM_NEKUDOTAYIM T_STRING", "class_constant : reference_variable T_PAAMAYIM_NEKUDOTAYIM T_STRING" ); protected function yyprintln($msg) { echo $msg, "\n"; } protected function YYTRACE_NEWSTATE($state, $sym) { $this->yyprintln( '% State ' . $state . ', Lookahead ' . ($sym < 0 ? '--none--' : self::$yyterminals[$sym]) ); } protected function YYTRACE_READ($sym) { $this->yyprintln('% Reading ' . self::$yyterminals[$sym]); } protected function YYTRACE_SHIFT($sym) { $this->yyprintln('% Shift ' . self::$yyterminals[$sym]); } protected function YYTRACE_ACCEPT() { $this->yyprintln('% Accepted.'); } protected function YYTRACE_REDUCE($n) { $this->yyprintln('% Reduce by (' . $n . ') ' . self::$yyproduction[$n]); } protected function YYTRACE_POP($state) { $this->yyprintln('% Recovering, uncovers state ' . $state); } protected function YYTRACE_DISCARD($sym) { $this->yyprintln('% Discard ' . self::$yyterminals[$sym]); } /** * Parses PHP code into a node tree and prints out debugging information. * * @param PHPParser_Lexer $lexer A lexer * * @return array Array of statements */ public function parse(PHPParser_Lexer $lexer) { $this->lexer = $lexer; $this->yysp = 0; // Stack pos $yysstk = array($yystate = 0); // State stack $this->yyastk = array(); // AST stack (?) $yylstk = array($yyline = 1); // Line stack $yydstk = array($yyDC = null); // Doc comment stack $yychar = -1; for (;;) { $this->YYTRACE_NEWSTATE($yystate, $yychar); if (self::$yybase[$yystate] == 0) { $yyn = self::$yydefault[$yystate]; } else { if ($yychar < 0) { if (($yychar = $lexer->lex($yylval, $yyline, $yyDC)) < 0) $yychar = 0; $yychar = $yychar < self::YYMAXLEX ? self::$yytranslate[$yychar] : self::YYBADCH; $yylstk[$this->yysp] = $yyline; $yydstk[$this->yysp] = $yyDC; $this->YYTRACE_READ($yychar); } if ((($yyn = self::$yybase[$yystate] + $yychar) >= 0 && $yyn < self::YYLAST && self::$yycheck[$yyn] == $yychar || ($yystate < self::YY2TBLSTATE && ($yyn = self::$yybase[$yystate + self::YYNLSTATES] + $yychar) >= 0 && $yyn < self::YYLAST && self::$yycheck[$yyn] == $yychar)) && ($yyn = self::$yyaction[$yyn]) != self::YYDEFAULT) { /* * >= YYNLSTATE: shift and reduce * > 0: shift * = 0: accept * < 0: reduce * = -YYUNEXPECTED: error */ if ($yyn > 0) { /* shift */ $this->YYTRACE_SHIFT($yychar); ++$this->yysp; $yysstk[$this->yysp] = $yystate = $yyn; $this->yyastk[$this->yysp] = $yylval; $yylstk[$this->yysp] = $yyline; $yydstk[$this->yysp] = $yyDC; $yychar = -1; if ($yyn < self::YYNLSTATES) continue; /* $yyn >= YYNLSTATES means shift-and-reduce */ $yyn -= self::YYNLSTATES; } else { $yyn = -$yyn; } } else { $yyn = self::$yydefault[$yystate]; } } for (;;) { /* reduce/error */ if ($yyn == 0) { /* accept */ $this->YYTRACE_ACCEPT(); return $this->yyval; } elseif ($yyn != self::YYUNEXPECTED) { /* reduce */ $this->YYTRACE_REDUCE($yyn); try { $this->{'yyn' . $yyn}( $yylstk[$this->yysp - self::$yylen[$yyn]], $yydstk[$this->yysp - self::$yylen[$yyn]] ); } catch (PHPParser_Error $e) { $e->setRawLine($yyline); throw $e; } /* Goto - shift nonterminal */ $this->yysp -= self::$yylen[$yyn]; $yyn = self::$yylhs[$yyn]; if (($yyp = self::$yygbase[$yyn] + $yysstk[$this->yysp]) >= 0 && $yyp < self::YYGLAST && self::$yygcheck[$yyp] == $yyn) { $yystate = self::$yygoto[$yyp]; } else { $yystate = self::$yygdefault[$yyn]; } ++$this->yysp; $yysstk[$this->yysp] = $yystate; $this->yyastk[$this->yysp] = $this->yyval; $yylstk[$this->yysp] = $yyline; $yydstk[$this->yysp] = $yyDC; } else { /* error */ throw new PHPParser_Error( 'Unexpected token ' . self::$yyterminals[$yychar], $yyline ); } if ($yystate < self::YYNLSTATES) break; /* >= YYNLSTATES means shift-and-reduce */ $yyn = $yystate - self::YYNLSTATES; } } } }