[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/phps-mode c29e35fea2 021/212: More work on bookkeeping
From: |
Christian Johansson |
Subject: |
[elpa] externals/phps-mode c29e35fea2 021/212: More work on bookkeeping |
Date: |
Wed, 26 Jan 2022 01:50:16 -0500 (EST) |
branch: externals/phps-mode
commit c29e35fea2df5e3e1b54b3af5e79a1716c74b035
Author: Christian Johansson <christian@cvj.se>
Commit: Christian Johansson <christian@cvj.se>
More work on bookkeeping
---
phps-mode-ast.el | 156 ++++++++++++++++++++++++++++++++++++++++++++++---------
1 file changed, 132 insertions(+), 24 deletions(-)
diff --git a/phps-mode-ast.el b/phps-mode-ast.el
index 7d3a37f319..1dc4d4425a 100644
--- a/phps-mode-ast.el
+++ b/phps-mode-ast.el
@@ -72,7 +72,7 @@
(lambda(args terminals)
(let ((ast-object
(list
- 'type
+ 'ast-type
'namespace
'name
(nth 1 args)
@@ -94,7 +94,7 @@
(lambda(args terminals)
(let ((ast-object
(list
- 'type
+ 'ast-type
'namespace
'name
(nth 1 args)
@@ -147,9 +147,9 @@
(lambda(args _terminals)
(let ((ast-object
(list
- 'type
+ 'ast-type
'echo
- 'body
+ 'children
(nth 1 args))))
ast-object))
phps-mode-parser--table-translations)
@@ -167,7 +167,7 @@
(lambda(args terminals)
(let ((ast-object
(list
- 'type
+ 'ast-type
'function
'name
(nth 2 args)
@@ -183,7 +183,7 @@
(nth 5 args)
'return-type
(nth 7 args)
- 'body
+ 'children
(nth 10 args))))
;; (message "Function: %S" ast-object)
;; (message "args: %S" args)
@@ -197,7 +197,7 @@
(lambda(args terminals)
(let ((ast-object
(list
- 'type
+ 'ast-type
'class
'name
(nth 1 args)
@@ -221,7 +221,7 @@
(lambda(args terminals)
(let ((ast-object
(list
- 'type
+ 'ast-type
'interface
'name
(nth 1 args)
@@ -246,11 +246,11 @@
;; (message "if_stmt_without_else: %S" args _terminals)
(let ((ast-object
(list
- 'type
+ 'ast-type
'if
'condition
(nth 2 args)
- 'body
+ 'children
(nth 4 args))))
ast-object))
phps-mode-parser--table-translations)
@@ -280,7 +280,7 @@
(list
'visibility
(nth 0 args)
- 'type
+ 'ast-type
(nth 1 args)
'is-reference
(nth 2 args)
@@ -308,16 +308,41 @@
ast-object))
phps-mode-parser--table-translations)
+;; attributed_class_statement -> (variable_modifiers
optional_type_without_static property_list ";")
+(puthash
+ 278
+ (lambda(args _terminals)
+ (let ((ast-object
+ (list
+ 'ast-type
+ 'property
+ 'modifiers
+ (nth 0 args)
+ 'type
+ (nth 1 args)
+ 'subject
+ (nth 2 args))))
+ ast-object))
+ phps-mode-parser--table-translations)
+
;; attributed_class_statement -> (method_modifiers function returns_ref
identifier backup_doc_comment "(" parameter_list ")" return_type
backup_fn_flags method_body backup_fn_flags)
(puthash
280
(lambda(args terminals)
(let ((ast-object
(list
- 'type
+ 'ast-type
'method
+ 'returns-reference-p
+ (not (equal (nth 2 args) nil))
'name
(nth 3 args)
+ 'parameters
+ (nth 6 args)
+ 'return-type
+ (nth 8 args)
+ 'children
+ (nth 10 args)
'index
(car (cdr (nth 3 terminals)))
'start
@@ -330,6 +355,27 @@
ast-object))
phps-mode-parser--table-translations)
+;; property -> (T_VARIABLE "=" expr backup_doc_comment)
+(puthash
+ 318
+ (lambda(args terminals)
+ (let ((ast-object
+ (list
+ 'ast-type
+ 'assign-property
+ 'key
+ (nth 0 args)
+ 'value
+ (nth 2 args)
+ 'index
+ (car (cdr (nth 0 terminals)))
+ 'start
+ (car (cdr (nth 0 terminals)))
+ 'end
+ (cdr (cdr (nth 0 terminals))))))
+ ast-object))
+ phps-mode-parser--table-translations)
+
;; expr -> (variable "=" expr)
(puthash
337
@@ -337,7 +383,7 @@
;; (message "expr: %S %S" args _terminals)
(let ((ast-object
(list
- 'type
+ 'ast-type
'assign-variable
'key
(nth 0 args)
@@ -356,10 +402,12 @@
;; (message "simple_variable: %S %S" args terminals)
(let ((ast-object
(list
- 'type
+ 'ast-type
'variable
'name
args
+ 'index
+ (car (cdr terminals))
'start
(car (cdr terminals))
'end
@@ -386,10 +434,10 @@
(when (listp item)
(cond
- ((plist-get item 'type)
+ ((plist-get item 'ast-type)
(if (and
(not namespace)
- (equal (plist-get item 'type) 'namespace)
+ (equal (plist-get item 'ast-type) 'namespace)
(equal (plist-get item 'end) 'max))
(progn
;; (message "Found global namespace: %S" item)
@@ -408,7 +456,7 @@
(dolist (sub-item item)
(when (and
(listp sub-item)
- (plist-get sub-item 'type))
+ (plist-get sub-item 'ast-type))
(if namespace
(push
sub-item
@@ -434,7 +482,7 @@
(let ((imenu-index))
(dolist (item ast)
(let ((children (plist-get item 'children))
- (item-type (plist-get item 'type))
+ (item-type (plist-get item 'ast-type))
(item-index (plist-get item 'index))
(parent))
(when (and
@@ -449,7 +497,7 @@
(progn
(dolist (child children)
(let ((grand-children (plist-get child 'children))
- (child-type (plist-get child 'type))
+ (child-type (plist-get child 'ast-type))
(subparent))
(if (and
(or
@@ -505,7 +553,7 @@
(setq
item
item-raw))
- (let ((type (plist-get item 'type)))
+ (let ((type (plist-get item 'ast-type)))
(cond
((equal type 'variable)
@@ -558,17 +606,53 @@
1
bookkeeping))))
- (when-let ((body (reverse (plist-get item 'body))))
- (dolist (body-item body)
+ (when-let ((children (reverse (plist-get item 'children))))
+ (dolist (child children)
+ (push
+ (list
+ subnamespace
+ child)
+ bookkeeping-stack)))))
+
+ ((equal type 'namespace)
+ (let ((subnamespace
+ (format
+ "%s namespace %s"
+ namespace
+ (plist-get item '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))))))
+
+ ((equal type 'class)
+ (let ((subnamespace
+ (format
+ "%s class %s"
+ namespace
+ (plist-get item 'name))))
+ (when-let ((children (reverse (plist-get item 'children))))
+ (dolist (child children)
(push
(list
subnamespace
- body-item)
+ child)
bookkeeping-stack)))))
((equal type 'if)
(let ((condition (plist-get item 'condition)))
- (when (equal (plist-get condition 'type) 'variable)
+ (when (equal (plist-get condition 'ast-type) 'variable)
(push
(list
namespace
@@ -598,6 +682,30 @@
defined
bookkeeping)))
+ ((equal type 'assign-property)
+ (let ((subject (plist-get item 'subject)))
+ (let ((id (format
+ "%s id %s"
+ namespace
+ (plist-get subject 'name)))
+ (object (list
+ (plist-get subject 'start)
+ (plist-get subject 'end)))
+ (defined 1))
+ ;; (message "id: %S from %S" id item)
+ (when-let ((predefined (gethash id bookkeeping)))
+ (setq
+ defined
+ (1+ predefined)))
+ (puthash
+ id
+ defined
+ bookkeeping)
+ (puthash
+ object
+ defined
+ bookkeeping))))
+
)))))
(setq
phps-mode-ast--bookkeeping
- [elpa] externals/phps-mode c453932f32 139/212: Added TODO item, (continued)
- [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, 2022/01/26
- [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 <=
- [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
- [elpa] externals/phps-mode 8fa61fa1f2 063/212: Passing bookkeeping of interface method arguments, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode 7a636ccd28 078/212: Removed obsolete file parser-grammar-macro.el, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode ee211dac6a 084/212: Started on indentation tests, Christian Johansson, 2022/01/26