[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/phps-mode bc2ecad56a 11/15: More work on PHP 8.1
From: |
Christian Johansson |
Subject: |
[elpa] externals/phps-mode bc2ecad56a 11/15: More work on PHP 8.1 |
Date: |
Sat, 26 Feb 2022 02:06:37 -0500 (EST) |
branch: externals/phps-mode
commit bc2ecad56a11c27a8719687f5d1cca50c6b14096
Author: Christian Johansson <christian@cvj.se>
Commit: Christian Johansson <christian@cvj.se>
More work on PHP 8.1
---
phps-mode-ast-bookkeeping.el | 90 ++++++++++++++++++++++++++++++++++++++++++++
phps-mode-ast.el | 4 +-
phps-mode-lexer.el | 18 +++++++--
phps-mode-parser-sdt.el | 2 +-
phps-mode-syntax-color.el | 2 +-
test/phps-mode-test-ast.el | 15 +++++---
6 files changed, 119 insertions(+), 12 deletions(-)
diff --git a/phps-mode-ast-bookkeeping.el b/phps-mode-ast-bookkeeping.el
index d8bda44a4a..0484eed3cd 100644
--- a/phps-mode-ast-bookkeeping.el
+++ b/phps-mode-ast-bookkeeping.el
@@ -847,6 +847,96 @@
))))
+ ((equal type 'variable)
+ (let* ((subject (plist-get item 'array-object-dereferencable))
+ (downcase-subject-name (downcase (plist-get subject 'name)))
+ (property-name (plist-get item 'property-name)))
+
+ (when downcase-subject-name
+ (cond
+
+ ((string= downcase-subject-name "$this")
+ (puthash
+ (list
+ (plist-get subject 'start)
+ (plist-get subject 'end))
+ 1
+ bookkeeping)
+ ;; When current scope is arrow function
+ ;; we should go up in scope until we get out of
+ ;; arrow functions scope
+ (let ((sub-scope scope)
+ (head-scope)
+ (is-arrow-function-scope t))
+ (while (and
+ sub-scope
+ is-arrow-function-scope)
+ (setq
+ head-scope
+ (car sub-scope))
+ (setq
+ sub-scope
+ (cdr sub-scope))
+ (unless (equal
+ (plist-get head-scope 'type)
+ 'arrow-function)
+ (setq is-arrow-function-scope nil)))
+ (let* ((predefined)
+ (variable-ids
+
(phps-mode-ast-bookkeeping--generate-variable-scope-string
+ sub-scope
+ (concat "$" property-name)
+ t))
+ (symbol-id
+
(phps-mode-ast-bookkeeping--generate-symbol-scope-string
+ sub-scope
+ property-name))
+ (bookkeeping-object
+ (list
+ (plist-get item 'property-start)
+ (plist-get item 'property-end))))
+ (when (gethash symbol-id bookkeeping)
+ (setq
+ predefined
+ t))
+ (dolist (variable-id variable-ids)
+ (when (gethash variable-id bookkeeping)
+ (setq
+ predefined
+ t)))
+ (if predefined
+ (puthash
+ bookkeeping-object
+ 1
+ bookkeeping)
+ (puthash
+ bookkeeping-object
+ 0
+ bookkeeping)))))
+
+ (t
+ (let ((variable-ids
+
(phps-mode-ast-bookkeeping--generate-variable-scope-string
+ scope
+ (plist-get subject 'name)
+ t))
+ (predefined 0))
+ (dolist (variable-id variable-ids)
+ (when (gethash
+ variable-id
+ bookkeeping)
+ (setq
+ predefined
+ 1)))
+ (puthash
+ (list
+ (plist-get subject 'start)
+ (plist-get subject 'end))
+ predefined
+ bookkeeping)))
+
+ ))))
+
((equal type 'static-member)
(let* ((parent-class (plist-get item 'class))
(downcased-parent-class (downcase parent-class))
diff --git a/phps-mode-ast.el b/phps-mode-ast.el
index eca2c86800..e395a23a12 100644
--- a/phps-mode-ast.el
+++ b/phps-mode-ast.el
@@ -40,7 +40,7 @@
phps-mode-ast--parse-trail
parse-trail)
- ;; (message "\nTranslation:\n%S\n\n" translation)
+ (message "\nTranslation:\n%S\n\n" translation)
(when translation
(dolist (item translation)
@@ -90,7 +90,7 @@
ast
(reverse ast))
- ;; (message "AST:\n%S\n\n" ast)
+ (message "AST:\n%S\n\n" ast)
(setq
phps-mode-ast--tree
diff --git a/phps-mode-lexer.el b/phps-mode-lexer.el
index e3a2193d98..077e9d762d 100644
--- a/phps-mode-lexer.el
+++ b/phps-mode-lexer.el
@@ -9,8 +9,8 @@
;; any higher order meta-lexer logic goes into `phps-mode-lex-analyzer.el'.
;;
;; Features:
-;; * Defines the lexer for this grammar based on the Zend PHP 8.0 Lexer at
-;;
https://raw.githubusercontent.com/php/php-src/php-8.0.0/Zend/zend_language_parser.y
+;; * Defines the lexer for this grammar based on the Zend PHP 8.1 Lexer at
+;;
https://raw.githubusercontent.com/php/php-src/PHP-8.1/Zend/zend_language_scanner.l
;; which is using re2c.
;;; Code:
@@ -109,7 +109,8 @@
(defconst
phps-mode-lexer--lambdas-by-state
- #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8125
data (ST_IN_SCRIPTING ((lambda nil (when (looking-at "exit") (let ((match-end
(match-end 0)) (match-beginning (match-beginning 0))) (let ((matching-length (-
match-end match-beginning))) (when (> matching-length 0) (when (or (not
phps-mode-lexer--match-length) (> matching-length
phps-mode-lexer--match-length)) (setq phps-mode-lexer--match-length
matching-length) (setq phps-mode-lexer--match-body (lambda nil (phps- [...]
+ #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8125
data (ST_IN_SCRIPTING ((lambda nil (when (looking-at "exit") (let ((match-end
(match-end 0)) (match-beginning (match-beginning 0))) (let ((matching-length (-
match-end match-beginning))) (when (> matching-length 0) (when (or (not
phps-mode-lexer--match-length) (> matching-length
phps-mode-lexer--match-length)) (setq phps-mode-lexer--match-length
matching-length) (setq phps-mode-lexer--match-body (lambda nil (phps- [...]
+]*" "\\(\\$\\|\\.\\.\\.\\)")) (let ((match-end (match-end 0)) (match-beginning
(match-beginning 0))) (let ((matching-length (- match-end match-beginning)))
(when (> matching-length 0) (when (or (not phps-mode-lexer--match-length) (>
matching-length phps-mode-lexer--match-length)) (setq
phps-mode-lexer--match-length matching-length) (setq
phps-mode-lexer--match-body (lambda nil (phps-mode-lexer--yyless 1)
(phps-mode-lexer--return-token 'T_AMPERSAND_FOLLOWED_BY_VAR_OR_VARARG))) (setq
phps- [...]
" phps-mode-lexer--heredoc-label ";?
\\|\\$" phps-mode-lexer--label "\\|{\\$" phps-mode-lexer--label "\\|\\${"
phps-mode-lexer--label "\\)") nil t))) (if string-start (let* ((start
(match-beginning 0)) (end (match-end 0)) (data (buffer-substring-no-properties
start end))) (cond ((string-match (concat "
" phps-mode-lexer--heredoc-label ";?
@@ -1145,6 +1146,17 @@
(looking-at ">>")
(phps-mode-lexer--return-token 'T_SR))
+ (phps-mode-lexer--match-macro
+ ST_IN_SCRIPTING
+ (looking-at (concat "&" "[ \t\r\n]*" "\\(\\$\\|\\.\\.\\.\\)"))
+ (phps-mode-lexer--yyless 1)
+ (phps-mode-lexer--return-token 'T_AMPERSAND_FOLLOWED_BY_VAR_OR_VARARG))
+
+ (phps-mode-lexer--match-macro
+ ST_IN_SCRIPTING
+ (looking-at "&")
+ (phps-mode-lexer--return-token 'T_AMPERSAND_NOT_FOLLOWED_BY_VAR_OR_VARARG))
+
(phps-mode-lexer--match-macro
ST_IN_SCRIPTING
(looking-at
diff --git a/phps-mode-parser-sdt.el b/phps-mode-parser-sdt.el
index 83fe389536..b72207a1d9 100644
--- a/phps-mode-parser-sdt.el
+++ b/phps-mode-parser-sdt.el
@@ -1156,7 +1156,7 @@
;; attributed_class_statement -> (variable_modifiers
optional_type_without_static property_list ";")
(puthash
- 299
+ 298
(lambda(args terminals)
`(
ast-type
diff --git a/phps-mode-syntax-color.el b/phps-mode-syntax-color.el
index 60feee7449..5f622b2c08 100644
--- a/phps-mode-syntax-color.el
+++ b/phps-mode-syntax-color.el
@@ -11,7 +11,7 @@
(defvar
phps-mode-syntax-color--token-font-face
- #s(hash-table size 145 test equal rehash-size 1.5 rehash-threshold 0.8125
data (T_ERROR font-lock-warning-face T_OPEN_TAG font-lock-constant-face
T_OPEN_TAG_WITH_ECHO font-lock-constant-face T_CLOSE_TAG
font-lock-constant-face T_START_HEREDOC font-lock-constant-face T_END_HEREDOC
font-lock-constant-face T_ELLIPSIS font-lock-constant-face T_COALESCE
font-lock-constant-face T_DOUBLE_ARROW font-lock-constant-face T_INC
font-lock-constant-face T_DEC font-lock-constant-face T_IS_IDENTICAL f [...]
+ #s(hash-table size 149 test equal rehash-size 1.5 rehash-threshold 0.8125
data (T_ERROR font-lock-warning-face T_OPEN_TAG font-lock-constant-face
T_OPEN_TAG_WITH_ECHO font-lock-constant-face T_CLOSE_TAG
font-lock-constant-face T_START_HEREDOC font-lock-constant-face T_END_HEREDOC
font-lock-constant-face T_ELLIPSIS font-lock-constant-face T_COALESCE
font-lock-constant-face T_DOUBLE_ARROW font-lock-constant-face T_INC
font-lock-constant-face T_DEC font-lock-constant-face T_IS_IDENTICAL f [...]
"Syntax color table for tokens")
(defvar
diff --git a/test/phps-mode-test-ast.el b/test/phps-mode-test-ast.el
index bab8269a7b..3c7c470345 100644
--- a/test/phps-mode-test-ast.el
+++ b/test/phps-mode-test-ast.el
@@ -26,7 +26,7 @@
(lambda()
(let ((parse (phps-mode-parser-parse)))
(message "Left-to-right with right-most derivation in reverse:\n%S\n"
parse)
- (dolist (production-number (reverse parse))
+ (dolist (production-number parse)
(let ((production
(phps-mode-parser--get-grammar-production-by-number
production-number)))
@@ -38,9 +38,14 @@
(message "\n")
(phps-mode-ast--generate)
(phps-mode-ast-bookkeeping--generate)
- (message "bookkeeping: %S" (phps-mode-test--hash-to-list
- phps-mode-ast-bookkeeping--index
- t))
+ (message
+ "expected-bookkeeping: %S\n"
+ bookkeeping)
+ (message
+ "actual-bookkeeping: %S\n"
+ (phps-mode-test--hash-to-list
+ phps-mode-ast-bookkeeping--index
+ t))
(should
(equal
(phps-mode-test--hash-to-list
@@ -55,7 +60,7 @@
(lambda()
(let ((parse (phps-mode-parser-parse)))
(message "Left-to-right with right-most derivation in reverse:\n%S\n"
parse)
- (dolist (production-number (reverse parse))
+ (dolist (production-number parse)
(let ((production
(phps-mode-parser--get-grammar-production-by-number
production-number)))
- [elpa] externals/phps-mode updated (a42188a24f -> be18349ec9), Christian Johansson, 2022/02/26
- [elpa] externals/phps-mode 0f355f6f4d 05/15: Formatted automation output as elisp comments, Christian Johansson, 2022/02/26
- [elpa] externals/phps-mode ccbb452889 04/15: Fixed automatic grammar translation from PHP 8.1 YACC, Christian Johansson, 2022/02/26
- [elpa] externals/phps-mode 2122f23ad1 01/15: Added failing indentation case, Christian Johansson, 2022/02/26
- [elpa] externals/phps-mode 924fb345ec 06/15: Minor tweaks in parser generation automation, Christian Johansson, 2022/02/26
- [elpa] externals/phps-mode b82471b38a 09/15: Removed TODO item, Christian Johansson, 2022/02/26
- [elpa] externals/phps-mode 85eed0d30e 07/15: Updated parser to PHP 8.1, Christian Johansson, 2022/02/26
- [elpa] externals/phps-mode bc2ecad56a 11/15: More work on PHP 8.1,
Christian Johansson <=
- [elpa] externals/phps-mode b5fcf0e7b7 02/15: Updated automation for PHP 8.1, Christian Johansson, 2022/02/26
- [elpa] externals/phps-mode 3e1142c30c 14/15: Passing bookkeeping tests with PHP 8.1 parser and AST, Christian Johansson, 2022/02/26
- [elpa] externals/phps-mode be18349ec9 15/15: Updated version, date and TODO, Christian Johansson, 2022/02/26
- [elpa] externals/phps-mode fe89129aaa 03/15: More work on PHP 8.1 automation, Christian Johansson, 2022/02/26
- [elpa] externals/phps-mode 10336eed90 08/15: Parser now handles multiple alternative cases switch case statement, Christian Johansson, 2022/02/26
- [elpa] externals/phps-mode d7ae56f698 10/15: Passing imenu-tests for PHP 8.1, Christian Johansson, 2022/02/26
- [elpa] externals/phps-mode faf6632911 13/15: Improved SDT for more infix operators, Christian Johansson, 2022/02/26
- [elpa] externals/phps-mode 16ec02520a 12/15: Fixed ampersand in lexer, Christian Johansson, 2022/02/26