branch: externals/phps-mode
commit 0919855a3117c7a384a564ff38f2e1ba66cb7682
Author: Christian Johansson <[email protected]>
Commit: Christian Johansson <[email protected]>
Added SDT for concat operation
---
phps-mode-ast-bookkeeping.el | 11 ++++++-----
phps-mode-parser-sdt.el | 15 ++++++++++++++-
test/phps-mode-test-ast.el | 26 +++++++++++++-------------
3 files changed, 33 insertions(+), 19 deletions(-)
diff --git a/phps-mode-ast-bookkeeping.el b/phps-mode-ast-bookkeeping.el
index 4bdbf8fa9b..a5b2d6953e 100644
--- a/phps-mode-ast-bookkeeping.el
+++ b/phps-mode-ast-bookkeeping.el
@@ -601,14 +601,15 @@
defined
bookkeeping)))
- ;; Infix operations
+ ;; Infix expressions
((or
(equal type 'addition-expression)
(equal type 'boolean-and-expression)
(equal type 'boolean-or-expression)
(equal type 'logical-and-expression)
(equal type 'logical-or-expression)
- (equal type 'logical-xor-expression))
+ (equal type 'logical-xor-expression)
+ (equal type 'concat-expression))
(when-let ((bs (reverse (plist-get item 'b))))
(dolist (b bs)
(push `(,scope ,b) bookkeeping-stack)))
@@ -888,9 +889,9 @@
(let ((sub-scope scope))
(setq arrow-function-count (1+ arrow-function-count))
(push `(type arrow-function name ,arrow-function-count)
sub-scope)
- (when-let ((inner-statement-list (reverse (plist-get item
'inner-statement-list))))
- (dolist (inner-statement inner-statement-list)
- (push `(,sub-scope ,inner-statement) bookkeeping-stack)))
+ (when-let ((expr (reverse (plist-get item 'expr))))
+ (dolist (e expr)
+ (push `(,sub-scope ,e) bookkeeping-stack)))
(when-let ((parameter-list (plist-get item 'parameter-list)))
(dolist (parameter parameter-list)
(let ((ids
diff --git a/phps-mode-parser-sdt.el b/phps-mode-parser-sdt.el
index 60dab6ff4c..1ecb0b778c 100644
--- a/phps-mode-parser-sdt.el
+++ b/phps-mode-parser-sdt.el
@@ -835,6 +835,19 @@
,(phps-mode-parser-sdt--get-list-of-object (nth 2 args))))
phps-mode-parser--table-translations)
+;; expr -> (expr "." expr)
+(puthash
+ 365
+ (lambda(args _terminals)
+ `(
+ ast-type
+ concat-expression
+ a
+ (phps-mode-parser-sdt--get-list-of-object ,(nth 0 args))
+ b
+ ,(phps-mode-parser-sdt--get-list-of-object (nth 2 args))))
+ phps-mode-parser--table-translations)
+
;; expr -> (expr "+" expr)
(puthash
366
@@ -929,7 +942,7 @@
(nth 8 args)
'backup-lex-pos
(nth 9 args)
- 'inner-statement-list
+ 'expr
(phps-mode-parser-sdt--get-list-of-object (nth 10 args))
'backup-fn-flags-2
(nth 11 args))))
diff --git a/test/phps-mode-test-ast.el b/test/phps-mode-test-ast.el
index ebf832e029..e5b07e2737 100644
--- a/test/phps-mode-test-ast.el
+++ b/test/phps-mode-test-ast.el
@@ -37,17 +37,17 @@
buffer-contents
name
(lambda()
- ;; (let ((parse (phps-mode-parser-parse)))
- ;; (message "Left-to-right with right-most derivation:\n%S\n" parse)
- ;; (dolist (production-number (reverse parse))
- ;; (let ((production
- ;; (phps-mode-parser--get-grammar-production-by-number
- ;; production-number)))
- ;; (message
- ;; "%d: %S -> %S"
- ;; production-number
- ;; (car (car production))
- ;; (car (cdr production))))))
+ (let ((parse (phps-mode-parser-parse)))
+ (message "Left-to-right with right-most derivation:\n%S\n" parse)
+ (dolist (production-number (reverse parse))
+ (let ((production
+ (phps-mode-parser--get-grammar-production-by-number
+ production-number)))
+ (message
+ "%d: %S -> %S"
+ production-number
+ (car (car production))
+ (car (cdr production))))))
(phps-mode-ast--generate)
(phps-mode-ast-bookkeeping--generate)
(should
@@ -404,11 +404,11 @@
"Bookkeeping of $this not available inside static method"
'(((68 73) 0) (" class MyClass function there id $this" 1) ((153 158) 1)))
- ;; TODO Make this test work and pass
+ ;; TODO Make this test pass
(phps-mode-test-ast--should-bookkeep
"<?php\n\nclass myClass\n{\n private $test = 'abc';\n public function
test($d)\n {\n return fn($e) => $this->test . $d . $e;\n
}\n}\n\n$a = new myClass();\necho $a->test('def')('ghi');"
"Bookkeeping of $this reference inside arrow function inside of method"
- '(0 1 2))
+ '((" class myClass id $test" 1) ((36 41) 1) (" class myClass function test
id $this" 1) (" class myClass function test id $d" 1) ((76 78) 1) (" class
myClass function test arrow function 1 id $e" 1) ((104 106) 1) ((111 116) 1)
((118 122) 1) ((125 127) 1) ((130 132) 1) (" id $a" 1) ((143 145) 1)))
(message "\n-- Ran tests for bookkeeping generation. --"))