[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/phps-mode 5d77b9b: Improved imenu generation, comment/u
From: |
Christian Johansson |
Subject: |
[elpa] externals/phps-mode 5d77b9b: Improved imenu generation, comment/uncomment and more work on Wisent |
Date: |
Sat, 5 Oct 2019 04:15:28 -0400 (EDT) |
branch: externals/phps-mode
commit 5d77b9bda38bed1f352178754d38115d2b26055a
Author: Christian Johansson <address@hidden>
Commit: Christian Johansson <address@hidden>
Improved imenu generation, comment/uncomment and more work on Wisent
---
.gitignore | 1 +
admin/phps-mode-automation-header.wy | 8 +-
admin/phps-mode-automation.el | 37 +-
phps-mode-analyzer.el | 24 +-
phps-mode-wy-macros.el | 110 ++++
phps-mode-wy-wy.el | 92 ++++
phps-mode-wy.wy | 981 +++++++++++++++++++++++++++++++++++
test/phps-mode-test-functions.el | 42 +-
8 files changed, 1246 insertions(+), 49 deletions(-)
diff --git a/.gitignore b/.gitignore
index c531d98..034d56c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,2 @@
*.elc
+admin/zend_language_parser.y
diff --git a/admin/phps-mode-automation-header.wy
b/admin/phps-mode-automation-header.wy
index 664fc31..8726788 100644
--- a/admin/phps-mode-automation-header.wy
+++ b/admin/phps-mode-automation-header.wy
@@ -20,7 +20,7 @@
;;; Commentary:
-;; Run `wisent-make-parsers' or "C-c C-c" to generate grammar-file in Emacs
Lisp.
+;; Run `(wisent-make-parsers)' or "C-c C-c" to generate grammar-file in Emacs
Lisp.
;;
;; Based on the Zend PHP Parser YACC
https://github.com/php/php-src/blob/master/Zend/zend_language_parser.y
@@ -31,12 +31,12 @@
;;; Code:
-%package phps-mode-tags
-%provide phps-mode-phps-wy
+%package phps-mode
+%provide phps-mode-wy
%languagemode phps-mode
-%use-macros phps-mode-wy-macro {
+%use-macros phps-mode-wy-macros {
zend_add_class_modifier
zend_add_member_modifier
zend_append_str
diff --git a/admin/phps-mode-automation.el b/admin/phps-mode-automation.el
index 3ccc5ef..4820ea9 100644
--- a/admin/phps-mode-automation.el
+++ b/admin/phps-mode-automation.el
@@ -24,29 +24,26 @@
;;; AST should be like this: (root (block (rule (logic))))
-;;; This entire file is WIP / TODO
-
;;; Code:
-;; (require 'emacs-wisent-grammar-converter)
-
-;; (add-to-list 'load-path (expand-file-name (concat user-emacs-directory
"emacs-wisent-grammar-converter/")))
-
-;; (let ((php-yacc-url
"https://raw.githubusercontent.com/php/php-src/master/Zend/zend_language_parser.y")
-;; (php-yacc-file (expand-file-name "zend_language_parser.y"))
-;; (wisent-destination (expand-file-name "zend_language_parser.wy")))
-
-;; ;; Download Yacc if not available
-;; (unless (file-exists-p php-yacc-file)
-;; (message "Downloading PHP Yacc grammar..")
-;; (url-copy-file php-yacc-url php-yacc-file t t)
-;; (message "Download completed"))
-
-;; ;; Generate grammar
-;; (message "Generating Wisent grammar..")
-;; (emacs-wisent-grammar-converter/generate-grammar-from-filename
php-yacc-file wisent-destination)
-;; (message "Automation completed"))
+(let ((php-yacc-url
"https://raw.githubusercontent.com/php/php-src/master/Zend/zend_language_parser.y")
+ (php-yacc-file (expand-file-name "zend_language_parser.y"))
+ (wisent-destination (expand-file-name "../phps-mode-wy.wy"))
+ (header (expand-file-name "phps-mode-automation-header.wy")))
+
+ ;; Download Yacc if not available
+ (unless (file-exists-p php-yacc-file)
+ (message "Downloading PHP Yacc grammar..")
+ (url-copy-file php-yacc-url php-yacc-file t t)
+ (message "Download completed"))
+
+ ;; Generate grammar
+ (message "Generating Wisent grammar..")
+ (if (fboundp 'emacs-wisent-grammar-converter-generate-grammar-from-filename)
+ (emacs-wisent-grammar-converter-generate-grammar-from-filename
php-yacc-file wisent-destination header)
+ (display-warning 'warning "Missing emacs-wisent-grammar-converter!"))
+ (message "Automation completed"))
(provide 'phps-mode-automation)
;;; phps-mode-automation.el ends here
diff --git a/phps-mode-analyzer.el b/phps-mode-analyzer.el
index cc0ef26..78e9a49 100644
--- a/phps-mode-analyzer.el
+++ b/phps-mode-analyzer.el
@@ -2208,9 +2208,7 @@
(temp-post-indent nil)
(imenu-index '())
(imenu-namespace-index '())
- (imenu-namespace-definition nil)
(imenu-class-index '())
- (imenu-class-definition nil)
(imenu-in-namespace-declaration nil)
(imenu-in-namespace-name nil)
(imenu-in-namespace-with-brackets nil)
@@ -2274,14 +2272,16 @@
(when (and imenu-open-namespace-level
(= imenu-open-namespace-level imenu-nesting-level)
- imenu-in-namespace-name)
+ imenu-in-namespace-name
+ imenu-namespace-index)
(let ((imenu-add-list (nreverse imenu-namespace-index)))
(push `(,imenu-in-namespace-name . ,imenu-add-list)
imenu-index))
(setq imenu-in-namespace-name nil))
(when (and imenu-open-class-level
(= imenu-open-class-level imenu-nesting-level)
- imenu-in-class-name)
+ imenu-in-class-name
+ imenu-class-index)
(let ((imenu-add-list (nreverse imenu-class-index)))
(if imenu-in-namespace-name
(push `(,imenu-in-class-name . ,imenu-add-list)
imenu-namespace-index)
@@ -2300,12 +2300,10 @@
(setq imenu-in-namespace-with-brackets (string= token "{"))
(setq imenu-open-namespace-level imenu-nesting-level)
(setq imenu-namespace-index '())
- (push `("*definition*" . ,imenu-namespace-definition)
imenu-namespace-index)
(setq imenu-in-namespace-declaration nil))
((and (or (equal token 'T_STRING)
(equal token 'T_NS_SEPARATOR))
- (setq imenu-namespace-definition token-start)
(setq imenu-in-namespace-name (concat
imenu-in-namespace-name (substring string (1- token-start) (1- token-end))))))))
(imenu-in-class-declaration
@@ -2314,12 +2312,10 @@
((string= token "{")
(setq imenu-open-class-level imenu-nesting-level)
(setq imenu-in-class-declaration nil)
- (setq imenu-class-index '())
- (push `("*definition*" . ,imenu-class-definition)
imenu-class-index))
+ (setq imenu-class-index '()))
((and (equal token 'T_STRING)
(not imenu-in-class-name))
- (setq imenu-class-definition token-start)
(setq imenu-in-class-name (substring string (1-
token-start) (1- token-end))))))
(imenu-in-function-declaration
@@ -2361,7 +2357,8 @@
(when (and (equal next-token 'END_PARSE)
imenu-in-namespace-name
- (not imenu-in-namespace-with-brackets))
+ (not imenu-in-namespace-with-brackets)
+ imenu-namespace-index)
(let ((imenu-add-list (nreverse imenu-namespace-index)))
(push `(,imenu-in-namespace-name . ,imenu-add-list)
imenu-index))
(setq imenu-in-namespace-name nil))
@@ -3106,7 +3103,7 @@
phps-mode-functions-imenu)
(defun phps-mode-functions-comment-region (beg end &optional _arg)
- "Comment region from BEG to END with optional ARG."
+ "Comment region from BEG to END with optional _ARG."
;; Iterate tokens from beginning to end and comment out all PHP code
(when-let ((tokens phps-mode-lexer-tokens))
(let ((token-comment-start nil)
@@ -3126,6 +3123,8 @@
(equal token-label 'T_COMMENT)
(equal token-label 'T_DOC_COMMENT)
(equal token-label 'T_CLOSE_TAG))
+ (phps-mode-debug-message
+ (message "Comment should end at previous token %s %s"
token-label token-comment-end))
(setq in-token-comment nil))
(t (setq token-comment-end token-end)))
@@ -3156,8 +3155,9 @@
(equal token-label 'T_OPEN_TAG_WITH_ECHO)))
(t
(phps-mode-debug-message
- (message "Comment should start at %s %s" token-label
token-start))
+ (message "Comment should start at %s %s-%s" token-label
token-start token-end))
(setq token-comment-start token-start)
+ (setq token-comment-end token-end)
(setq in-token-comment t)))))))
;; When we have a start and end of comment, comment it out
diff --git a/phps-mode-wy-macros.el b/phps-mode-wy-macros.el
new file mode 100644
index 0000000..b345a27
--- /dev/null
+++ b/phps-mode-wy-macros.el
@@ -0,0 +1,110 @@
+;;; phps-mode-wy-macros.el --- Macros for Wisent grammar -*- lexical-binding:
t -*-
+
+;; Copyright (C) 2018-2019 Free Software Foundation, Inc.
+
+;; This file is not part of GNU Emacs.
+
+;; This program is free software; you can redistribute it and/or
+;; modify it under the terms of the GNU General Public License as
+;; published by the Free Software Foundation; either version 2, or (at
+;; your option) any later version.
+
+;; This program is distributed in the hope that it will be useful, but
+;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+;; General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
+
+
+;;; Commentary:
+
+;;; Provides functions for the Wisent grammar.
+
+
+;;; Code:
+
+
+(require 'semantic/wisent/grammar)
+
+(defun CG (subject &optional value)
+ "Return and optionally set VALUE of SUBJECT."
+ ;; TODO Implement this
+ )
+
+(defun zend_add_class_modifier (class modifier)
+ "Add CLASS MODIFIER."
+ )
+
+(defun zend_add_member_modifier (member modifier)
+ "Add MEMBER MODIFIER."
+ )
+
+(defun zend_ast_create (a b c d)
+ ;; TODO Understand this
+ )
+
+(defun zend_ast_create_assign_op (operator a b)
+ "Assign A value of B via OPERATOR."
+ ;; TODO Understand this
+ )
+
+(defun zend_ast_create_binary_op (operator a b)
+ "Perform binary OPERATOR on A and B."
+ ;; TODO Understand this
+ )
+
+(defun zend_ast_create_cast (operator subject)
+ "Cast SUBJECT with OPERATOR."
+ ;; TODO Understand this
+ )
+
+(defun zend_ast_create_decl (a b c d e f g h)
+ ;; TODO Understand this
+ )
+
+(defun zend_ast_create_ex (a b c d)
+ ;; TODO Understand this
+ )
+
+(defun zend_ast_create_list (a b c)
+ ;; TODO Understand this
+ )
+
+(defun zend_ast_create_zval_from_str (subject)
+ "Create zval from SUBJECT."
+ ;; TODO Understand this
+ )
+
+(defun zend_ast_get_str (subject)
+ "Get string from SUBJECT."
+ ;; TODO Understand this
+ )
+
+(defun zend_lex_tstring(subject)
+ ;; TODO Understand this
+ )
+
+(defun zend_ast_list_add (list item)
+ "Add ITEM to LIST."
+ ;; TODO Understand this
+ )
+
+(defun zend_ast_list_rtrim (subject)
+ "Perform a right trim on SUBJECT."
+ ;; TODO Understand this
+ )
+
+(defun zend_handle_encoding_declaration (subject)
+ ;; TODO Understand this
+ )
+
+(defun zend_negate_num_string (subject)
+ "Negate num string on SUBJECT."
+ ;; TODO Understand this
+ )
+
+
+(provide 'phps-mode-wy-macros)
+;;; phps-mode-wy-macros.el ends here
diff --git a/phps-mode-wy-wy.el b/phps-mode-wy-wy.el
new file mode 100644
index 0000000..3ad834f
--- /dev/null
+++ b/phps-mode-wy-wy.el
@@ -0,0 +1,92 @@
+;;; phps-mode-wy-wy.el --- Generated parser support file
+
+;; Copyright (C) 2018-2019 Free Software Foundation, Inc.
+
+;; Author: Christian Johansson
<christianjohansson@Christians-MacBook-Air.local>
+;; Created: 2019-10-04 07:20:36+0200
+;; Keywords: syntax
+;; X-RCS: $Id$
+
+;; This file is not part of GNU Emacs.
+
+;; This program is free software; you can redistribute it and/or
+;; modify it under the terms of the GNU General Public License as
+;; published by the Free Software Foundation, either version 3 of
+;; the License, or (at your option) any later version.
+
+;; This software is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+;; General Public License for more details.
+;;
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <https://www.gnu.org/licenses/>.
+
+;;; Commentary:
+;;
+;; PLEASE DO NOT MANUALLY EDIT THIS FILE! It is automatically
+;; generated from the grammar file phps-mode-wy.wy.
+
+;;; History:
+;;
+
+;;; Code:
+
+(require 'semantic/lex)
+(eval-when-compile (require 'semantic/bovine))
+
+;;; Prologue
+;;
+
+;;; Declarations
+;;
+(eval-and-compile (defconst phps-mode-wy-wy--expected-conflicts
+ nil
+ "The number of expected shift/reduce conflicts in this
grammar."))
+
+(defconst phps-mode-wy-wy--keyword-table
+ (semantic-lex-make-keyword-table 'nil 'nil)
+ "Table of language keywords.")
+
+(defconst phps-mode-wy-wy--token-table
+ (semantic-lex-make-type-table 'nil 'nil)
+ "Table of lexical tokens.")
+
+(defconst phps-mode-wy-wy--parse-table
+ (progn
+ (eval-when-compile
+ (require 'semantic/wisent/comp))
+ (wisent-compile-grammar
+ '(nil nil)
+ 'nil))
+ "Parser table.")
+
+(defun phps-mode-wy-wy--install-parser ()
+ "Setup the Semantic Parser."
+ (semantic-install-function-overrides
+ '((parse-stream . wisent-parse-stream)))
+ (setq semantic-parser-name "LALR"
+ semantic--parse-table phps-mode-wy-wy--parse-table
+ semantic-debug-parser-source "phps-mode-wy.wy"
+ semantic-flex-keywords-obarray phps-mode-wy-wy--keyword-table
+ semantic-lex-types-obarray phps-mode-wy-wy--token-table)
+ ;; Collect unmatched syntax lexical tokens
+ (semantic-make-local-hook 'wisent-discarding-token-functions)
+ (add-hook 'wisent-discarding-token-functions
+ 'wisent-collect-unmatched-syntax nil t))
+
+
+;;; Analyzers
+;;
+
+;;; Epilogue
+;;
+
+(provide 'phps-mode-wy-wy)
+
+;; Local Variables:
+;; version-control: never
+;; no-update-autoloads: t
+;; End:
+
+;;; phps-mode-wy-wy.el ends here
diff --git a/phps-mode-wy.wy b/phps-mode-wy.wy
new file mode 100644
index 0000000..22fce56
--- /dev/null
+++ b/phps-mode-wy.wy
@@ -0,0 +1,981 @@
+;;; phps.wy -- Semantic LALR grammar for PHP
+
+;; Copyright (C) 2018-2019 Free Software Foundation, Inc.
+
+;; This file is not part of GNU Emacs.
+
+;; This program is free software; you can redistribute it and/or
+;; modify it under the terms of the GNU General Public License as
+;; published by the Free Software Foundation; either version 2, or (at
+;; your option) any later version.
+
+;; This program is distributed in the hope that it will be useful, but
+;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+;; General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
+
+
+;;; Commentary:
+
+;; Run `(wisent-make-parsers)' or "C-c C-c" to generate grammar-file in Emacs
Lisp.
+;;
+;; Based on the Zend PHP Parser YACC
https://github.com/php/php-src/blob/master/Zend/zend_language_parser.y
+
+;; Create macros for all macros uses in original YACC, base macro structure on
semantic-php-wy-macro.el
+
+;; Don't edit phps.wy because it's generated by phps-automation.el and
phps-automation-header.wy
+
+
+;;; Code:
+
+%package phps-mode
+%provide phps-mode-wy
+
+%languagemode phps-mode
+
+%use-macros phps-mode-wy-macros {
+ zend_add_class_modifier
+ zend_add_member_modifier
+ zend_ast_create
+ zend_ast_create_assign_op
+ zend_ast_create_binary_op
+ zend_ast_create_cast
+ zend_ast_create_decl
+ zend_ast_create_ex
+ zend_ast_create_list
+ zend_ast_create_zval_from_str
+ zend_ast_get_str
+ zend_ast_list_add
+ zend_ast_list_rtrim
+ zend_handle_encoding_declaration
+ zend_negate_num_string
+}
+
+
+;; NOTE Generated grammar starts here
+
+
+start:
+ top_statement_list ((CG ast $1))
+ ;
+
+reserved_non_modifiers:
+ T_INCLUDE
+ | T_INCLUDE_ONCE
+ | T_EVAL
+ | T_REQUIRE
+ | T_REQUIRE_ONCE
+ | T_LOGICAL_OR
+ | T_LOGICAL_XOR
+ | T_LOGICAL_AND
+ | T_INSTANCEOF
+ | T_NEW
+ | T_CLONE
+ | T_EXIT
+ | T_IF
+ | T_ELSEIF
+ | T_ELSE
+ | T_ENDIF
+ | T_ECHO
+ | T_DO
+ | T_WHILE
+ | T_ENDWHILE
+ | T_FOR
+ | T_ENDFOR
+ | T_FOREACH
+ | T_ENDFOREACH
+ | T_DECLARE
+ | T_ENDDECLARE
+ | T_AS
+ | T_TRY
+ | T_CATCH
+ | T_FINALLY
+ | T_THROW
+ | T_USE
+ | T_INSTEADOF
+ | T_GLOBAL
+ | T_VAR
+ | T_UNSET
+ | T_ISSET
+ | T_EMPTY
+ | T_CONTINUE
+ | T_GOTO
+ | T_FUNCTION
+ | T_CONST
+ | T_RETURN
+ | T_PRINT
+ | T_YIELD
+ | T_LIST
+ | T_SWITCH
+ | T_ENDSWITCH
+ | T_CASE
+ | T_DEFAULT
+ | T_BREAK
+ | T_ARRAY
+ | T_CALLABLE
+ | T_EXTENDS
+ | T_IMPLEMENTS
+ | T_NAMESPACE
+ | T_TRAIT
+ | T_INTERFACE
+ | T_CLASS
+ | T_CLASS_C
+ | T_TRAIT_C
+ | T_FUNC_C
+ | T_METHOD_C
+ | T_LINE
+ | T_FILE
+ | T_DIR
+ | T_NS_C
+ | T_FN
+ ;
+
+semi_reserved:
+ reserved_non_modifiers
+ | T_STATIC
+ | T_ABSTRACT
+ | T_FINAL
+ | T_PRIVATE
+ | T_PROTECTED
+ | T_PUBLIC
+ ;
+
+identifier:
+ T_STRING ($1)
+ | semi_reserved (zval zv (zend_lex_tstring &zv) (zend_ast_create_zval &zv))
+ ;
+
+top_statement_list:
+ top_statement_list top_statement ((zend_ast_list_add $1 $2))
+ | ;; empty
+ ((zend_ast_create_list 0 ZEND_AST_STMT_LIST))
+ ;
+
+namespace_name:
+ T_STRING ($1)
+ | namespace_name T_NS_SEPARATOR T_STRING ((zend_ast_append_str $1 $3))
+ ;
+
+name:
+ namespace_name ($1 (put $$ 'attr 'ZEND_NAME_NOT_FQ))
+ | T_NAMESPACE T_NS_SEPARATOR namespace_name ($3 (put $$ 'attr
'ZEND_NAME_RELATIVE))
+ | T_NS_SEPARATOR namespace_name ($2 (put $$ 'attr 'ZEND_NAME_FQ))
+ ;
+
+top_statement:
+ statement ($1)
+ | function_declaration_statement ($1)
+ | class_declaration_statement ($1)
+ | trait_declaration_statement ($1)
+ | interface_declaration_statement ($1)
+ | T_HALT_COMPILER '(' ')' ';' ((zend_ast_create ZEND_AST_HALT_COMPILER
(zend_ast_create_zval_from_long (zend_get_scanned_file_offset)))
(zend_stop_lexing))
+ | T_NAMESPACE namespace_name ';' ((zend_ast_create ZEND_AST_NAMESPACE $2
nil (RESET_DOC_COMMENT))
+ | T_NAMESPACE namespace_name ((RESET_DOC_COMMENT)) '{' top_statement_list
'}' ((zend_ast_create ZEND_AST_NAMESPACE $2 $5))
+ | T_NAMESPACE ((RESET_DOC_COMMENT)) '{' top_statement_list '}'
((zend_ast_create ZEND_AST_NAMESPACE nil$4))
+ | T_USE mixed_group_use_declaration ';' ($2)
+ | T_USE use_type group_use_declaration ';' ($3 (put $$ 'attr '$2))
+ | T_USE use_declarations ';' ($2 (put $$ 'attr 'ZEND_SYMBOL_CLASS))
+ | T_USE use_type use_declarations ';' ($3 (put $$ 'attr '$2))
+ | T_CONST const_list ';' ($2)
+ ;
+
+use_type:
+ T_FUNCTION ($$ = ZEND_SYMBOL_FUNCTION)
+ | T_CONST ($$ = ZEND_SYMBOL_CONST)
+ ;
+
+group_use_declaration:
+ namespace_name T_NS_SEPARATOR '{' unprefixed_use_declarations
possible_comma '}' ((zend_ast_create ZEND_AST_GROUP_USE $1 $4))
+ | T_NS_SEPARATOR namespace_name T_NS_SEPARATOR '{'
unprefixed_use_declarations possible_comma '}' ((zend_ast_create
ZEND_AST_GROUP_USE $2 $5))
+ ;
+
+mixed_group_use_declaration:
+ namespace_name T_NS_SEPARATOR '{' inline_use_declarations possible_comma
'}' ((zend_ast_create ZEND_AST_GROUP_USE $1 $4))
+ | T_NS_SEPARATOR namespace_name T_NS_SEPARATOR '{' inline_use_declarations
possible_comma '}' ((zend_ast_create ZEND_AST_GROUP_USE $2 $5))
+ ;
+
+possible_comma:
+ ;; empty
+ | ','
+ ;
+
+inline_use_declarations:
+ inline_use_declarations ',' inline_use_declaration ((zend_ast_list_add $1
$3))
+ | inline_use_declaration ((zend_ast_create_list 1 ZEND_AST_USE $1))
+ ;
+
+unprefixed_use_declarations:
+ unprefixed_use_declarations ',' unprefixed_use_declaration
((zend_ast_list_add $1 $3))
+ | unprefixed_use_declaration ((zend_ast_create_list 1 ZEND_AST_USE $1))
+ ;
+
+use_declarations:
+ use_declarations ',' use_declaration ((zend_ast_list_add $1 $3))
+ | use_declaration ((zend_ast_create_list 1 ZEND_AST_USE $1))
+ ;
+
+inline_use_declaration:
+ unprefixed_use_declaration ($1 (put $$ 'attr 'ZEND_SYMBOL_CLASS))
+ | use_type unprefixed_use_declaration ($2 (put $$ 'attr '$1))
+ ;
+
+unprefixed_use_declaration:
+ namespace_name ((zend_ast_create ZEND_AST_USE_ELEM $1 nil)
+ | namespace_name T_AS T_STRING ((zend_ast_create ZEND_AST_USE_ELEM $1 $3))
+ ;
+
+use_declaration:
+ unprefixed_use_declaration ($1)
+ | T_NS_SEPARATOR unprefixed_use_declaration ($2)
+ ;
+
+const_list:
+ const_list ',' const_decl ((zend_ast_list_add $1 $3))
+ | const_decl ((zend_ast_create_list 1 ZEND_AST_CONST_DECL $1))
+ ;
+
+inner_statement_list:
+ inner_statement_list inner_statement ((zend_ast_list_add $1 $2))
+ | ;; empty
+ ((zend_ast_create_list 0 ZEND_AST_STMT_LIST))
+ ;
+
+inner_statement:
+ statement ($1)
+ | function_declaration_statement ($1)
+ | class_declaration_statement ($1)
+ | trait_declaration_statement ($1)
+ | interface_declaration_statement ($1)
+ | T_HALT_COMPILER '(' ')' ';' ($$ = nil(zend_throw_exception
zend_ce_compile_error "(__HALT_COMPILER) can only be used from the outermost
scope" 0) YYERROR)
+ ;
+
+statement:
+ '{' inner_statement_list '}' ($2)
+ | if_stmt ($1)
+ | alt_if_stmt ($1)
+ | T_WHILE '(' expr ')' while_statement ((zend_ast_create ZEND_AST_WHILE $3
$5))
+ | T_DO statement T_WHILE '(' expr ')' ';' ((zend_ast_create
ZEND_AST_DO_WHILE $2 $5))
+ | T_FOR '(' for_exprs ';' for_exprs ';' for_exprs ')' for_statement
((zend_ast_create ZEND_AST_FOR $3 $5 $7 $9))
+ | T_SWITCH '(' expr ')' switch_case_list ((zend_ast_create ZEND_AST_SWITCH
$3 $5))
+ | T_BREAK optional_expr ';' ((zend_ast_create ZEND_AST_BREAK $2))
+ | T_CONTINUE optional_expr ';' ((zend_ast_create ZEND_AST_CONTINUE $2))
+ | T_RETURN optional_expr ';' ((zend_ast_create ZEND_AST_RETURN $2))
+ | T_GLOBAL global_var_list ';' ($2)
+ | T_STATIC static_var_list ';' ($2)
+ | T_ECHO echo_expr_list ';' ($2)
+ | T_INLINE_HTML ((zend_ast_create ZEND_AST_ECHO $1))
+ | expr ';' ($1)
+ | T_UNSET '(' unset_variables possible_comma ')' ';' ($3)
+ | T_FOREACH '(' expr T_AS foreach_variable ')' foreach_statement
((zend_ast_create ZEND_AST_FOREACH $3 $5 nil$7))
+ | T_FOREACH '(' expr T_AS foreach_variable T_DOUBLE_ARROW foreach_variable
')' foreach_statement ((zend_ast_create ZEND_AST_FOREACH $3 $7 $5 $9))
+ | T_DECLARE '(' const_list ')' ( (if
(!zend_handle_encoding_declaration($3))YYERROR)) declare_statement
((zend_ast_create ZEND_AST_DECLARE $3 $6))
+ | ';' ;; empty statement
+ ($$ = NULL)
+ | T_TRY '{' inner_statement_list '}' catch_list finally_statement
((zend_ast_create ZEND_AST_TRY $3 $5 $6))
+ | T_THROW expr ';' ((zend_ast_create ZEND_AST_THROW $2))
+ | T_GOTO T_STRING ';' ((zend_ast_create ZEND_AST_GOTO $2))
+ | T_STRING ':' ((zend_ast_create ZEND_AST_LABEL $1))
+ ;
+
+catch_list:
+ ;; empty
+ ((zend_ast_create_list 0 ZEND_AST_CATCH_LIST))
+ | catch_list T_CATCH '(' catch_name_list T_VARIABLE ')' '{'
inner_statement_list '}' ((zend_ast_list_add $1 (zend_ast_create ZEND_AST_CATCH
$4 $5 $8)))
+ ;
+
+catch_name_list:
+ name ((zend_ast_create_list 1 ZEND_AST_NAME_LIST $1))
+ | catch_name_list '|' name ((zend_ast_list_add $1 $3))
+ ;
+
+finally_statement:
+ ;; empty
+ ($$ = NULL)
+ | T_FINALLY '{' inner_statement_list '}' ($3)
+ ;
+
+unset_variables:
+ unset_variable ((zend_ast_create_list 1 ZEND_AST_STMT_LIST $1))
+ | unset_variables ',' unset_variable ((zend_ast_list_add $1 $3))
+ ;
+
+unset_variable:
+ variable ((zend_ast_create ZEND_AST_UNSET $1))
+ ;
+
+function_declaration_statement:
+ function returns_ref T_STRING backup_doc_comment '(' parameter_list ')'
return_type backup_fn_flags '{' inner_statement_list '}' backup_fn_flags
((zend_ast_create_decl ZEND_AST_FUNC_DECL (logior $2 $13) $1 $4
(zend_ast_get_str $3) $6 nil$11 $8) (CG extra_fn_flags) = $9)
+ ;
+
+is_reference:
+ ;; empty
+ ($$ = 0)
+ | '&' ($$ = ZEND_PARAM_REF)
+ ;
+
+is_variadic:
+ ;; empty
+ ($$ = 0)
+ | T_ELLIPSIS ($$ = ZEND_PARAM_VARIADIC)
+ ;
+
+class_declaration_statement:
+ class_modifiers T_CLASS ($<num>$ = (CG zend_lineno)) T_STRING extends_from
implements_list backup_doc_comment '{' class_statement_list '}'
((zend_ast_create_decl ZEND_AST_CLASS $1 $<num>3 $7 (zend_ast_get_str $4) $5 $6
$9 nil)
+ | T_CLASS ($<num>$ = (CG zend_lineno)) T_STRING extends_from
implements_list backup_doc_comment '{' class_statement_list '}'
((zend_ast_create_decl ZEND_AST_CLASS 0 $<num>2 $6 (zend_ast_get_str $3) $4 $5
$8 nil)
+ ;
+
+class_modifiers:
+ class_modifier ($1)
+ | class_modifiers class_modifier ( ($$ = zend_add_class_modifier($1, $2);
if (!$$)YYERROR))
+ ;
+
+class_modifier:
+ T_ABSTRACT ($$ = ZEND_ACC_EXPLICIT_ABSTRACT_CLASS)
+ | T_FINAL ($$ = ZEND_ACC_FINAL)
+ ;
+
+trait_declaration_statement:
+ T_TRAIT ($<num>$ = (CG zend_lineno)) T_STRING backup_doc_comment '{'
class_statement_list '}' ((zend_ast_create_decl ZEND_AST_CLASS ZEND_ACC_TRAIT
$<num>2 $4 (zend_ast_get_str $3) nilnil$6 nil)
+ ;
+
+interface_declaration_statement:
+ T_INTERFACE ($<num>$ = (CG zend_lineno)) T_STRING interface_extends_list
backup_doc_comment '{' class_statement_list '}' ((zend_ast_create_decl
ZEND_AST_CLASS ZEND_ACC_INTERFACE $<num>2 $5 (zend_ast_get_str $3) nil$4 $7 nil)
+ ;
+
+extends_from:
+ ;; empty
+ ($$ = NULL)
+ | T_EXTENDS name ($2)
+ ;
+
+interface_extends_list:
+ ;; empty
+ ($$ = NULL)
+ | T_EXTENDS name_list ($2)
+ ;
+
+implements_list:
+ ;; empty
+ ($$ = NULL)
+ | T_IMPLEMENTS name_list ($2)
+ ;
+
+foreach_variable:
+ variable ($1)
+ | '&' variable ((zend_ast_create ZEND_AST_REF $2))
+ | T_LIST '(' array_pair_list ')' ($3 (put $$ 'attr
'ZEND_ARRAY_SYNTAX_LIST))
+ | '[' array_pair_list ']' ($2 (put $$ 'attr 'ZEND_ARRAY_SYNTAX_SHORT))
+ ;
+
+for_statement:
+ statement ($1)
+ | ':' inner_statement_list T_ENDFOR ';' ($2)
+ ;
+
+foreach_statement:
+ statement ($1)
+ | ':' inner_statement_list T_ENDFOREACH ';' ($2)
+ ;
+
+declare_statement:
+ statement ($1)
+ | ':' inner_statement_list T_ENDDECLARE ';' ($2)
+ ;
+
+switch_case_list:
+ '{' case_list '}' ($2)
+ | '{' ';' case_list '}' ($3)
+ | ':' case_list T_ENDSWITCH ';' ($2)
+ | ':' ';' case_list T_ENDSWITCH ';' ($3)
+ ;
+
+case_list:
+ ;; empty
+ ((zend_ast_create_list 0 ZEND_AST_SWITCH_LIST))
+ | case_list T_CASE expr case_separator inner_statement_list
((zend_ast_list_add $1 (zend_ast_create ZEND_AST_SWITCH_CASE $3 $5)))
+ | case_list T_DEFAULT case_separator inner_statement_list
((zend_ast_list_add $1 (zend_ast_create ZEND_AST_SWITCH_CASE nil$4)))
+ ;
+
+case_separator:
+ ':'
+ | ';'
+ ;
+
+while_statement:
+ statement ($1)
+ | ':' inner_statement_list T_ENDWHILE ';' ($2)
+ ;
+
+if_stmt_without_else:
+ T_IF '(' expr ')' statement ((zend_ast_create_list 1 ZEND_AST_IF
(zend_ast_create ZEND_AST_IF_ELEM $3 $5)))
+ | if_stmt_without_else T_ELSEIF '(' expr ')' statement ((zend_ast_list_add
$1 (zend_ast_create ZEND_AST_IF_ELEM $4 $6)))
+ ;
+
+if_stmt:
+ if_stmt_without_else prec T_NOELSE ($1)
+ | if_stmt_without_else T_ELSE statement ((zend_ast_list_add $1
(zend_ast_create ZEND_AST_IF_ELEM nil$3)))
+ ;
+
+alt_if_stmt_without_else:
+ T_IF '(' expr ')' ':' inner_statement_list ((zend_ast_create_list 1
ZEND_AST_IF (zend_ast_create ZEND_AST_IF_ELEM $3 $6)))
+ | alt_if_stmt_without_else T_ELSEIF '(' expr ')' ':' inner_statement_list
((zend_ast_list_add $1 (zend_ast_create ZEND_AST_IF_ELEM $4 $7)))
+ ;
+
+alt_if_stmt:
+ alt_if_stmt_without_else T_ENDIF ';' ($1)
+ | alt_if_stmt_without_else T_ELSE ':' inner_statement_list T_ENDIF ';'
((zend_ast_list_add $1 (zend_ast_create ZEND_AST_IF_ELEM nil$4)))
+ ;
+
+parameter_list:
+ non_empty_parameter_list ($1)
+ | ;; empty
+ ((zend_ast_create_list 0 ZEND_AST_PARAM_LIST))
+ ;
+
+non_empty_parameter_list:
+ parameter ((zend_ast_create_list 1 ZEND_AST_PARAM_LIST $1))
+ | non_empty_parameter_list ',' parameter ((zend_ast_list_add $1 $3))
+ ;
+
+parameter:
+ optional_type is_reference is_variadic T_VARIABLE ((zend_ast_create_ex
ZEND_AST_PARAM (logior $2 $3) $1 $4 nil)
+ | optional_type is_reference is_variadic T_VARIABLE '=' expr
((zend_ast_create_ex ZEND_AST_PARAM (logior $2 $3) $1 $4 $6))
+ ;
+
+optional_type:
+ ;; empty
+ ($$ = NULL)
+ | type_expr ($1)
+ ;
+
+type_expr:
+ type ($1)
+ | '?' type ($2 $$->attr |= ZEND_TYPE_NULLABLE)
+ ;
+
+type:
+ T_ARRAY ((zend_ast_create_ex ZEND_AST_TYPE IS_ARRAY))
+ | T_CALLABLE ((zend_ast_create_ex ZEND_AST_TYPE IS_CALLABLE))
+ | name ($1)
+ ;
+
+return_type:
+ ;; empty
+ ($$ = NULL)
+ | ':' type_expr ($2)
+ ;
+
+argument_list:
+ '(' ')' ((zend_ast_create_list 0 ZEND_AST_ARG_LIST))
+ | '(' non_empty_argument_list possible_comma ')' ($2)
+ ;
+
+non_empty_argument_list:
+ argument ((zend_ast_create_list 1 ZEND_AST_ARG_LIST $1))
+ | non_empty_argument_list ',' argument ((zend_ast_list_add $1 $3))
+ ;
+
+argument:
+ expr ($1)
+ | T_ELLIPSIS expr ((zend_ast_create ZEND_AST_UNPACK $2))
+ ;
+
+global_var_list:
+ global_var_list ',' global_var ((zend_ast_list_add $1 $3))
+ | global_var ((zend_ast_create_list 1 ZEND_AST_STMT_LIST $1))
+ ;
+
+global_var:
+ simple_variable ((zend_ast_create ZEND_AST_GLOBAL (zend_ast_create
ZEND_AST_VAR $1)))
+ ;
+
+static_var_list:
+ static_var_list ',' static_var ((zend_ast_list_add $1 $3))
+ | static_var ((zend_ast_create_list 1 ZEND_AST_STMT_LIST $1))
+ ;
+
+static_var:
+ T_VARIABLE ((zend_ast_create ZEND_AST_STATIC $1 nil)
+ | T_VARIABLE '=' expr ((zend_ast_create ZEND_AST_STATIC $1 $3))
+ ;
+
+class_statement_list:
+ class_statement_list class_statement ((zend_ast_list_add $1 $2))
+ | ;; empty
+ ((zend_ast_create_list 0 ZEND_AST_STMT_LIST))
+ ;
+
+class_statement:
+ variable_modifiers optional_type property_list ';' ((zend_ast_create
ZEND_AST_PROP_GROUP $2 $3) (put $$ 'attr '$1))
+ | method_modifiers T_CONST class_const_list ';' ($3 (put $$ 'attr '$1))
+ | T_USE name_list trait_adaptations ((zend_ast_create ZEND_AST_USE_TRAIT
$2 $3))
+ | method_modifiers function returns_ref identifier backup_doc_comment '('
parameter_list ')' return_type backup_fn_flags method_body backup_fn_flags
((zend_ast_create_decl ZEND_AST_METHOD (logior $3 $1) | $12 $2 $5
(zend_ast_get_str $4) $7 nil$11 $9) (CG extra_fn_flags) = $10)
+ ;
+
+name_list:
+ name ((zend_ast_create_list 1 ZEND_AST_NAME_LIST $1))
+ | name_list ',' name ((zend_ast_list_add $1 $3))
+ ;
+
+trait_adaptations:
+ ';' ($$ = NULL)
+ | '{' '}' ($$ = NULL)
+ | '{' trait_adaptation_list '}' ($2)
+ ;
+
+trait_adaptation_list:
+ trait_adaptation ((zend_ast_create_list 1 ZEND_AST_TRAIT_ADAPTATIONS $1))
+ | trait_adaptation_list trait_adaptation ((zend_ast_list_add $1 $2))
+ ;
+
+trait_adaptation:
+ trait_precedence ';' ($1)
+ | trait_alias ';' ($1)
+ ;
+
+trait_precedence:
+ absolute_trait_method_reference T_INSTEADOF name_list ((zend_ast_create
ZEND_AST_TRAIT_PRECEDENCE $1 $3))
+ ;
+
+trait_alias:
+ trait_method_reference T_AS T_STRING ((zend_ast_create
ZEND_AST_TRAIT_ALIAS $1 $3))
+ | trait_method_reference T_AS reserved_non_modifiers (zval zv
(zend_lex_tstring &zv) (zend_ast_create ZEND_AST_TRAIT_ALIAS $1
(zend_ast_create_zval &zv)))
+ | trait_method_reference T_AS member_modifier identifier
((zend_ast_create_ex ZEND_AST_TRAIT_ALIAS $3 $1 $4))
+ | trait_method_reference T_AS member_modifier ((zend_ast_create_ex
ZEND_AST_TRAIT_ALIAS $3 $1 nil)
+ ;
+
+trait_method_reference:
+ identifier ((zend_ast_create ZEND_AST_METHOD_REFERENCE nil$1))
+ | absolute_trait_method_reference ($1)
+ ;
+
+absolute_trait_method_reference:
+ name T_PAAMAYIM_NEKUDOTAYIM identifier ((zend_ast_create
ZEND_AST_METHOD_REFERENCE $1 $3))
+ ;
+
+method_body:
+ ';' ;; abstract method
+ ($$ = NULL)
+ | '{' inner_statement_list '}' ($2)
+ ;
+
+variable_modifiers:
+ non_empty_member_modifiers ($1)
+ | T_VAR ($$ = ZEND_ACC_PUBLIC)
+ ;
+
+method_modifiers:
+ ;; empty
+ ($$ = ZEND_ACC_PUBLIC)
+ | non_empty_member_modifiers ( ($$ = $1; if (!($$ & ZEND_ACC_PPP_MASK))$$
|= ZEND_ACC_PUBLIC))
+ ;
+
+non_empty_member_modifiers:
+ member_modifier ($1)
+ | non_empty_member_modifiers member_modifier ( ($$ =
zend_add_member_modifier($1, $2); if (!$$)YYERROR))
+ ;
+
+member_modifier:
+ T_PUBLIC ($$ = ZEND_ACC_PUBLIC)
+ | T_PROTECTED ($$ = ZEND_ACC_PROTECTED)
+ | T_PRIVATE ($$ = ZEND_ACC_PRIVATE)
+ | T_STATIC ($$ = ZEND_ACC_STATIC)
+ | T_ABSTRACT ($$ = ZEND_ACC_ABSTRACT)
+ | T_FINAL ($$ = ZEND_ACC_FINAL)
+ ;
+
+property_list:
+ property_list ',' property ((zend_ast_list_add $1 $3))
+ | property ((zend_ast_create_list 1 ZEND_AST_PROP_DECL $1))
+ ;
+
+property:
+ T_VARIABLE backup_doc_comment ((zend_ast_create ZEND_AST_PROP_ELEM $1
nil($2 ? (zend_ast_create_zval_from_str $2) : nil))
+ | T_VARIABLE '=' expr backup_doc_comment ((zend_ast_create
ZEND_AST_PROP_ELEM $1 $3 ($4 ? (zend_ast_create_zval_from_str $4) : nil))
+ ;
+
+class_const_list:
+ class_const_list ',' class_const_decl ((zend_ast_list_add $1 $3))
+ | class_const_decl ((zend_ast_create_list 1 ZEND_AST_CLASS_CONST_DECL $1))
+ ;
+
+class_const_decl:
+ identifier '=' expr backup_doc_comment ((zend_ast_create
ZEND_AST_CONST_ELEM $1 $3 ($4 ? (zend_ast_create_zval_from_str $4) : nil))
+ ;
+
+const_decl:
+ T_STRING '=' expr backup_doc_comment ((zend_ast_create ZEND_AST_CONST_ELEM
$1 $3 ($4 ? (zend_ast_create_zval_from_str $4) : nil))
+ ;
+
+echo_expr_list:
+ echo_expr_list ',' echo_expr ((zend_ast_list_add $1 $3))
+ | echo_expr ((zend_ast_create_list 1 ZEND_AST_STMT_LIST $1))
+ ;
+
+echo_expr:
+ expr ((zend_ast_create ZEND_AST_ECHO $1))
+ ;
+
+for_exprs:
+ ;; empty
+ ($$ = NULL)
+ | non_empty_for_exprs ($1)
+ ;
+
+non_empty_for_exprs:
+ non_empty_for_exprs ',' expr ((zend_ast_list_add $1 $3))
+ | expr ((zend_ast_create_list 1 ZEND_AST_EXPR_LIST $1))
+ ;
+
+anonymous_class:
+ T_CLASS ($<num>$ = (CG zend_lineno)) ctor_arguments extends_from
implements_list backup_doc_comment '{' class_statement_list '}' (zend_ast *decl
= (zend_ast_create_decl ZEND_AST_CLASS ZEND_ACC_ANON_CLASS $<num>2 $6 nil$4 $5
$8 nil (zend_ast_create ZEND_AST_NEW decl $3))
+ ;
+
+new_expr:
+ T_NEW class_name_reference ctor_arguments ((zend_ast_create ZEND_AST_NEW
$2 $3))
+ | T_NEW anonymous_class ($2)
+ ;
+
+expr:
+ variable ($1)
+ | T_LIST '(' array_pair_list ')' '=' expr ((put $3 'attr
'ZEND_ARRAY_SYNTAX_LIST) (zend_ast_create ZEND_AST_ASSIGN $3 $6))
+ | '[' array_pair_list ']' '=' expr ((put $2 'attr
'ZEND_ARRAY_SYNTAX_SHORT) (zend_ast_create ZEND_AST_ASSIGN $2 $5))
+ | variable '=' expr ((zend_ast_create ZEND_AST_ASSIGN $1 $3))
+ | variable '=' '&' variable ((zend_ast_create ZEND_AST_ASSIGN_REF $1 $4))
+ | T_CLONE expr ((zend_ast_create ZEND_AST_CLONE $2))
+ | variable T_PLUS_EQUAL expr ((zend_ast_create_assign_op ZEND_ADD $1 $3))
+ | variable T_MINUS_EQUAL expr ((zend_ast_create_assign_op ZEND_SUB $1 $3))
+ | variable T_MUL_EQUAL expr ((zend_ast_create_assign_op ZEND_MUL $1 $3))
+ | variable T_POW_EQUAL expr ((zend_ast_create_assign_op ZEND_POW $1 $3))
+ | variable T_DIV_EQUAL expr ((zend_ast_create_assign_op ZEND_DIV $1 $3))
+ | variable T_CONCAT_EQUAL expr ((zend_ast_create_assign_op ZEND_CONCAT $1
$3))
+ | variable T_MOD_EQUAL expr ((zend_ast_create_assign_op ZEND_MOD $1 $3))
+ | variable T_AND_EQUAL expr ((zend_ast_create_assign_op ZEND_BW_AND $1 $3))
+ | variable T_OR_EQUAL expr ((zend_ast_create_assign_op ZEND_BW_OR $1 $3))
+ | variable T_XOR_EQUAL expr ((zend_ast_create_assign_op ZEND_BW_XOR $1 $3))
+ | variable T_SL_EQUAL expr ((zend_ast_create_assign_op ZEND_SL $1 $3))
+ | variable T_SR_EQUAL expr ((zend_ast_create_assign_op ZEND_SR $1 $3))
+ | variable T_COALESCE_EQUAL expr ((zend_ast_create
ZEND_AST_ASSIGN_COALESCE $1 $3))
+ | variable T_INC ((zend_ast_create ZEND_AST_POST_INC $1))
+ | T_INC variable ((zend_ast_create ZEND_AST_PRE_INC $2))
+ | variable T_DEC ((zend_ast_create ZEND_AST_POST_DEC $1))
+ | T_DEC variable ((zend_ast_create ZEND_AST_PRE_DEC $2))
+ | expr T_BOOLEAN_OR expr ((zend_ast_create ZEND_AST_OR $1 $3))
+ | expr T_BOOLEAN_AND expr ((zend_ast_create ZEND_AST_AND $1 $3))
+ | expr T_LOGICAL_OR expr ((zend_ast_create ZEND_AST_OR $1 $3))
+ | expr T_LOGICAL_AND expr ((zend_ast_create ZEND_AST_AND $1 $3))
+ | expr T_LOGICAL_XOR expr ((zend_ast_create_binary_op ZEND_BOOL_XOR $1 $3))
+ | expr '|' expr ((zend_ast_create_binary_op ZEND_BW_OR $1 $3))
+ | expr '&' expr ((zend_ast_create_binary_op ZEND_BW_AND $1 $3))
+ | expr '^' expr ((zend_ast_create_binary_op ZEND_BW_XOR $1 $3))
+ | expr '.' expr ((zend_ast_create_binary_op ZEND_CONCAT $1 $3))
+ | expr '+' expr ((zend_ast_create_binary_op ZEND_ADD $1 $3))
+ | expr '-' expr ((zend_ast_create_binary_op ZEND_SUB $1 $3))
+ | expr '*' expr ((zend_ast_create_binary_op ZEND_MUL $1 $3))
+ | expr T_POW expr ((zend_ast_create_binary_op ZEND_POW $1 $3))
+ | expr '/' expr ((zend_ast_create_binary_op ZEND_DIV $1 $3))
+ | expr '%' expr ((zend_ast_create_binary_op ZEND_MOD $1 $3))
+ | expr T_SL expr ((zend_ast_create_binary_op ZEND_SL $1 $3))
+ | expr T_SR expr ((zend_ast_create_binary_op ZEND_SR $1 $3))
+ | '+' expr prec '~' ((zend_ast_create ZEND_AST_UNARY_PLUS $2))
+ | '-' expr prec '~' ((zend_ast_create ZEND_AST_UNARY_MINUS $2))
+ | '!' expr ((zend_ast_create_ex ZEND_AST_UNARY_OP ZEND_BOOL_NOT $2))
+ | '~' expr ((zend_ast_create_ex ZEND_AST_UNARY_OP ZEND_BW_NOT $2))
+ | expr T_IS_IDENTICAL expr ((zend_ast_create_binary_op ZEND_IS_IDENTICAL
$1 $3))
+ | expr T_IS_NOT_IDENTICAL expr ((zend_ast_create_binary_op
ZEND_IS_NOT_IDENTICAL $1 $3))
+ | expr T_IS_EQUAL expr ((zend_ast_create_binary_op ZEND_IS_EQUAL $1 $3))
+ | expr T_IS_NOT_EQUAL expr ((zend_ast_create_binary_op ZEND_IS_NOT_EQUAL
$1 $3))
+ | expr '<' expr ((zend_ast_create_binary_op ZEND_IS_SMALLER $1 $3))
+ | expr T_IS_SMALLER_OR_EQUAL expr ((zend_ast_create_binary_op
ZEND_IS_SMALLER_OR_EQUAL $1 $3))
+ | expr '>' expr ((zend_ast_create ZEND_AST_GREATER $1 $3))
+ | expr T_IS_GREATER_OR_EQUAL expr ((zend_ast_create ZEND_AST_GREATER_EQUAL
$1 $3))
+ | expr T_SPACESHIP expr ((zend_ast_create_binary_op ZEND_SPACESHIP $1 $3))
+ | expr T_INSTANCEOF class_name_reference ((zend_ast_create
ZEND_AST_INSTANCEOF $1 $3))
+ | '(' expr ')' ($2 if ((put $$ 'kind '= ZEND_AST_CONDITIONAL) $$->attr =
ZEND_PARENTHESIZED_CONDITIONAL))
+ | new_expr ($1)
+ | expr '?' expr ':' expr ((zend_ast_create ZEND_AST_CONDITIONAL $1 $3 $5))
+ | expr '?' ':' expr ((zend_ast_create ZEND_AST_CONDITIONAL $1 nil$4))
+ | expr T_COALESCE expr ((zend_ast_create ZEND_AST_COALESCE $1 $3))
+ | internal_functions_in_yacc ($1)
+ | T_INT_CAST expr ((zend_ast_create_cast IS_LONG $2))
+ | T_DOUBLE_CAST expr ((zend_ast_create_cast IS_DOUBLE $2))
+ | T_STRING_CAST expr ((zend_ast_create_cast IS_STRING $2))
+ | T_ARRAY_CAST expr ((zend_ast_create_cast IS_ARRAY $2))
+ | T_OBJECT_CAST expr ((zend_ast_create_cast IS_OBJECT $2))
+ | T_BOOL_CAST expr ((zend_ast_create_cast _IS_BOOL $2))
+ | T_UNSET_CAST expr ((zend_ast_create_cast IS_nil$2))
+ | T_EXIT exit_expr ((zend_ast_create ZEND_AST_EXIT $2))
+ | '@' expr ((zend_ast_create ZEND_AST_SILENCE $2))
+ | scalar ($1)
+ | '`' backticks_expr '`' ((zend_ast_create ZEND_AST_SHELL_EXEC $2))
+ | T_PRINT expr ((zend_ast_create ZEND_AST_PRINT $2))
+ | T_YIELD ((zend_ast_create ZEND_AST_YIELD nilnil (CG extra_fn_flags) |=
ZEND_ACC_GENERATOR)
+ | T_YIELD expr ((zend_ast_create ZEND_AST_YIELD $2 nil (CG extra_fn_flags)
|= ZEND_ACC_GENERATOR)
+ | T_YIELD expr T_DOUBLE_ARROW expr ((zend_ast_create ZEND_AST_YIELD $4 $2)
(CG extra_fn_flags) |= ZEND_ACC_GENERATOR)
+ | T_YIELD_FROM expr ((zend_ast_create ZEND_AST_YIELD_FROM $2) (CG
extra_fn_flags) |= ZEND_ACC_GENERATOR)
+ | inline_function ($1)
+ | T_STATIC inline_function ($2 ((zend_ast_decl *) $$)->flags |=
ZEND_ACC_STATIC)
+ ;
+
+inline_function:
+ function returns_ref backup_doc_comment '(' parameter_list ')'
lexical_vars return_type backup_fn_flags '{' inner_statement_list '}'
backup_fn_flags ( ($$ = zend_ast_create_decl(ZEND_AST_CLOSURE, $2 | $13, $1, $3,
+zend_string_init("closure) (", sizeof("closure)") - 1 0) $5 $7 $11 $8) (CG
extra_fn_flags) = $9)
+ | fn returns_ref '(' parameter_list ')' return_type backup_doc_comment
T_DOUBLE_ARROW backup_fn_flags backup_lex_pos expr backup_fn_flags ( ($$ =
zend_ast_create_decl(ZEND_AST_ARROW_FUNC, $2 | $12, $1, $7,
+zend_string_init("closure) (", sizeof("closure)") - 1 0) $4
nil(zend_ast_create ZEND_AST_RETURN $11) $6) ((zend_ast_decl *) $$)->lex_pos =
$10 (CG extra_fn_flags) = $9)
+ ;
+
+fn:
+ T_FN ((CG zend_lineno))
+ ;
+
+function:
+ T_FUNCTION ((CG zend_lineno))
+ ;
+
+backup_doc_comment:
+ ;; empty
+ ((CG doc_comment) (CG doc_comment) = NULL)
+ ;
+
+backup_fn_flags:
+ prec PREC_ARROW_FUNCTION ;; empty
+ ((CG extra_fn_flags) (CG extra_fn_flags) = 0)
+ ;
+
+backup_lex_pos:
+ ;; empty
+ ((LANG_SCNG yy_text))
+ ;
+
+returns_ref:
+ ;; empty
+ ($$ = 0)
+ | '&' ($$ = ZEND_ACC_RETURN_REFERENCE)
+ ;
+
+lexical_vars:
+ ;; empty
+ ($$ = NULL)
+ | T_USE '(' lexical_var_list ')' ($3)
+ ;
+
+lexical_var_list:
+ lexical_var_list ',' lexical_var ((zend_ast_list_add $1 $3))
+ | lexical_var ((zend_ast_create_list 1 ZEND_AST_CLOSURE_USES $1))
+ ;
+
+lexical_var:
+ T_VARIABLE ($1)
+ | '&' T_VARIABLE ($2 (put $$ 'attr 'ZEND_BIND_REF))
+ ;
+
+function_call:
+ name argument_list ((zend_ast_create ZEND_AST_CALL $1 $2))
+ | class_name T_PAAMAYIM_NEKUDOTAYIM member_name argument_list
((zend_ast_create ZEND_AST_STATIC_CALL $1 $3 $4))
+ | variable_class_name T_PAAMAYIM_NEKUDOTAYIM member_name argument_list
((zend_ast_create ZEND_AST_STATIC_CALL $1 $3 $4))
+ | callable_expr argument_list ((zend_ast_create ZEND_AST_CALL $1 $2))
+ ;
+
+class_name:
+ T_STATIC (zval zv (ZVAL_INTERNED_STR &zv (ZSTR_KNOWN ZEND_STR_STATIC))
(zend_ast_create_zval_ex &zv ZEND_NAME_NOT_FQ))
+ | name ($1)
+ ;
+
+class_name_reference:
+ class_name ($1)
+ | new_variable ($1)
+ ;
+
+exit_expr:
+ ;; empty
+ ($$ = NULL)
+ | '(' optional_expr ')' ($2)
+ ;
+
+backticks_expr:
+ ;; empty
+ ((zend_ast_create_zval_from_str (ZSTR_EMPTY_ALLOC)))
+ | T_ENCAPSED_AND_WHITESPACE ($1)
+ | encaps_list ($1)
+ ;
+
+ctor_arguments:
+ ;; empty
+ ((zend_ast_create_list 0 ZEND_AST_ARG_LIST))
+ | argument_list ($1)
+ ;
+
+dereferencable_scalar:
+ T_ARRAY '(' array_pair_list ')' ($3 (put $$ 'attr 'ZEND_ARRAY_SYNTAX_LONG))
+ | '[' array_pair_list ']' ($2 (put $$ 'attr 'ZEND_ARRAY_SYNTAX_SHORT))
+ | T_CONSTANT_ENCAPSED_STRING ($1)
+ ;
+
+scalar:
+ T_LNUMBER ($1)
+ | T_DNUMBER ($1)
+ | T_LINE ((zend_ast_create_ex ZEND_AST_MAGIC_CONST T_LINE))
+ | T_FILE ((zend_ast_create_ex ZEND_AST_MAGIC_CONST T_FILE))
+ | T_DIR ((zend_ast_create_ex ZEND_AST_MAGIC_CONST T_DIR))
+ | T_TRAIT_C ((zend_ast_create_ex ZEND_AST_MAGIC_CONST T_TRAIT_C))
+ | T_METHOD_C ((zend_ast_create_ex ZEND_AST_MAGIC_CONST T_METHOD_C))
+ | T_FUNC_C ((zend_ast_create_ex ZEND_AST_MAGIC_CONST T_FUNC_C))
+ | T_NS_C ((zend_ast_create_ex ZEND_AST_MAGIC_CONST T_NS_C))
+ | T_CLASS_C ((zend_ast_create_ex ZEND_AST_MAGIC_CONST T_CLASS_C))
+ | T_START_HEREDOC T_ENCAPSED_AND_WHITESPACE T_END_HEREDOC ($2)
+ | T_START_HEREDOC T_END_HEREDOC ((zend_ast_create_zval_from_str
(ZSTR_EMPTY_ALLOC)))
+ | '"' encaps_list '"' ($2)
+ | T_START_HEREDOC encaps_list T_END_HEREDOC ($2)
+ | dereferencable_scalar ($1)
+ | constant ($1)
+ ;
+
+constant:
+ name ((zend_ast_create ZEND_AST_CONST $1))
+ | class_name T_PAAMAYIM_NEKUDOTAYIM identifier
((zend_ast_create_class_const_or_name $1 $3))
+ | variable_class_name T_PAAMAYIM_NEKUDOTAYIM identifier
((zend_ast_create_class_const_or_name $1 $3))
+ ;
+
+optional_expr:
+ ;; empty
+ ($$ = NULL)
+ | expr ($1)
+ ;
+
+variable_class_name:
+ dereferencable ($1)
+ ;
+
+dereferencable:
+ variable ($1)
+ | '(' expr ')' ($2)
+ | dereferencable_scalar ($1)
+ ;
+
+callable_expr:
+ callable_variable ($1)
+ | '(' expr ')' ($2)
+ | dereferencable_scalar ($1)
+ ;
+
+callable_variable:
+ simple_variable ((zend_ast_create ZEND_AST_VAR $1))
+ | dereferencable '[' optional_expr ']' ((zend_ast_create ZEND_AST_DIM $1
$3))
+ | constant '[' optional_expr ']' ((zend_ast_create ZEND_AST_DIM $1 $3))
+ | dereferencable '{' expr '}' ((zend_ast_create_ex ZEND_AST_DIM
ZEND_DIM_ALTERNATIVE_SYNTAX $1 $3))
+ | dereferencable T_OBJECT_OPERATOR property_name argument_list
((zend_ast_create ZEND_AST_METHOD_CALL $1 $3 $4))
+ | function_call ($1)
+ ;
+
+variable:
+ callable_variable ($1)
+ | static_member ($1)
+ | dereferencable T_OBJECT_OPERATOR property_name ((zend_ast_create
ZEND_AST_PROP $1 $3))
+ ;
+
+simple_variable:
+ T_VARIABLE ($1)
+ | '$' '{' expr '}' ($3)
+ | '$' simple_variable ((zend_ast_create ZEND_AST_VAR $2))
+ ;
+
+static_member:
+ class_name T_PAAMAYIM_NEKUDOTAYIM simple_variable ((zend_ast_create
ZEND_AST_STATIC_PROP $1 $3))
+ | variable_class_name T_PAAMAYIM_NEKUDOTAYIM simple_variable
((zend_ast_create ZEND_AST_STATIC_PROP $1 $3))
+ ;
+
+new_variable:
+ simple_variable ((zend_ast_create ZEND_AST_VAR $1))
+ | new_variable '[' optional_expr ']' ((zend_ast_create ZEND_AST_DIM $1 $3))
+ | new_variable '{' expr '}' ((zend_ast_create_ex ZEND_AST_DIM
ZEND_DIM_ALTERNATIVE_SYNTAX $1 $3))
+ | new_variable T_OBJECT_OPERATOR property_name ((zend_ast_create
ZEND_AST_PROP $1 $3))
+ | class_name T_PAAMAYIM_NEKUDOTAYIM simple_variable ((zend_ast_create
ZEND_AST_STATIC_PROP $1 $3))
+ | new_variable T_PAAMAYIM_NEKUDOTAYIM simple_variable ((zend_ast_create
ZEND_AST_STATIC_PROP $1 $3))
+ ;
+
+member_name:
+ identifier ($1)
+ | '{' expr '}' ($2)
+ | simple_variable ((zend_ast_create ZEND_AST_VAR $1))
+ ;
+
+property_name:
+ T_STRING ($1)
+ | '{' expr '}' ($2)
+ | simple_variable ((zend_ast_create ZEND_AST_VAR $1))
+ ;
+
+array_pair_list:
+ non_empty_array_pair_list (;; allow single trailing comma
+(zend_ast_list_rtrim $1))
+ ;
+
+possible_array_pair:
+ ;; empty
+ ($$ = NULL)
+ | array_pair ($1)
+ ;
+
+non_empty_array_pair_list:
+ non_empty_array_pair_list ',' possible_array_pair ((zend_ast_list_add $1
$3))
+ | possible_array_pair ((zend_ast_create_list 1 ZEND_AST_ARRAY $1))
+ ;
+
+array_pair:
+ expr T_DOUBLE_ARROW expr ((zend_ast_create ZEND_AST_ARRAY_ELEM $3 $1))
+ | expr ((zend_ast_create ZEND_AST_ARRAY_ELEM $1 nil)
+ | expr T_DOUBLE_ARROW '&' variable ((zend_ast_create_ex
ZEND_AST_ARRAY_ELEM 1 $4 $1))
+ | '&' variable ((zend_ast_create_ex ZEND_AST_ARRAY_ELEM 1 $2 nil)
+ | T_ELLIPSIS expr ((zend_ast_create ZEND_AST_UNPACK $2))
+ | expr T_DOUBLE_ARROW T_LIST '(' array_pair_list ')' ((put $5 'attr
'ZEND_ARRAY_SYNTAX_LIST) (zend_ast_create ZEND_AST_ARRAY_ELEM $5 $1))
+ | T_LIST '(' array_pair_list ')' ((put $3 'attr 'ZEND_ARRAY_SYNTAX_LIST)
(zend_ast_create ZEND_AST_ARRAY_ELEM $3 nil)
+ ;
+
+encaps_list:
+ encaps_list encaps_var ((zend_ast_list_add $1 $2))
+ | encaps_list T_ENCAPSED_AND_WHITESPACE ((zend_ast_list_add $1 $2))
+ | encaps_var ((zend_ast_create_list 1 ZEND_AST_ENCAPS_LIST $1))
+ | T_ENCAPSED_AND_WHITESPACE encaps_var ((zend_ast_create_list 2
ZEND_AST_ENCAPS_LIST $1 $2))
+ ;
+
+encaps_var:
+ T_VARIABLE ((zend_ast_create ZEND_AST_VAR $1))
+ | T_VARIABLE '[' encaps_var_offset ']' ((zend_ast_create ZEND_AST_DIM
(zend_ast_create ZEND_AST_VAR $1) $3))
+ | T_VARIABLE T_OBJECT_OPERATOR T_STRING ((zend_ast_create ZEND_AST_PROP
(zend_ast_create ZEND_AST_VAR $1) $3))
+ | T_DOLLAR_OPEN_CURLY_BRACES expr '}' ((zend_ast_create ZEND_AST_VAR $2))
+ | T_DOLLAR_OPEN_CURLY_BRACES T_STRING_VARNAME '}' ((zend_ast_create
ZEND_AST_VAR $2))
+ | T_DOLLAR_OPEN_CURLY_BRACES T_STRING_VARNAME '[' expr ']' '}'
((zend_ast_create ZEND_AST_DIM (zend_ast_create ZEND_AST_VAR $2) $4))
+ | T_CURLY_OPEN variable '}' ($2)
+ ;
+
+encaps_var_offset:
+ T_STRING ($1)
+ | T_NUM_STRING ($1)
+ | '-' T_NUM_STRING ((zend_negate_num_string $2))
+ | T_VARIABLE ((zend_ast_create ZEND_AST_VAR $1))
+ ;
+
+internal_functions_in_yacc:
+ T_ISSET '(' isset_variables possible_comma ')' ($3)
+ | T_EMPTY '(' expr ')' ((zend_ast_create ZEND_AST_EMPTY $3))
+ | T_INCLUDE expr ((zend_ast_create_ex ZEND_AST_INCLUDE_OR_EVAL
ZEND_INCLUDE $2))
+ | T_INCLUDE_ONCE expr ((zend_ast_create_ex ZEND_AST_INCLUDE_OR_EVAL
ZEND_INCLUDE_ONCE $2))
+ | T_EVAL '(' expr ')' ((zend_ast_create_ex ZEND_AST_INCLUDE_OR_EVAL
ZEND_EVAL $3))
+ | T_REQUIRE expr ((zend_ast_create_ex ZEND_AST_INCLUDE_OR_EVAL
ZEND_REQUIRE $2))
+ | T_REQUIRE_ONCE expr ((zend_ast_create_ex ZEND_AST_INCLUDE_OR_EVAL
ZEND_REQUIRE_ONCE $2))
+ ;
+
+isset_variables:
+ isset_variable ($1)
+ | isset_variables ',' isset_variable ((zend_ast_create ZEND_AST_AND $1 $3))
+ ;
+
+isset_variable:
+ expr ((zend_ast_create ZEND_AST_ISSET $1))
+ ;
+
+
+;; NOTE Generated grammar ends here
\ No newline at end of file
diff --git a/test/phps-mode-test-functions.el b/test/phps-mode-test-functions.el
index 53d2c83..a44332b 100644
--- a/test/phps-mode-test-functions.el
+++ b/test/phps-mode-test-functions.el
@@ -874,67 +874,67 @@
(phps-mode-test-with-buffer
"<?php\nclass myClass {\n public function myFunctionA() {}\n
protected function myFunctionB() {}\n}\n"
"Imenu object-oriented file"
- (should (equal (phps-mode-functions-get-imenu) '(("myClass" .
(("*definition*" . 13) ("myFunctionA" . 43) ("myFunctionB" . 83)))))))
+ (should (equal (phps-mode-functions-get-imenu) '(("myClass" .
(("myFunctionA" . 43) ("myFunctionB" . 83)))))))
(phps-mode-test-with-buffer
"<?php\ninterface myInterface {\n public function myFunctionA() {}\n
protected function myFunctionB() {}\n}\n"
"Imenu object-oriented file with interface"
- (should (equal (phps-mode-functions-get-imenu) '(("myInterface" .
(("*definition*" . 17) ("myFunctionA" . 51) ("myFunctionB" . 91)))))))
+ (should (equal (phps-mode-functions-get-imenu) '(("myInterface" .
(("myFunctionA" . 51) ("myFunctionB" . 91)))))))
(phps-mode-test-with-buffer
"<?php\nnamespace myNamespace {\n class myClass {\n public
function myFunctionA() {}\n protected function myFunctionB() {}\n
}\n}\n"
"Imenu object-oriented file with namespace, class and function"
- (should (equal (phps-mode-functions-get-imenu) '(("myNamespace"
("*definition*" . 17) ("myClass" ("*definition*" . 41) ("myFunctionA" . 75)
("myFunctionB" . 119)))))))
+ (should (equal (phps-mode-functions-get-imenu) '(("myNamespace" ("myClass"
("myFunctionA" . 75) ("myFunctionB" . 119)))))))
(phps-mode-test-with-buffer
"<?php\nnamespace myNamespace;\nclass myClass {\n public function
myFunctionA() {}\n protected function myFunctionB() {}\n}\n"
"Imenu object-oriented file with bracket-less namespace, class and function"
- (should (equal (phps-mode-functions-get-imenu) '(("myNamespace"
("*definition*" . 17) ("myClass" ("*definition*" . 36) ("myFunctionA" . 66)
("myFunctionB" . 106)))))))
+ (should (equal (phps-mode-functions-get-imenu) '(("myNamespace" ("myClass"
("myFunctionA" . 66) ("myFunctionB" . 106)))))))
(phps-mode-test-with-buffer
"<?php\nnamespace myNamespace {\n class myClass extends myAbstract {\n
public function myFunctionA() {}\n protected function myFunctionB()
{}\n }\n}\n"
"Imenu object-oriented file with namespace, class that extends and
functions"
- (should (equal (phps-mode-functions-get-imenu) '(("myNamespace"
("*definition*" . 17) ("myClass" ("*definition*" . 41) ("myFunctionA" . 94)
("myFunctionB" . 138)))))))
+ (should (equal (phps-mode-functions-get-imenu) '(("myNamespace" ("myClass"
("myFunctionA" . 94) ("myFunctionB" . 138)))))))
(phps-mode-test-with-buffer
"<?php\nnamespace myNamespace;\nclass myClass extends myAbstract implements
myInterface {\n public function myFunctionA() {}\n protected function
myFunctionB() {}\n}\n"
"Imenu object-oriented file with bracket-less namespace, class that extends
and implements and functions"
- (should (equal (phps-mode-functions-get-imenu) '(("myNamespace"
("*definition*" . 17) ("myClass" ("*definition*" . 36) ("myFunctionA" . 108)
("myFunctionB" . 148)))))))
+ (should (equal (phps-mode-functions-get-imenu) '(("myNamespace" ("myClass"
("myFunctionA" . 108) ("myFunctionB" . 148)))))))
(phps-mode-test-with-buffer
"<?php\nnamespace myNamespace;\nclass myClass extends myAbstract implements
myInterface {\n public function myFunctionA($myArg = null) {}\n protected
function myFunctionB($myArg = 'abc') {}\n}\n"
"Imenu object-oriented file with bracket-less namespace, class that extends
and implements and functions with optional arguments"
- (should (equal (phps-mode-functions-get-imenu) '(("myNamespace"
("*definition*" . 17) ("myClass" ("*definition*" . 36) ("myFunctionA" . 108)
("myFunctionB" . 161)))))))
+ (should (equal (phps-mode-functions-get-imenu) '(("myNamespace" ("myClass"
("myFunctionA" . 108) ("myFunctionB" . 161)))))))
(phps-mode-test-with-buffer
"<?php\nnamespace myNamespace\\myNamespace2;\nclass myClass extends
myAbstract implements myInterface {\n public function myFunctionA($myArg =
null) {}\n protected function myFunctionB($myArg = 'abc') {}\n}\n"
"Imenu object-oriented file with bracket-less namespace with multiple
levels, class that extends and implements and functions with optional arguments"
- (should (equal (phps-mode-functions-get-imenu)
'(("myNamespace\\myNamespace2" ("*definition*" . 29) ("myClass" ("*definition*"
. 49) ("myFunctionA" . 121) ("myFunctionB" . 174)))))))
+ (should (equal (phps-mode-functions-get-imenu)
'(("myNamespace\\myNamespace2" ("myClass" ("myFunctionA" . 121) ("myFunctionB"
. 174)))))))
(phps-mode-test-with-buffer
"<?php\nclass myClass\n{\n\n public function myFunction1()\n {\n
echo \"my string with variable {$variable} inside it\";\n }\n\n public
function myFunction2()\n {\n }\n\n}"
"Imenu with double quoted string with variable inside it"
- (should (equal (phps-mode-functions-get-imenu) '(("myClass" ("*definition*"
. 13) ("myFunction1" . 44) ("myFunction2" . 153))))))
+ (should (equal (phps-mode-functions-get-imenu) '(("myClass" ("myFunction1"
. 44) ("myFunction2" . 153))))))
(phps-mode-test-with-buffer
"<?php\n\nnamespace MyNamespace;\n\nclass MyClass\n{\n\n /**\n *\n
*/\n public function __construct()\n {\n if ($test) {\n
}\n }\n\n /**\n *\n */\n public function myFunction1()\n
{\n $this->addMessage(\"My random {$message} here\" . ($random > 1 ?
\"A\" : \"\") . \" was here.\");\n }\n \n /**\n *\n */\n
public function myFunction2()\n {\n }\n\n /**\n * It's good\n
*/\n public function my [...]
"Imenu with double quoted string with variable inside it and concatenated
string"
- (should (equal (phps-mode-functions-get-imenu) '(("MyNamespace"
("*definition*" . 18) ("MyClass" ("*definition*" . 38) ("__construct" . 92)
("myFunction1" . 193) ("myFunction2" . 365) ("myFunction3" . 445)
("myFunction4" . 515)))))))
+ (should (equal (phps-mode-functions-get-imenu) '(("MyNamespace" ("MyClass"
("__construct" . 92) ("myFunction1" . 193) ("myFunction2" . 365) ("myFunction3"
. 445) ("myFunction4" . 515)))))))
(phps-mode-test-with-buffer
"<?php\nclass myClass {}"
"Imenu empty class"
- (should (equal (phps-mode-functions-get-imenu) '(("myClass" ("*definition*"
. 13))))))
+ (should (equal (phps-mode-functions-get-imenu) nil)))
(phps-mode-test-with-buffer
"<?php\nnamespace myNamespace {}"
"Imenu empty bracketed namespace"
- (should (equal (phps-mode-functions-get-imenu) '(("myNamespace"
("*definition*" . 17))))))
+ (should (equal (phps-mode-functions-get-imenu) nil)))
(phps-mode-test-with-buffer
"<?php\nnamespace myNamespace;"
"Imenu empty namespace without brackets"
- (should (equal (phps-mode-functions-get-imenu) '(("myNamespace"
("*definition*" . 17))))))
+ (should (equal (phps-mode-functions-get-imenu) nil)))
)
@@ -992,6 +992,22 @@
(let ((buffer-contents (buffer-substring-no-properties (point-min)
(point-max))))
(should (equal buffer-contents "<?php\nnamespace myNamespace;\nclass
myClass extends myAbstract implements myInterface {\n public function
myFunctionA($myArg = null) {}\n protected function myFunctionB($myArg =
'abc') {}\n}\n"))))
+ (phps-mode-test-with-buffer
+ "<?php\nnamespace myNamespace;\nclass myClass extends myAbstract/*
implements myInterface */{\n // public function myFunctionA($myArg = null)
{}\n protected function myFunctionB($myArg = 'abc') {}\n}"
+ "Comment region were some of the region is already commented-out"
+ ;; (message "Tokens %s" phps-mode-lexer-tokens)
+ (comment-region (point-min) (point-max))
+ (let ((buffer-contents (buffer-substring-no-properties (point-min)
(point-max))))
+ (should (equal buffer-contents "<?php\n/* namespace myNamespace;\nclass
myClass extends myAbstract *//* implements myInterface *//* { */\n //
public function myFunctionA($myArg = null) {}\n /* protected function
myFunctionB($myArg = 'abc') {}\n} */"))))
+
+ (phps-mode-test-with-buffer
+ "<?php\nnamespace myNamespace;\nclass myClass extends myAbstract/*
implements myInterface */{\n public function myFunctionA($myArg = null)
{}\n /* protected function myFunctionB($myArg = 'abc') {} */\n}"
+ "Un-comment region were some of the region is already un-commented"
+ ;; (message "Tokens %s" phps-mode-lexer-tokens)
+ (uncomment-region (point-min) (point-max))
+ (let ((buffer-contents (buffer-substring-no-properties (point-min)
(point-max))))
+ (should (equal buffer-contents "<?php\nnamespace myNamespace;\nclass
myClass extends myAbstract implements myInterface {\n public function
myFunctionA($myArg = null) {}\n protected function myFunctionB($myArg =
'abc') {}\n}"))))
+
)
(defun phps-mode-test-functions-get-inline-html-indentation ()
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [elpa] externals/phps-mode 5d77b9b: Improved imenu generation, comment/uncomment and more work on Wisent,
Christian Johansson <=