[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/phps-mode 3d54b6ff01 022/212: Passed another test for b
From: |
Christian Johansson |
Subject: |
[elpa] externals/phps-mode 3d54b6ff01 022/212: Passed another test for bookkeeping generated via parser SDT |
Date: |
Wed, 26 Jan 2022 01:50:16 -0500 (EST) |
branch: externals/phps-mode
commit 3d54b6ff0155ef36f954e41361812d488d0b75b3
Author: Christian Johansson <christian@cvj.se>
Commit: Christian Johansson <christian@cvj.se>
Passed another test for bookkeeping generated via parser SDT
---
phps-mode-ast.el | 192 ++++++++++++++++++++++++++++++++++++++++++-------------
1 file changed, 149 insertions(+), 43 deletions(-)
diff --git a/phps-mode-ast.el b/phps-mode-ast.el
index 1dc4d4425a..1774c69227 100644
--- a/phps-mode-ast.el
+++ b/phps-mode-ast.el
@@ -278,9 +278,11 @@
;; (message "parameter: %S %S" args _terminals)
(let ((ast-object
(list
+ 'ast-type
+ 'parameter
'visibility
(nth 0 args)
- 'ast-type
+ 'type
(nth 1 args)
'is-reference
(nth 2 args)
@@ -355,6 +357,13 @@
ast-object))
phps-mode-parser--table-translations)
+;; 302: method_body -> ("{" inner_statement_list "}")
+(puthash
+ 302
+ (lambda(args terminals)
+ (nth 1 args))
+ phps-mode-parser--table-translations)
+
;; property -> (T_VARIABLE "=" expr backup_doc_comment)
(puthash
318
@@ -363,7 +372,7 @@
(list
'ast-type
'assign-property
- 'key
+ 'name
(nth 0 args)
'value
(nth 2 args)
@@ -538,33 +547,82 @@
(while bookkeeping-stack
(let ((item-raw (pop bookkeeping-stack))
(item)
- (namespace))
- (if (stringp (car item-raw))
+ (class)
+ (function)
+ (namespace)
+ (variable-namespace "")
+ (symbol-namespace ""))
+ (if (listp (car item-raw))
(progn
+ (setq
+ class
+ (nth 0 (car item-raw)))
+ (setq
+ function
+ (nth 1 (car item-raw)))
(setq
namespace
- (car item-raw))
+ (nth 2 (car item-raw)))
(setq
item
- (car (cdr item-raw))))
- (setq
- namespace
- "")
+ (car (cdr item-raw)))
+ (when namespace
+ (setq
+ symbol-namespace
+ (format
+ "%s namespace %s"
+ symbol-namespace
+ namespace)))
+ (when class
+ (setq
+ symbol-namespace
+ (format
+ "%s class %s"
+ symbol-namespace
+ class))
+ (when namespace
+ (setq
+ variable-namespace
+ (format
+ "%s namespace %s"
+ variable-namespace
+ namespace)))
+ (setq
+ variable-namespace
+ (format
+ "%s class %s"
+ variable-namespace
+ class)))
+ (when function
+ (setq
+ symbol-namespace
+ (format
+ "%s function %s"
+ symbol-namespace
+ function))
+ (setq
+ variable-namespace
+ (format
+ "%s function %s"
+ variable-namespace
+ function))))
(setq
item
item-raw))
+
(let ((type (plist-get item 'ast-type)))
(cond
((equal type 'variable)
(let ((id (format
"%s id %s"
- namespace
+ variable-namespace
(plist-get item 'name)))
(object (list
(plist-get item 'start)
(plist-get item 'end)))
(defined-p 0))
+
(when (gethash id bookkeeping)
(setq
defined-p
@@ -583,11 +641,12 @@
bookkeeping)))
((equal type 'function)
- (let ((subnamespace
+ (let* ((name (plist-get item 'name))
+ (subnamespace
(format
"%s function %s"
- namespace
- (plist-get item 'name))))
+ symbol-namespace
+ name)))
(when-let ((parameters (reverse (plist-get item 'parameters))))
(dolist (parameter parameters)
(let ((id (format
@@ -610,43 +669,88 @@
(dolist (child children)
(push
(list
- subnamespace
+ (list
+ class
+ name
+ namespace)
+ child)
+ bookkeeping-stack)))))
+
+ ((equal type 'method)
+ (let* ((name (plist-get item 'name))
+ (subnamespace
+ (format
+ "%s function %s"
+ symbol-namespace
+ name)))
+
+ ;; TODO should only do this is method is not static
+ (let ((this-id
+ (format
+ "%s id %s"
+ subnamespace
+ "$this")))
+ (puthash
+ this-id
+ 1
+ bookkeeping))
+ (when-let ((parameters (reverse (plist-get item 'parameters))))
+ (dolist (parameter parameters)
+ (let ((id (format
+ "%s id %s"
+ subnamespace
+ (plist-get parameter 'name)))
+ (object (list
+ (plist-get parameter 'start)
+ (plist-get parameter 'end))))
+ (puthash
+ id
+ 1
+ bookkeeping)
+ (puthash
+ object
+ 1
+ bookkeeping))))
+
+ (when-let ((children (reverse (plist-get item 'children))))
+ (dolist (child children)
+ (push
+ (list
+ (list
+ class
+ name
+ namespace)
child)
bookkeeping-stack)))))
((equal type 'namespace)
- (let ((subnamespace
- (format
- "%s namespace %s"
- namespace
- (plist-get item 'name))))
+ (let* ((name (plist-get item 'name))
+ (subnamespace
+ (format
+ "%s namespace %s"
+ symbol-namespace
+ name)))
(when-let ((children (reverse (plist-get item 'children))))
(dolist (child children)
- (if (equal
- (plist-get child 'ast-type)
- 'assign-variable)
- (push
- (list
- namespace
- child)
- bookkeeping-stack)
- (push
- (list
- subnamespace
- child)
- bookkeeping-stack))))))
+ (push
+ (list
+ (list
+ class
+ function
+ name)
+ child)
+ bookkeeping-stack)))))
((equal type 'class)
- (let ((subnamespace
- (format
- "%s class %s"
- namespace
- (plist-get item 'name))))
+ (let ((name (plist-get item 'name)))
(when-let ((children (reverse (plist-get item 'children))))
(dolist (child children)
(push
(list
- subnamespace
+ (list
+ name
+ function
+ namespace)
child)
bookkeeping-stack)))))
@@ -655,20 +759,22 @@
(when (equal (plist-get condition 'ast-type) 'variable)
(push
(list
- namespace
+ (list
+ class
+ function
+ namespace)
condition)
bookkeeping-stack))))
((equal type 'assign-variable)
(let ((id (format
"%s id %s"
- namespace
+ variable-namespace
(plist-get (plist-get item 'key) 'name)))
(object (list
(plist-get (plist-get item 'key) 'start)
(plist-get (plist-get item 'key) 'end)))
(defined 1))
- ;; (message "id: %S from %S" id item)
(when-let ((predefined (gethash id bookkeeping)))
(setq
defined
@@ -682,11 +788,11 @@
defined
bookkeeping)))
- ((equal type 'assign-property)
+ ((equal type 'property)
(let ((subject (plist-get item 'subject)))
(let ((id (format
"%s id %s"
- namespace
+ symbol-namespace
(plist-get subject 'name)))
(object (list
(plist-get subject 'start)
- [elpa] externals/phps-mode a530988fe0 134/212: Added more failing indent tests, (continued)
- [elpa] externals/phps-mode a530988fe0 134/212: Added more failing indent tests, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode 8c1f529f87 145/212: Passing indent for line after ending of statement / expression with trailing closing bracket, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode d7aa22d251 146/212: Added two new failing tests for indentation, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode c453932f32 139/212: Added TODO item, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode 8374026917 166/212: Improved indentation on lines starting with a closing square bracket, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode 2afb7dc87a 002/212: Generating basic imenu-index via parser SDT, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode 41b1566c40 010/212: Imenu generation via parser SDT passing more tests, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode 8f9870fb9b 013/212: Parser SDT does not use global variables, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode 4753734b0a 006/212: Moved syntax coloring to separate file, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode d037aa09bc 023/212: Added bookkeeping via parser SDT foreach ($x as $y) {}, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode 3d54b6ff01 022/212: Passed another test for bookkeeping generated via parser SDT,
Christian Johansson <=
- [elpa] externals/phps-mode 442ad93cb2 018/212: Fix for function parameter formatting in AST, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode 2a4d5dea37 019/212: Passed bookkeeping of function arguments, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode c29e35fea2 021/212: More work on bookkeeping, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode 0daaa97f8d 025/212: SDT for for() loop started, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode fa3681141b 027/212: Passed test for bookkeeping of conditional assignment via parser SDT, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode fc4c763d68 030/212: Added SDT for class properties, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode f7c261cee1 032/212: Generate parser command now compatible with latest emacs-parser-generator, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode f82c9a377d 033/212: Re-generated parser to verify automation functionality, improved automation documentation, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode f858060096 034/212: More work on bookkeeping generated from parser SDT, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode c83b1c264e 060/212: Fixed SDT for isset_variables, Christian Johansson, 2022/01/26